rasterizer

c++ software renderer

renderer.hpp

1.1 kB
 1#define _CRT_SECURE_NO_WARNINGS
 2
 3#pragma once
 4
 5#include <SDL.h>
 6#include <stdint.h>
 7
 8typedef int8_t   i8;
 9typedef int16_t  i16;
10typedef int32_t  i32;
11typedef int64_t  i64;
12typedef uint8_t  u8;
13typedef uint16_t u16;
14typedef uint32_t u32;
15typedef uint64_t u64;
16typedef float    f32;
17typedef double   f64;
18
19#define static_global   static
20#define static_local    static
21#define static_internal static
22
23// could manually blit instead of using SDL_Renderer, but there's no point?
24// GPU gets used to composite the window anyway.
25// The only added step after skipping SDL_Renderer would be walking color_buffer and
26// memcpying by the stride
27struct Window {
28    SDL_Window   *sdl_window;
29    SDL_Renderer *renderer;
30    SDL_Texture  *front_buffer;
31    u32          *back_buffer;
32    float        *depth_buffer;
33    int           width;
34    int           height;
35};
36
37struct InputState {
38    bool move_forward;
39    bool move_backward;
40    bool move_left;
41    bool move_right;
42    bool move_up;
43    bool move_down;
44    int  mouse_dx;
45    int  mouse_dy;
46};
47
48struct Camera;
49struct ClipVertex;
50struct ScreenTriangle;
51struct Face;
52struct Transform;
53struct Mesh;