Setup Manigraph for glad
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
#include "main.h"
|
||||
#ifdef GLAD
|
||||
#include <glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#else
|
||||
#include <GL/glew.h>
|
||||
#endif
|
||||
|
||||
void set_clean_color_context(unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
@@ -8,6 +13,15 @@ void set_clean_color_context(unsigned char r, unsigned char g, unsigned char b)
|
||||
glClearColor((float)r / 0xff, (float)g / 0xff, (float)b / 0xff, 1.0);
|
||||
}
|
||||
|
||||
int init_context(void) { return glewInit() == GLEW_OK; }
|
||||
int init_context(void)
|
||||
{
|
||||
#ifdef GLAD
|
||||
|
||||
return gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
|
||||
#else
|
||||
return glewInit() == GLEW_OK;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void clean_context(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); }
|
||||
|
||||
@@ -44,7 +44,6 @@ int main(void)
|
||||
}
|
||||
|
||||
use_window(window);
|
||||
set_clean_color_context(0x2E, 0x07, 0x3F);
|
||||
}
|
||||
|
||||
mlog("[CONTEXT] Inicializando...\n");
|
||||
@@ -54,6 +53,7 @@ int main(void)
|
||||
mlog("[CONTEXT] Error al inicializar...\n");
|
||||
goto error_context;
|
||||
}
|
||||
set_clean_color_context(0x2E, 0x07, 0x3F);
|
||||
}
|
||||
|
||||
mlog("[TEXTURE] Inicializando...\n");
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
error of the shaders.
|
||||
*/
|
||||
|
||||
/* #define DEBUG */
|
||||
/* #define DEBUG */
|
||||
/* #define GLAD */
|
||||
|
||||
typedef const void * window_t;
|
||||
typedef unsigned int id_t;
|
||||
|
||||
12
src/mesh.c
12
src/mesh.c
@@ -1,5 +1,9 @@
|
||||
#include "main.h"
|
||||
#ifdef GLAD
|
||||
#include <glad.h>
|
||||
#else
|
||||
#include <GL/glew.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -25,7 +29,7 @@ void set_projection_mesh(struct projection projection)
|
||||
glVertexAttribPointer(3, 1, GL_FLOAT, 0, projection.m * sizeof(float),
|
||||
(float *)(projection.w * sizeof(float)));
|
||||
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, p->n_vbo);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, p->n_vbo);
|
||||
glVertexAttribPointer(4, 1, GL_FLOAT, 0, projection.m * sizeof(float),
|
||||
(float *)(projection.x * sizeof(float)));
|
||||
glVertexAttribPointer(5, 1, GL_FLOAT, 0, projection.m * sizeof(float),
|
||||
@@ -37,7 +41,7 @@ void set_projection_mesh(struct projection projection)
|
||||
}
|
||||
|
||||
/*
|
||||
In this function we load all the vertex and normal datas on two
|
||||
In this function we load all the vertex and ELEMENT_ARRAY datas on two
|
||||
diferents buffers, so we can access the coordanates that we want
|
||||
to display using the layout location in GLSL.
|
||||
This trick can be done with glVertexAttribPointer.
|
||||
@@ -63,8 +67,8 @@ mesh_t create_mesh(float *d, float *n, unsigned char m)
|
||||
if (n)
|
||||
{
|
||||
glGenBuffers(1, &p->n_vbo);
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, p->n_vbo);
|
||||
glBufferData(GL_UNIFORM_BUFFER, p->vertex * m * sizeof(float), n + 1,
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, p->n_vbo);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, p->vertex * m * sizeof(float), n + 1,
|
||||
GL_STATIC_DRAW);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
#include "main.h"
|
||||
|
||||
#ifdef GLAD
|
||||
#include <glad.h>
|
||||
#else
|
||||
#include <GL/glew.h>
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#include "main.h"
|
||||
#ifdef GLAD
|
||||
#include <glad.h>
|
||||
#else
|
||||
#include <GL/glew.h>
|
||||
#endif
|
||||
|
||||
#define TYPE GL_TEXTURE_2D_ARRAY
|
||||
|
||||
|
||||
Reference in New Issue
Block a user