|
@@ -1,50 +1,17 @@
|
|
|
|
|
|
#include "renderer.h"
|
|
#include "renderer.h"
|
|
|
|
+#include "fio.h"
|
|
|
|
+
|
|
#include <linmath.h>
|
|
#include <linmath.h>
|
|
|
|
|
|
#include <glad/glad.h>
|
|
#include <glad/glad.h>
|
|
-#include <inttypes.h>
|
|
|
|
#include <assert.h>
|
|
#include <assert.h>
|
|
#include <stdio.h>
|
|
#include <stdio.h>
|
|
#include <stdbool.h>
|
|
#include <stdbool.h>
|
|
#include <stdlib.h>
|
|
#include <stdlib.h>
|
|
-#include <io.h>
|
|
|
|
-#include <sys/stat.h>
|
|
|
|
#include <GLFW/glfw3.h>
|
|
#include <GLFW/glfw3.h>
|
|
|
|
|
|
|
|
|
|
-void read_shader_source(GLchar* source, const char* file_path) {
|
|
|
|
-
|
|
|
|
- GLchar buf[1024] = { 0 };
|
|
|
|
- errno_t err = 0;
|
|
|
|
- struct _stat st;
|
|
|
|
- int result = 0;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if (_access(file_path, 4) == -1) {
|
|
|
|
- fprintf(stderr, "file not found %s\n", file_path);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- FILE* f = NULL;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- err = fopen_s(&f, file_path, "r");
|
|
|
|
- if (err != 0) {
|
|
|
|
- fprintf(stderr, "could not open file %s\n", file_path);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- result = _stat(file_path, &st);
|
|
|
|
- assert(result == 0 && "could not stat file");
|
|
|
|
- assert(st.st_size <= 1024 && "shader source too long");
|
|
|
|
-
|
|
|
|
- fread(buf, st.st_size, 1, f);
|
|
|
|
- assert(buf[0] != 0);
|
|
|
|
-
|
|
|
|
- strcpy_s(source, 1024, buf);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
|
|
|
|
void renderer_init_nk(Renderer* renderer) {
|
|
void renderer_init_nk(Renderer* renderer) {
|
|
#if 0
|
|
#if 0
|
|
@@ -196,13 +163,16 @@ void render_quad(Renderer* renderer, vec2 pos, vec2 size, vec4 color)
|
|
|
|
|
|
glBindVertexArray(0);
|
|
glBindVertexArray(0);
|
|
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void renderer_destroy(Renderer* renderer) {
|
|
void renderer_destroy(Renderer* renderer) {
|
|
- //glDeleteTextures(1, &renderer->font_tex);
|
|
|
|
|
|
+
|
|
|
|
+ glDeleteTextures(1, &renderer->texture_color);
|
|
glDeleteBuffers(1, &renderer->vbo);
|
|
glDeleteBuffers(1, &renderer->vbo);
|
|
|
|
+ glDeleteBuffers(1, &renderer->ebo);
|
|
glDeleteProgram(renderer->programs[0]);
|
|
glDeleteProgram(renderer->programs[0]);
|
|
|
|
+
|
|
|
|
+ glfwTerminate();
|
|
//nk_buffer_free(&renderer->cmds);
|
|
//nk_buffer_free(&renderer->cmds);
|
|
}
|
|
}
|
|
|
|
|