port back oldpos logic
This commit is contained in:
parent
d112930c5c
commit
d4b8c18708
1 changed files with 10 additions and 2 deletions
12
main.c
12
main.c
|
@ -175,6 +175,7 @@ int main(void) {
|
||||||
|
|
||||||
while (!glfwWindowShouldClose(window)) {
|
while (!glfwWindowShouldClose(window)) {
|
||||||
|
|
||||||
|
vec3 oldPos = {pos[0], pos[1], pos[2]};
|
||||||
glfwGetFramebufferSize(window, &width, &height);
|
glfwGetFramebufferSize(window, &width, &height);
|
||||||
const float ratio = width / (float)height;
|
const float ratio = width / (float)height;
|
||||||
|
|
||||||
|
@ -217,7 +218,11 @@ int main(void) {
|
||||||
|
|
||||||
glUniformMatrix4fv(mvp_location, 1, GL_FALSE, (const GLfloat *)&mvp);
|
glUniformMatrix4fv(mvp_location, 1, GL_FALSE, (const GLfloat *)&mvp);
|
||||||
|
|
||||||
if (frames >= 8) {
|
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 ((ax != 0 || ay != 0 || az != 0) && frames > 4.0) {
|
||||||
struct args args;
|
struct args args;
|
||||||
args.cube_count = &cube_count;
|
args.cube_count = &cube_count;
|
||||||
|
|
||||||
|
@ -229,6 +234,9 @@ int main(void) {
|
||||||
args.vertex_buffer = vertex_buffer;
|
args.vertex_buffer = vertex_buffer;
|
||||||
args.is_render = &is_render;
|
args.is_render = &is_render;
|
||||||
|
|
||||||
|
if (thread_id != 0)
|
||||||
|
pthread_join(thread_id, NULL);
|
||||||
|
|
||||||
pthread_create(&(thread_id), NULL, render_chunks, (void *)&(args));
|
pthread_create(&(thread_id), NULL, render_chunks, (void *)&(args));
|
||||||
|
|
||||||
frames = 0;
|
frames = 0;
|
||||||
|
@ -236,7 +244,7 @@ int main(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
frames = glfwGetTime();
|
frames = glfwGetTime();
|
||||||
//printf("%f\n", frames);
|
//Sprintf("%f\n", frames);
|
||||||
|
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue