port back oldpos logic

This commit is contained in:
onezplpl 2024-07-14 12:01:38 -04:00
parent d112930c5c
commit d4b8c18708
No known key found for this signature in database
GPG key ID: 7EC026A136F9EEC3

12
main.c
View file

@ -175,6 +175,7 @@ int main(void) {
while (!glfwWindowShouldClose(window)) {
vec3 oldPos = {pos[0], pos[1], pos[2]};
glfwGetFramebufferSize(window, &width, &height);
const float ratio = width / (float)height;
@ -216,8 +217,12 @@ int main(void) {
mat4x4_mul(mvp, mvp, m);
glUniformMatrix4fv(mvp_location, 1, GL_FALSE, (const GLfloat *)&mvp);
int ax = (int)(oldPos[0] / CHUNK_LENGTH) - (int)(pos[0] / CHUNK_LENGTH);
int ay = (int)(oldPos[1] / CHUNK_LENGTH) - (int)(pos[1] / CHUNK_LENGTH);
int az = (int)(oldPos[2] / CHUNK_LENGTH) - (int)(pos[2] / CHUNK_LENGTH);
if (frames >= 8) {
if ((ax != 0 || ay != 0 || az != 0) && frames > 4.0) {
struct args args;
args.cube_count = &cube_count;
@ -229,6 +234,9 @@ int main(void) {
args.vertex_buffer = vertex_buffer;
args.is_render = &is_render;
if (thread_id != 0)
pthread_join(thread_id, NULL);
pthread_create(&(thread_id), NULL, render_chunks, (void *)&(args));
frames = 0;
@ -236,7 +244,7 @@ int main(void) {
}
frames = glfwGetTime();
//printf("%f\n", frames);
//Sprintf("%f\n", frames);
glfwSwapBuffers(window);
glfwPollEvents();