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)) {
|
||||
|
||||
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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue