1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- /*
- * 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>
- /***********************************************************************************************************************
- * Constants
- **********************************************************************************************************************/
- #define FPS (30)
- #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, uint32_t colour);
- void clearFrameBuffer(int32_t colour);
- void drawGrid(int spacing, uint32_t colour);
- void drawRectangle(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t colour);
- void drawVLine(int32_t x, int32_t y0, int32_t y1, uint32_t colour);
- void drawHLine(int32_t x0, int32_t y, int32_t x1, uint32_t colour);
- void drawLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t colour);
- static inline void intSwap(int *a, int *b)
- {
- int tmp = *a;
- *a = *b;
- *b = tmp;
- }
- #endif /* THREEDENGINE_SOURCE_INCLUDE_DISPLAY_H */
|