1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- /*
- * 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>
- #include <vector.h>
- #include <texture.h>
- #include <colour.h>
- /***********************************************************************************************************************
- * Data types
- **********************************************************************************************************************/
- typedef struct window_t
- {
- int32_t height, width;
- } window_t;
- /***********************************************************************************************************************
- * Constants
- **********************************************************************************************************************/
- #define FPS (60)
- #define FRAME_TARGET_TIME (1000 / FPS)
- /***********************************************************************************************************************
- * Prototypes
- **********************************************************************************************************************/
- /* --- Window functions --- */
- bool initialiseWindow(int32_t screenWidth, int32_t screenHeight, bool fullScreen);
- void destroyWindow();
- void renderFrameBuffer();
- void getWindowSize(int32_t *width, int32_t *height);
- void displayWindowClear();
- void displayWindowRender();
- /* --- Drawing functions --- */
- void clearZBuffer();
- void clearFrameBuffer(colour_t colour);
- void drawPixel(int32_t x, int32_t y, 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;
- }
- /* Other */
- void drawZPixel(int32_t x, int32_t y, vec4_t a, vec4_t b, vec4_t c, colour_t colour);
- void drawTexel(int32_t x, int32_t y, vec4_t a, vec4_t b, vec4_t c, tex2_t ta, tex2_t tb, tex2_t tc, texture_t *texture);
- #endif /* THREEDENGINE_SOURCE_INCLUDE_DISPLAY_H */
|