whoops
This commit is contained in:
parent
8bca227b73
commit
9c0bd98918
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,3 +1,3 @@
|
|||
libgearlib.a
|
||||
*.a
|
||||
obj/
|
||||
test/*.exe
|
||||
examples/*.exe
|
||||
|
|
4
Makefile
4
Makefile
|
@ -5,7 +5,7 @@ AR=ar
|
|||
CFLAGS=-O3 -Iinclude -g
|
||||
LDFLAGS=-lglfw -lm
|
||||
|
||||
CFILES=$(shell cd src && mingw32-find -L * -type f -name '*.c')
|
||||
CFILES=$(shell cd src && find -L * -type f -name '*.c')
|
||||
OBJDIR=obj
|
||||
OBJ=$(addprefix $(OBJDIR)/, $(CFILES:.c=.o))
|
||||
|
||||
|
@ -22,4 +22,4 @@ run: $(LIBRARY)
|
|||
|
||||
clean:
|
||||
rm -rf $(OBJ) $(LIBRARY)
|
||||
make -C test clean
|
||||
make -C examples clean
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
CC=gcc
|
||||
|
||||
CFLAGS=-O3 -I../include
|
||||
LDFLAGS=C:\msys64\ucrt64\lib\libglfw3.a -L ../ -lgdi32 -lgearlib -lm
|
||||
CFLAGS = -O3 -I../include
|
||||
LDFLAGS = -L ../ -lglfw -lgearlib -lm
|
||||
|
||||
CFILES=$(shell mingw32-find -L * -type f -name '*.c')
|
||||
CFILES=$(shell find -L * -type f -name '*.c')
|
||||
BINARIES=$(CFILES:.c=)
|
||||
|
||||
all: $(BINARIES)
|
||||
|
|
BIN
examples/test
BIN
examples/test
Binary file not shown.
|
@ -11,6 +11,8 @@ int main() {
|
|||
|
||||
Texture cat = load_texture("assets/cat.png");
|
||||
|
||||
double time = glfwGetTime();
|
||||
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
process_input(window);
|
||||
update_camera(camera, window);
|
||||
|
@ -25,6 +27,13 @@ int main() {
|
|||
|
||||
flush();
|
||||
|
||||
double end_time = glfwGetTime();
|
||||
double frame_time = end_time - time;
|
||||
time = end_time;
|
||||
|
||||
double fps = 1.0 / frame_time;
|
||||
printf("frame_time: %lf fps: %lf\n", frame_time, fps);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -10,18 +10,27 @@ int main() {
|
|||
|
||||
Texture cat = load_texture("assets/cat.png");
|
||||
|
||||
double time = glfwGetTime();
|
||||
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
process_input(window);
|
||||
update_camera(camera, window);
|
||||
set_uniform_data(camera_buffer, camera->m);
|
||||
|
||||
glClearColor(vec4_spread(BLACK));
|
||||
glClearColor(vec4_spread(BLUE));
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
draw_texture(cat, vec2(250.0f, 250.0f), vec2(500.0f, 500.0f), WHITE);
|
||||
|
||||
flush();
|
||||
|
||||
double end_time = glfwGetTime();
|
||||
double frame_time = end_time - time;
|
||||
time = end_time;
|
||||
|
||||
double fps = 1.0 / frame_time;
|
||||
printf("frame_time: %lf fps: %lf\n", frame_time, fps);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
|
BIN
src/.textures.c.swp
Normal file
BIN
src/.textures.c.swp
Normal file
Binary file not shown.
|
@ -18,20 +18,30 @@ uint32_t load_texture(const char* path) {
|
|||
uint32_t id;
|
||||
glCreateTextures(GL_TEXTURE_2D, 1, &id);
|
||||
|
||||
glTextureParameteri(id, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTextureParameteri(id, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTextureParameteri(id, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTextureParameteri(id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
uint8_t default_texture[] = {
|
||||
0, 0, 0, 255, 255, 0, 255, 255,
|
||||
255, 0, 255, 255, 0, 0, 0, 255 };
|
||||
|
||||
int width, height, channels;
|
||||
unsigned char* pixels = stbi_load(path, &width, &height, &channels, 4);
|
||||
int width = 2, height = 2, channels;
|
||||
uint8_t* pixels = stbi_load(path, &width, &height, &channels, 4);
|
||||
if(pixels) {
|
||||
glTextureParameteri(id, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTextureParameteri(id, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTextureParameteri(id, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTextureParameteri(id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
glTextureStorage2D(id, 1, GL_RGBA8, width, height);
|
||||
glTextureSubImage2D(id, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
|
||||
printf("[Texture %d, %s] Loaded successfully (%dx%d, %d channels)\n", id, path, width, height, channels);
|
||||
} else {
|
||||
glTextureParameteri(id, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTextureParameteri(id, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTextureParameteri(id, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTextureParameteri(id, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
glTextureStorage2D(id, 1, GL_RGBA8, width, height);
|
||||
glTextureSubImage2D(id, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, default_texture);
|
||||
printf("[Texture %d, %s] Failed to load image data: %s\n", id, path, stbi_failure_reason());
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
return id;
|
||||
|
|
Loading…
Reference in a new issue