1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- /*
- * 3D Engine
- * display.h:
- * Based on pikuma.com 3D software renderer in C
- * Copyright (c) 2021 986-Studio. All rights reserved.
- *
- * Created by Manoël Trapier on 01/03/2021.
- */
- #ifndef THREEDENGINE_SOURCE_INCLUDE_DISPLAY_H
- #define THREEDENGINE_SOURCE_INCLUDE_DISPLAY_H
- #include <stdbool.h>
- #include <SDL.h>
- /***********************************************************************************************************************
- * Data types
- **********************************************************************************************************************/
- typedef uint32_t colour_t;
- /***********************************************************************************************************************
- * Constants
- **********************************************************************************************************************/
- #define FPS (60)
- #define FRAME_TARGET_TIME (1000 / FPS)
- /***********************************************************************************************************************
- * Global variables
- **********************************************************************************************************************/
- extern SDL_Window *window;
- extern SDL_Renderer *renderer;
- extern uint32_t *frameBuffer;
- extern SDL_Texture *frameBufferTexture;
- extern int32_t windowWidth;
- extern int32_t windowHeight;
- /***********************************************************************************************************************
- * Prototypes
- **********************************************************************************************************************/
- /* --- Window functions --- */
- bool initialiseWindow(bool fullScreen);
- void destroyWindow();
- void renderFrameBuffer();
- /* --- Drawing functions --- */
- void drawPixel(int32_t x, int32_t y, colour_t colour);
- void clearFrameBuffer(colour_t colour);
- void drawGrid(int spacing, colour_t colour);
- void drawRectangle(int32_t x, int32_t y, int32_t w, int32_t h, colour_t colour);
- void drawVLine(int32_t x, int32_t y0, int32_t y1, colour_t colour);
- void drawHLine(int32_t x0, int32_t y, int32_t x1, colour_t colour);
- void drawLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1, colour_t colour);
- void drawText(int32_t x, int32_t y, colour_t colour, const char *format, ...);
- static inline void intSwap(int *a, int *b)
- {
- int tmp = *a;
- *a = *b;
- *b = tmp;
- }
- static inline void doubleSwap(double *a, double *b)
- {
- double tmp = *a;
- *a = *b;
- *b = tmp;
- }
- #define MAKE_RGB(_r, _g, _b) ((0xFF000000) | ((_r & 0xFF) << 16) | ((_g & 0xFF) << 8) | ((_b & 0xFF)))
- #define MAKE_ARGB(_a, _r, _g, _b) (((_a & 0xFF) << 24) | ((_r & 0xFF) << 16) | ((_g & 0xFF) << 8) | ((_b & 0xFF)))
- #endif /* THREEDENGINE_SOURCE_INCLUDE_DISPLAY_H */
|