Start implementing drawing order

This commit is contained in:
2024-07-14 00:49:41 +01:00
parent 77edf714bb
commit f6848b5f4f
7 changed files with 142 additions and 22 deletions

View File

@@ -31,7 +31,8 @@ MAKE_LIST_TYPE(scene_triangle_t);
typedef enum {
RASTERISER_RENDER_WIREFRAME,
RASTERISER_RENDER_SOLID,
RASTERISER_RENDER_FILLED,
RASTERISER_RENDER_SHADED,
} render_type_t;
typedef struct {
@@ -46,6 +47,9 @@ typedef struct {
f32 h0;
f32 h1;
f32 h2;
f32 z0;
f32 z1;
f32 z2;
colour_t colour;
} triangle_t;

View File

@@ -2,6 +2,7 @@
#define WINDOW_H
#include "aliases.h"
#include "mem_arena.h"
#include "vector/vec.h"
#include <SDL2/SDL_video.h>
#include <stdbool.h>
@@ -29,13 +30,17 @@ typedef struct {
SDL_Window *window;
SDL_Surface *front_buffer;
SDL_Surface *back_buffer;
f32 *z_buffer;
} window_t;
bool init_window(window_t *wnd, u32 width, u32 height, const char *title);
bool init_window(Arena *arena, window_t *wnd, u32 width, u32 height,
const char *title);
void close_window(window_t *wnd);
void clear_window(window_t *wnd, colour_t colour);
void set_pixel(window_t *wnd, i32 x, i32 y, colour_t colour);
void set_z_pixel(window_t *wnd, i32 x, i32 y, f32 value);
f32 get_z_pixel(const window_t *wnd, i32 x, i32 y);
void swap_buffers(window_t *wnd);
vec3f_t window_to_viewport(const window_t *wnd, i32 x, i32 y, vec3f_t viewport);