cleanup
This commit is contained in:
parent
c4181e5c42
commit
678db8574f
6 changed files with 125 additions and 116 deletions
51
main.c
51
main.c
|
@ -1,21 +1,19 @@
|
|||
#include <math.h>
|
||||
#define GLAD_GL_IMPLEMENTATION
|
||||
#include "gl.h"
|
||||
#define GLFW_INCLUDE_NONE
|
||||
#include <GLFW/glfw3.h>
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
#define GLFW_INCLUDE_NONE
|
||||
#define GLAD_GL_IMPLEMENTATION
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <math.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "const.h"
|
||||
#include "cubes.h"
|
||||
#include "linmath.h"
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "cubes.h"
|
||||
#include "gen.h"
|
||||
#include "gl.h"
|
||||
#include "linmath.h"
|
||||
#include "stb_image.h"
|
||||
|
||||
static const char *vertex_shader_text =
|
||||
"#version 330\n"
|
||||
|
@ -78,10 +76,10 @@ static void cursor_position_callback(GLFWwindow *window, double x, double y) {
|
|||
|
||||
struct args {
|
||||
int *cube_count;
|
||||
Vertex **cube;
|
||||
Vertex **text;
|
||||
Vertex **cubeO;
|
||||
Vertex **textO;
|
||||
struct v3f **cube;
|
||||
struct v3f **text;
|
||||
struct v3f **cubeO;
|
||||
struct v3f **textO;
|
||||
vec3 pos;
|
||||
GLuint *vertex_buffer;
|
||||
int *is_render;
|
||||
|
@ -128,10 +126,10 @@ int main(void) {
|
|||
gladLoadGL(glfwGetProcAddress);
|
||||
glfwSwapInterval(1);
|
||||
|
||||
Vertex *cube = malloc(CTRI_ALL);
|
||||
Vertex *text = malloc(CTRI_ALL);
|
||||
Vertex *cubeO = malloc(CTRI_ALL);
|
||||
Vertex *textO = malloc(CTRI_ALL);
|
||||
struct v3f *cube = malloc(CTRI_ALL);
|
||||
struct v3f *text = malloc(CTRI_ALL);
|
||||
struct v3f *cubeO = malloc(CTRI_ALL);
|
||||
struct v3f *textO = malloc(CTRI_ALL);
|
||||
int bleh = (CHUNK_DIAMETER_H) * (CHUNK_DIAMETER_V);
|
||||
int *i2 = calloc(bleh, sizeof(int));
|
||||
|
||||
|
@ -148,12 +146,14 @@ int main(void) {
|
|||
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer[1]);
|
||||
glBufferData(GL_ARRAY_BUFFER, CTRI_ALL, text, GL_STATIC_DRAW);
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void *)0);
|
||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(struct v3f),
|
||||
(void *)0);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer[0]);
|
||||
glBufferData(GL_ARRAY_BUFFER, CTRI_ALL, cube, GL_STATIC_DRAW);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void *)0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(struct v3f),
|
||||
(void *)0);
|
||||
|
||||
GLuint vertex_shader = glCreateShader(GL_VERTEX_SHADER);
|
||||
glShaderSource(vertex_shader, 1, &vertex_shader_text, NULL);
|
||||
|
@ -186,7 +186,7 @@ int main(void) {
|
|||
|
||||
vec3 pos = {10240, 48, 10240};
|
||||
vec3 oldPos = {0, 0, 0};
|
||||
Chunk ch7;
|
||||
struct chunk ch7;
|
||||
ch7.exists = 0;
|
||||
int state = cube_exists(pos[0], pos[1], pos[2], ch7, 0);
|
||||
|
||||
|
@ -288,11 +288,11 @@ int main(void) {
|
|||
|
||||
if (is_render == 2) {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer[1]);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, (long)cube_count * sizeof(Vertex),
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, (long)cube_count * sizeof(struct v3f),
|
||||
textO); // text);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer[0]);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, (long)cube_count * sizeof(Vertex),
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, (long)cube_count * sizeof(struct v3f),
|
||||
cubeO); // cube);
|
||||
if (thread_id != 0)
|
||||
pthread_join(thread_id, NULL);
|
||||
|
@ -326,6 +326,11 @@ int main(void) {
|
|||
|
||||
free(cube);
|
||||
free(text);
|
||||
free(cubeO);
|
||||
free(textO);
|
||||
free(i2);
|
||||
free_chunks();
|
||||
free_chunks_old();
|
||||
|
||||
glfwDestroyWindow(window);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue