Fix gamma, add Glad, error if glad is compiled with emscripten
This commit is contained in:
2
Makefile
2
Makefile
@@ -1,6 +1,7 @@
|
|||||||
BIN = manigraph
|
BIN = manigraph
|
||||||
|
|
||||||
OBJ = \
|
OBJ = \
|
||||||
|
ext/glad/glad.o \
|
||||||
src/surface.o \
|
src/surface.o \
|
||||||
src/context.o \
|
src/context.o \
|
||||||
src/texture.o \
|
src/texture.o \
|
||||||
@@ -14,6 +15,7 @@ OBJ = \
|
|||||||
CFLAGS = \
|
CFLAGS = \
|
||||||
-I./ext/cglm/include \
|
-I./ext/cglm/include \
|
||||||
-I./ext/glfw/include \
|
-I./ext/glfw/include \
|
||||||
|
-I./ext/glad \
|
||||||
-Wall -Wno-unused-function -std=c99 -D_GNU_SOURCE \
|
-Wall -Wno-unused-function -std=c99 -D_GNU_SOURCE \
|
||||||
|
|
||||||
WAYLAND-LIB = \
|
WAYLAND-LIB = \
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#else
|
#else
|
||||||
#ifdef GLAD
|
#ifdef GLAD
|
||||||
#include <GLFW/glfw3.h>
|
|
||||||
#include <glad.h>
|
#include <glad.h>
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
#else
|
#else
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -14,7 +14,6 @@
|
|||||||
void set_clean_color_context(unsigned char r, unsigned char g, unsigned char b)
|
void set_clean_color_context(unsigned char r, unsigned char g, unsigned char b)
|
||||||
{
|
{
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
|
||||||
glClearColor((float)r / 0xff, (float)g / 0xff, (float)b / 0xff, 1.0);
|
glClearColor((float)r / 0xff, (float)g / 0xff, (float)b / 0xff, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,8 @@ const char * fs_plain =
|
|||||||
|
|
||||||
"void main()"
|
"void main()"
|
||||||
"{"
|
"{"
|
||||||
" FragColor = texture( palette, vec3( 0, 0, index ) ).rgba;"
|
" vec4 color = texture( palette, vec3(0,0,index)).rgba;"
|
||||||
|
" FragColor = vec4(pow(vec3(color),vec3(1.0/2.2)),color.a);"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
const char * fs =
|
const char * fs =
|
||||||
@@ -102,6 +103,6 @@ const char * fs =
|
|||||||
" float specular = pow(abs(dot(normalize(Normal), halfwayDir)), 32.0);\n"
|
" float specular = pow(abs(dot(normalize(Normal), halfwayDir)), 32.0);\n"
|
||||||
" float diffuse = abs(dot(normalize(Normal), lightDir));\n"
|
" float diffuse = abs(dot(normalize(Normal), lightDir));\n"
|
||||||
|
|
||||||
" vec3 result = (0.5 + 1.5*diffuse + 4*specular) * color.rgb;\n"
|
" vec3 result = pow((0.5 + 0.5*diffuse + 1.5*specular) * color.rgb, vec3(1.0/2.2));\n"
|
||||||
" FragColor = vec4(result, color.a)*1/2.2;\n"
|
" FragColor = vec4(result, color.a);\n"
|
||||||
"}";
|
"}";
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
float *generate_data_surface(unsigned int, unsigned char *);
|
float *generate_data_surface(unsigned int, unsigned char *);
|
||||||
float *generate_normals_surface(float *, unsigned char);
|
float *generate_normals_surface(float *, unsigned char);
|
||||||
|
|
||||||
struct projection projection = {.x = 3, .y=1, .z=2, .w=0 };
|
struct projection projection = {.x = 0, .y=1, .z=2, .w=3 };
|
||||||
|
|
||||||
const char *wname = "manigraph: manifold grapher";
|
const char *wname = "manigraph: manifold grapher";
|
||||||
|
|
||||||
@@ -65,6 +65,7 @@ void main_loop(void)
|
|||||||
|
|
||||||
load_uint_to_shader( shader, "i", animate_index-1 );
|
load_uint_to_shader( shader, "i", animate_index-1 );
|
||||||
load_uint_to_shader( shader_plain, "i", animate_index-1 );
|
load_uint_to_shader( shader_plain, "i", animate_index-1 );
|
||||||
|
|
||||||
load_float_to_shader( shader, "angle", angle);
|
load_float_to_shader( shader, "angle", angle);
|
||||||
load_float_to_shader( shader_plain, "angle", angle);
|
load_float_to_shader( shader_plain, "angle", angle);
|
||||||
}
|
}
|
||||||
@@ -117,7 +118,7 @@ int main(void)
|
|||||||
mlog("[CONTEXT] Error al inicializar...\n");
|
mlog("[CONTEXT] Error al inicializar...\n");
|
||||||
goto error_context;
|
goto error_context;
|
||||||
}
|
}
|
||||||
set_clean_color_context(0xFB, 0xEA, 0xEB);
|
set_clean_color_context(0xFF, 0xFF, 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
mlog("[TEXTURE] Inicializando...\n");
|
mlog("[TEXTURE] Inicializando...\n");
|
||||||
@@ -184,7 +185,8 @@ int main(void)
|
|||||||
|
|
||||||
mlog("[MAIN LOOP] Inicializando...\n");
|
mlog("[MAIN LOOP] Inicializando...\n");
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
emscripten_set_main_loop(&main_loop, 0, 1);
|
emscripten_set_main_loop(&main_loop, 60, 1);
|
||||||
|
return 0;
|
||||||
#else
|
#else
|
||||||
while (is_open_window(window))
|
while (is_open_window(window))
|
||||||
main_loop();
|
main_loop();
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* #define DEBUG */
|
/* #define DEBUG */
|
||||||
/* #define GLAD */
|
#define GLAD
|
||||||
|
|
||||||
typedef const void * window_t;
|
typedef const void * window_t;
|
||||||
typedef unsigned int id_t;
|
typedef unsigned int id_t;
|
||||||
@@ -154,3 +154,9 @@ void destroy_texture(id_t texture);
|
|||||||
id_t create_palette_texture(const unsigned char colors[][4], unsigned char n );
|
id_t create_palette_texture(const unsigned char colors[][4], unsigned char n );
|
||||||
|
|
||||||
quat_t poll_input(window_t window);
|
quat_t poll_input(window_t window);
|
||||||
|
|
||||||
|
#ifdef EMSCRIPTEN
|
||||||
|
#ifdef GLAD
|
||||||
|
#error undefine GLAD on src/main.h please
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user