prosperon/source/engine/render.h

117 lines
2 KiB
C
Raw Normal View History

#ifndef OPENGL_RENDER_H
#define OPENGL_RENDER_H
2021-11-30 21:29:18 -06:00
2023-09-05 09:38:52 -05:00
#if defined __linux__
#define SOKOL_GLCORE33
#elif __EMSCRIPTEN__
#define SOKOL_GLES3
#elif __WIN32
#define SOKOL_D3D11
2023-09-05 09:38:52 -05:00
#define SOKOL_WIN32_FORCE_MAIN
#elif __APPLE__
#define SOKOL_METAL
2023-09-05 09:38:52 -05:00
#endif
2023-05-22 00:08:08 -05:00
#include "sokol/sokol_gfx.h"
2023-05-30 13:07:18 -05:00
#include "HandmadeMath.h"
#define RGBA_MAX 255
#include "window.h"
extern struct rgba color_white;
extern struct rgba color_black;
extern int renderMode;
extern HMM_Vec3 dirl_pos;
extern HMM_Mat4 projection;
extern HMM_Mat4 hudproj;
struct camera3d {
};
typedef struct camera3d camera3d;
struct draw_p {
float x;
float y;
};
#include <chipmunk/chipmunk.h>
enum RenderMode {
LIT,
UNLIT,
WIREFRAME,
DIRSHADOWMAP,
OBJECTPICKER
};
void render_init();
void openglRender(struct window *window);
void opengl_rendermode(enum RenderMode r);
void openglInit3d(struct window *window);
void openglRender3d(struct window *window, camera3d *camera);
void capture_screen(int x, int y, int w, int h, const char *path);
void render_winsize();
void debug_draw_phys(int draw);
void set_cam_body(cpBody *body);
cpVect cam_pos();
float cam_zoom();
void add_zoom(float val);
HMM_Vec2 world2screen(HMM_Vec2 pos);
HMM_Vec2 screen2world(HMM_Vec2 pos);
sg_shader sg_compile_shader(const char *v, const char *f, sg_shader_desc *d);
2023-09-12 00:02:57 -05:00
void gif_rec_start(int w, int h, int cpf, int bitdepth);
void gif_rec_end(const char *path);
2023-09-11 15:07:36 -05:00
2023-05-16 01:31:13 -05:00
struct uv_n {
unsigned short u;
unsigned short v;
};
struct st_n {
struct uv_n s;
struct uv_n t;
};
2023-05-24 20:45:50 -05:00
struct rgba {
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char a;
};
2023-05-30 13:07:18 -05:00
struct boundingbox {
float t;
float b;
float r;
float l;
};
2023-09-05 09:38:52 -05:00
struct rect {
float h, w, x, y;
};
/* Normalized S,T coordinates for rendering */
struct glrect {
float s0;
float s1;
float t0;
float t1;
2023-05-22 00:08:08 -05:00
};
struct boundingbox cwh2bb(HMM_Vec2 c, HMM_Vec2 wh);
float *rgba2floats(float *r, struct rgba c);
extern sg_blend_state blend_trans;
2022-02-06 10:14:57 -06:00
#endif