renderer.h

C++ software renderer

src/renderer.h

824 B
#pragma once

#include <SDL.h>
#include <stdint.h>

#include "globals.h"

// could manually blit instead of using SDL_Renderer, but there's no point?
// GPU gets used to composite the window anyway.
// The only added step after skipping SDL_Renderer would be walking color_buffer and
// memcpying by the stride
struct Window {
    SDL_Window   *sdl_window;
    SDL_Renderer *renderer;
    SDL_Texture  *front_buffer;
    u32          *back_buffer;
    float        *depth_buffer;
    int           width;
    int           height;
};

struct InputState {
    bool move_forward;
    bool move_backward;
    bool move_left;
    bool move_right;
    bool move_up;
    bool move_down;
    int  mouse_dx;
    int  mouse_dy;
};

struct Camera;
struct ClipVertex;
struct ScreenTriangle;
struct Face;
struct Transform;
struct Mesh;