polyadvent

A game engine from scratch in C
git clone git://jb55.com/polyadvent
Log | Files | Refs | README

render.h (1173B)


      1 #ifndef POLYADVENT_RENDER_H
      2 #define POLYADVENT_RENDER_H
      3 
      4 #include "geometry.h"
      5 #include "node.h"
      6 #include "mat4.h"
      7 #include "util.h"
      8 
      9 struct render_config {
     10     int draw_ui;
     11     int is_depth_pass;
     12     struct node_id camera;
     13     float* projection;
     14     float* depth_vp;
     15 };
     16 
     17 void init_gl();
     18 void recalc_normals(GLint nm_uniform, mat4 *model_view, mat4 *normal);
     19 
     20 void wireframe_mode_on();
     21 void wireframe_mode_off();
     22 
     23 static inline void uniform_3f(struct gpu_program *program,
     24                               int id, const float *v3)
     25 {
     26     glUniform3f(program->uniforms[id].location, v3[0], v3[1], v3[2]);
     27     check_gl();
     28 }
     29 
     30 static inline void uniform_1i(struct gpu_program *program, int id, int i)
     31 {
     32     glUniform1i(program->uniforms[id].location, i);
     33     check_gl();
     34 }
     35 
     36 static inline void uniform_m4f(struct gpu_program *program,
     37                                int id, float *m)
     38 {
     39     glUniformMatrix4fv(program->uniforms[id].location, 1, 0, m);
     40     check_gl();
     41 }
     42 
     43 static inline void uniform_1f(struct gpu_program *program,
     44                               int id, float f)
     45 {
     46     glUniform1f(program->uniforms[id].location, f);
     47     check_gl();
     48 }
     49 
     50 #endif /* POLYADVENT_RENDER_H */