#ifndef render_h #define render_h #include "rect.h" typedef struct { unsigned char r, g, b, a; } Colour; Colour make_colour(unsigned rgb, unsigned char a); Colour make_red(void); Colour make_green(void); Colour make_blue(void); Colour make_cyan(void); Colour make_pink(void); Colour make_yellow(void); Colour make_aliceblue(void); Colour blend(Colour dst, Colour src); Colour blend_mod(Colour dst, Colour src, Colour mod); Colour col_mul(Colour a, Colour b); typedef struct { Colour* p; int w, h; } Bitmap; typedef struct Texture { int w, h; } Texture; typedef struct { unsigned short p, n, t; } Mesh_Vert; typedef struct Mesh { int vc, pc, nc, tc; int* p, * n, * t; Mesh_Vert* verts; } Mesh; typedef struct { Colour* t; int* d; int asp, n; int vp[4]; Rect clip; } Renderer; int tri_os( const Renderer* r, const int* v0, const int* v1, const int* v2 ); int point_os( const Renderer* r, int x, int y ); Colour sample_tex(const Texture* t, int u, int v); void ren_begin(Renderer* r, Colour* t, int* d, int w, int h); void ren_end(Renderer* r); void ren_clear(Renderer* r); void ren_clearc(Renderer* r, Colour c); void ren_cleard(Renderer* r, int depth); void ren_clip(Renderer* r, const Rect* c); void ren_point(Renderer* r, Colour c, int x, int y); void ren_char( Renderer* r, Colour c, int x, int y, char ch ); void ren_chars( Renderer* r, Colour c, int x, int y, char ch ); void ren_text( Renderer* r, Colour c, int x, int y, const char* t ); void ren_texts( Renderer* r, Colour c, int x, int y, const char* t ); /* Vertex format: * x y z u v r g b * All fixed point values with 9 bits of precision. */ void ren_tri( Renderer* r, const int* v0, const int* v1, const int* v2, const Texture* tex ); /* Unsafe for 3D. Clips against the r->clip */ void ren_tri3( Renderer* r, const int* v0, const int* v1, const int* v2, const Texture* tex ); /* Does perspective calculation and clips against the near. */ void ren_mesh( Renderer* r, const Mesh* mesh, const Texture* tex ); #endif