Merge: roberto -> main
This commit is contained in:
5
Makefile
5
Makefile
@@ -14,7 +14,7 @@ OBJ = \
|
||||
CFLAGS = \
|
||||
-I./ext/cglm/include \
|
||||
-I./ext/glfw/include \
|
||||
-Wall -Wno-unused-function -std=c99 -D_POSIX_C_SOURCE \
|
||||
-Wall -Wno-unused-function -std=c99 -D_GNU_SOURCE \
|
||||
|
||||
WAYLAND-LIB = \
|
||||
xdg-shell \
|
||||
@@ -48,6 +48,8 @@ windows: $(OBJ) glfw.dll
|
||||
glfw.dll:
|
||||
$(CC) -fPIC -shared -D_GLFW_WIN32 -D_GLFW_BUILD_DLL ./ext/glfw/src/*.c -o $@ -lgdi32
|
||||
|
||||
src/main.o: src/data/shaders.h src/data/axis.h
|
||||
|
||||
# LINUX
|
||||
linux-wayland: $(OBJ)
|
||||
for i in $(WAYLAND-LIB); \
|
||||
@@ -79,4 +81,5 @@ clean:
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
.c.o: src/main.h
|
||||
clang-format -i $<
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "main.h"
|
||||
#ifdef GLAD
|
||||
#include <glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <glad.h>
|
||||
#else
|
||||
#include <GL/glew.h>
|
||||
#endif
|
||||
@@ -19,9 +19,8 @@ int init_context(void)
|
||||
|
||||
return gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
|
||||
#else
|
||||
return glewInit() == GLEW_OK;
|
||||
return glewInit();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void clean_context(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); }
|
||||
|
||||
@@ -46,27 +46,32 @@ const char * fs_plain =
|
||||
" FragColor = texture( palette, vec3( 0, 0, index ) ).rgba;"
|
||||
"}";
|
||||
|
||||
|
||||
const char * fs =
|
||||
"#version 330 core\n"
|
||||
"#version 330 core\n"
|
||||
|
||||
"uniform sampler2DArray palette;"
|
||||
"uniform sampler2DArray palette;"
|
||||
|
||||
"in float index;"
|
||||
"out vec4 FragColor;"
|
||||
"in vec3 Normal;"
|
||||
"in vec3 FragPos;"
|
||||
"in float index;"
|
||||
"in vec3 Normal;"
|
||||
"in vec3 FragPos;"
|
||||
|
||||
"void main()"
|
||||
"{"
|
||||
"out vec4 FragColor;"
|
||||
|
||||
" vec4 color = texture( palette, vec3( 0, 0, index ) ).rgba;"
|
||||
" vec3 lightPos = vec3(0,0,-15);"
|
||||
" vec3 lightDir = normalize(lightPos - FragPos);"
|
||||
"void main()"
|
||||
"{"
|
||||
" vec4 color = texture(palette, vec3(0, 0, index));\n"
|
||||
|
||||
" float diffuse = abs(dot(Normal, lightDir)); "
|
||||
" vec3 viewPos = vec3(0, 0, -15);\n"
|
||||
" vec3 viewDir = normalize(viewPos - FragPos);\n"
|
||||
|
||||
" FragColor = (0.5 + 0.5*diffuse)*color;"
|
||||
"}";
|
||||
" vec3 lightPos = viewPos;\n"
|
||||
" vec3 lightDir = normalize(lightPos - FragPos);\n"
|
||||
|
||||
" vec3 halfwayDir = normalize(lightDir + viewDir);\n"
|
||||
|
||||
" float specular = pow(max(dot(normalize(Normal), halfwayDir), 0.0), 16.0);\n"
|
||||
" float diffuse = max(dot(normalize(Normal), lightDir), 0.0);\n"
|
||||
|
||||
" vec3 result = (0.5 + 0.5 * diffuse + specular) * color.rgb;\n"
|
||||
" FragColor = vec4(result, color.a);\n"
|
||||
"}";
|
||||
|
||||
0
src/main.c
Normal file → Executable file
0
src/main.c
Normal file → Executable file
@@ -68,8 +68,8 @@ mesh_t create_mesh(float *d, float *n, unsigned char m)
|
||||
{
|
||||
glGenBuffers(1, &p->n_vbo);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, p->n_vbo);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, p->vertex * m * sizeof(float), n + 1,
|
||||
GL_STATIC_DRAW);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, p->vertex * m * sizeof(float),
|
||||
n + 1, GL_STATIC_DRAW);
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; ++i)
|
||||
|
||||
Reference in New Issue
Block a user