Document code, and clean up
This commit is contained in:
96
src/main.h
96
src/main.h
@@ -1,5 +1,10 @@
|
||||
#include <GL/glew.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
/*
|
||||
If DEBUG is set, we show the triangles of the mesh,
|
||||
without illumination, and we write the compilation
|
||||
error of the shaders.
|
||||
*/
|
||||
|
||||
/* #define DEBUG */
|
||||
|
||||
typedef const void * window_t;
|
||||
typedef unsigned int id_t;
|
||||
@@ -7,12 +12,12 @@ typedef void * mesh_t;
|
||||
typedef float * quat_t;
|
||||
typedef float * mat4_t;
|
||||
|
||||
typedef unsigned char narray_u8_t[];
|
||||
|
||||
enum
|
||||
{
|
||||
VERTEX, FRAGMENT
|
||||
};
|
||||
/*
|
||||
Init window:
|
||||
w: default width;
|
||||
h: default height;
|
||||
name: Name of the window.
|
||||
*/
|
||||
|
||||
window_t init_window(unsigned int w, unsigned int h, const char * name);
|
||||
|
||||
@@ -22,32 +27,90 @@ int is_open_window(window_t window);
|
||||
|
||||
void close_window(window_t window);
|
||||
|
||||
/*
|
||||
Create mesh:
|
||||
d: array of floats with the vertex data.
|
||||
n: array of floats with the normal data.
|
||||
coordanate: the number of the 3 axis that we are displaying.
|
||||
*/
|
||||
|
||||
mesh_t create_mesh( float * d, float * n, unsigned char * coordanate );
|
||||
|
||||
void destroy_mesh(mesh_t p);
|
||||
|
||||
void draw_mesh(mesh_t p);
|
||||
|
||||
void set_clean_color_context(unsigned char, unsigned char, unsigned char);
|
||||
/*
|
||||
Set background color:
|
||||
r: red value in hex.
|
||||
g: green value in hex.
|
||||
b: blue value in hex.
|
||||
*/
|
||||
|
||||
void set_clean_color_context(unsigned char r, unsigned char g, unsigned char b);
|
||||
|
||||
void clean_context(void);
|
||||
|
||||
int init_context( void );
|
||||
|
||||
void destroy_shader(id_t shader);
|
||||
|
||||
id_t create_shader(void);
|
||||
|
||||
void use_shader(id_t program);
|
||||
void use_shader(id_t shader);
|
||||
|
||||
unsigned char gload_program(id_t program, const char * src, unsigned int type);
|
||||
enum
|
||||
{
|
||||
VERTEX, FRAGMENT
|
||||
};
|
||||
|
||||
void gload_float(id_t program, char * var, float f);
|
||||
/*
|
||||
Load program to shader:
|
||||
src: GLSL source code as string.
|
||||
type: VERTEX or FRAGMENT
|
||||
*/
|
||||
|
||||
void gload_mat4(id_t program, char * var, mat4_t m);
|
||||
unsigned char load_program_to_shader(id_t shader, const char * src, unsigned int type);
|
||||
|
||||
/*
|
||||
load float to shader:
|
||||
var: name of glsl variable.
|
||||
f: float to load
|
||||
*/
|
||||
|
||||
void load_float_to_shader(id_t shader, char * var, float f);
|
||||
|
||||
/*
|
||||
load matrix 4 to shader:
|
||||
var: name of glsl variable.
|
||||
m: Matrix to load
|
||||
*/
|
||||
|
||||
void load_mat4_to_shader(id_t shader, char * var, mat4_t m);
|
||||
|
||||
/*
|
||||
Generate and load fix matrix, this matrix
|
||||
has the information of the perspective and
|
||||
camera information.
|
||||
|
||||
ratio: default ratio of window.
|
||||
*/
|
||||
void load_fix_matrix(id_t shader, float ratio);
|
||||
|
||||
/*
|
||||
Generate and load model matrix, it also sets the color
|
||||
to draw.
|
||||
i: From {0,1,2} select one of 3 ortogonal rotations,
|
||||
One for each axis.
|
||||
c: Color index of the pallete.
|
||||
*/
|
||||
void load_mdl_matrix(id_t shader, unsigned char i, unsigned char c);
|
||||
|
||||
/*
|
||||
Generate and load rotation matrix.
|
||||
q: quaterinon describing the rotation.
|
||||
*/
|
||||
|
||||
void load_rot_matrix(id_t shader, quat_t q);
|
||||
|
||||
id_t config_texture(unsigned short type);
|
||||
@@ -56,6 +119,11 @@ void use_texture(id_t texture);
|
||||
|
||||
void destroy_texture(id_t texture);
|
||||
|
||||
id_t create_palette_texture(const narray_u8_t colors);
|
||||
/*
|
||||
Set color palette as texture:
|
||||
colors: array of color values (rgba in hex ).
|
||||
n: number of color on colors.
|
||||
*/
|
||||
id_t create_palette_texture(const unsigned char * colors, unsigned char n );
|
||||
|
||||
quat_t poll_input(window_t window);
|
||||
|
||||
Reference in New Issue
Block a user