rasterizer

C++ software renderer

renderer.h

824 B
 1#pragma once
 2
 3#include <SDL.h>
 4#include <stdint.h>
 5
 6#include "globals.h"
 7
 8// could manually blit instead of using SDL_Renderer, but there's no point?
 9// GPU gets used to composite the window anyway.
10// The only added step after skipping SDL_Renderer would be walking color_buffer and
11// memcpying by the stride
12struct Window {
13    SDL_Window   *sdl_window;
14    SDL_Renderer *renderer;
15    SDL_Texture  *front_buffer;
16    u32          *back_buffer;
17    float        *depth_buffer;
18    int           width;
19    int           height;
20};
21
22struct InputState {
23    bool move_forward;
24    bool move_backward;
25    bool move_left;
26    bool move_right;
27    bool move_up;
28    bool move_down;
29    int  mouse_dx;
30    int  mouse_dy;
31};
32
33struct Camera;
34struct ClipVertex;
35struct ScreenTriangle;
36struct Face;
37struct Transform;
38struct Mesh;