Jump to content
  • Advertisement

Sharlock93

Member
  • Content Count

    12
  • Joined

  • Last visited

Community Reputation

114 Neutral

About Sharlock93

  • Rank
    Member

Personal Information

  • Interests
    |programmer|
  1. I have a program called f.lux that is used for night time and changes the color of your screen, after disabling that, the examples of glfw ran smoothly, which is very very weird.   This is exactly what I meant by 'it sounds like something is periodically interrupting your PC, such as a bad wireless driver or similar.' :) F.lux has to make calls to the graphics drivers to change the colour temperature of the screen, and that seems to involve quite a slow low-level process that interrupts absolutely everything. I had this exact problem with audio software, and getting periodic dropouts from the audio when f.lux was changing to night mode. They allude to potential problems with mouse stuttering or computer slowdowns on the f.lux FAQ, but there is no real solution. (They suggest updating video drivers, but that doesn't work in the general case.)   The problem happens maybe because I have two graphics card, the internal Intel one and one by nvidia in my laptop, because I tested the same program and examples on a friends computer, and nothing was wrong there, which leads me to believe there is a problem on how they handle multiple graphics cards or something, but that is just a guess. The problem was f.lux, the software was interrupting the update of graphics every second.
  2. Yeah, the article mentions that, so I should probably interpolate between the frames too.
  3. So after removing f.lux, everything is smooth as a baby's butt, I wonder why would f.lux cause this? the staggering and the jump happens every second, like on each "second" boundary, maybe I should report this to the f.lux people.
  4.   That is what glfw would use most likely, but I don't know, I'm still gonna test to see if not using f.lux would fix my problem first, I'm try to clean up my code a bit.
  5. I posted the same question to reddit, and someone mentioned i should test the examples that come with glfw, after testing them, it looks like those examples also had the same problem, after looking into it, like Lactose the problem happened every one second, I have a program called f.lux that is used for night time and changes the color of your screen, after disabling that, the examples of glfw ran smoothly, which is very very weird.   Here are two videos I made of the examples: with f.lux:     without f.lux:  
  6. Yeah, this fucks with my head, I have even removed all the timing calculations, just straight up set dt to 1.0/60.0 and turn Vsync on, I honestly don't know what is happening.
  7. I'm certain there is something wrong with my timing calculation, should I post the entire code to github?
  8. That framerate is related with the nVidia Overlay, even if I turn it off the problem still happens.
  9.   Yeah Vsync doesn't solve anything, and shatranslate is just a making a translation matrix. just my own implementation. //translation mat4 shatranslate(float x, float y, float z) { return mat4(1.0, 0.0, 0.0, x, 0.0, 1.0, 0.0, y, 0.0, 0.0, 1.0, z, 0.0, 0.0, 0.0, 1.0 ); }   vec2 is floats, and I have already seen and implemented that article, I was using a fixed timestep, and thought it might be the problem, so I went back to the more simpler and less complex variable timestep.
  10.   the code I posted is literally everything that happens, its the data creation, the update and rendering all in the same place, and that is my main loop, the problem still happens even with that code.
  11. because the ball class is too fucked and contains too much, I took out the important parts of it and still the problem existed, here is the code: vec2 data[32]; GLuint vbo; mat4 transforms; vec2 pos(-250,-250); float velocity = 20; int main(int argc, char ** argv) { glfwSetTime(0); double total_time = 0; double current_time = glfwGetTime(); double previous_time = current_time; glfwSwapInterval(0); pos = vec2(0, 0); float step = 360.0/CIRCLE_SEGMENTS; for(int i = 0; i < CIRCLE_SEGMENTS; i++) { data[i] = vec2( (float)( 15*cos(i*step*torad) + pos.x ),(float) ( 15*sin(i*step*torad) + pos.y)); } glGenBuffers(1, &vbo); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_DYNAMIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); transforms = mat4(1); while(run) { current_time = glfwGetTime(); vec2 diff = velocity*(current_time - previous_time)*vec2(1, 1); pos = pos + diff; transforms = shatranslate(diff.x, diff.y, 0)*transforms; glUniformMatrix4fv(3, 1, GL_TRUE, &transforms[0][0]); previous_time = current_time; if((glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)) { run = false; glfwSetWindowShouldClose(window, true); } glClear(GL_COLOR_BUFFER_BIT); glBindBuffer(GL_ARRAY_BUFFER, vbo); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0); glDrawArrays(GL_TRIANGLE_FAN, 0, 32); glfwSwapBuffers(window); glfwPollEvents(); } glfwDestroyWindow(window); return 0; } Thank you for taking time to answer.
  12. This has me stumped for quiet sometime now that I don't know what to do anymore with it.   So basically I have a ball that just moves from one side of the screen to the other, and even though the game is running upwards of 100+ FPS, I still see the the ball jump or stagger around when it moves, as if its skipping frames or something, and I don't know where the problem is, and its just killing my mood :(   Here is a video of the thing:       and here is the relevant code: int main(int argc, char ** argv) { //snip some code glfwSetTime(0); double total_time = 0; double current_time = glfwGetTime(); double previous_time = current_time; glfwSwapInterval(0); while(run) { current_time = glfwGetTime(); gamestate.update(&gamestate, &mouse_st, current_time - previous_time); previous_time = current_time; if(!gamestate.is_init) { gamestate.init(&gamestate); gamestate.is_init = 1; } if((glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)) { run = false; glfwSetWindowShouldClose(window, true); } glClear(GL_COLOR_BUFFER_BIT); gamestate.render(&gamestate); glfwSwapBuffers(window); glfwPollEvents(); } glfwDestroyWindow(window); return 0; }   and here is what what update and render functions do: void render(game_state *gamestate) { //Render Function int vpos = gamestate->vpos_attrib_loc; int color = gamestate->color_attrib_loc; int model = gamestate->model_t_attrib_loc; start_node = gamestate->named_objects; for(int i = 0; i < gamestate->object_count; ++i) { switch(start_node->type) { case BALL: { ball_object *ball = (ball_object *) start_node->obj; ball->circ.render(vpos, color, model); } break; //snip code } start_node++; } } ////////////////////////////Update Fucntion////////////////////////// void update(game_state *gamestate, mouse_state *mouse, double dt) { start_node = gamestate->named_objects; for(int i = 0; i < gamestate->object_count; ++i) { switch(start_node->type) { case BALL: { ball_object *ball = (ball_object *) start_node->obj; ball->circ.move_position((float)( ball->velocity*dt )); if(ball->circ.get_position().y < -gamestate->window_width_height.y/2.0) ball->circ._direction.y = 1; if(ball->circ.get_position().y > gamestate->window_width_height.y/2.0) ball->circ._direction.y = -1; if(ball->circ.get_position().x < -gamestate->window_width_height.x/2.0) ball->circ._direction.x = 1; if(ball->circ.get_position().x > gamestate->window_width_height.x/2.0) ball->circ._direction.x = -1; } break; } start_node++; } }
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!