Setup Manigraph for glad

This commit is contained in:
PedroEdiaz
2024-10-30 22:42:13 -06:00
parent 303f16d155
commit 88495c1068
9 changed files with 5178 additions and 7 deletions

View File

@@ -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); }

View File

@@ -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");

View File

@@ -4,7 +4,8 @@
error of the shaders.
*/
/* #define DEBUG */
/* #define DEBUG */
/* #define GLAD */
typedef const void * window_t;
typedef unsigned int id_t;

View File

@@ -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);
}

View File

@@ -1,5 +1,10 @@
#include "main.h"
#ifdef GLAD
#include <glad.h>
#else
#include <GL/glew.h>
#endif
#ifdef DEBUG
#include <stdio.h>

View File

@@ -1,5 +1,9 @@
#include "main.h"
#ifdef GLAD
#include <glad.h>
#else
#include <GL/glew.h>
#endif
#define TYPE GL_TEXTURE_2D_ARRAY