Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Jumping/stuttering (probably lag)

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    2

    Jumping/stuttering (probably lag)

    I was previously using display lists to render, and am now using VBOs, and I'm getting the same problem.
    I'm getting some jumping, as in for a frame or two everything stutters/jumps to the side (generally in the direction of motion). I'm wondering if this is a lag problem, but it seems to have gotten worse since switching to VBOs, which is the opposite of what I was expecting.


    I'm also getting some horizontal lines. I'm drawing textures by using a 512px x 512px image divided into 16x16 tiles. I've tried to fix this by drawing 1.0f/16.001f of the texture instead of just 1.0f/16.0f, and this helps, but doesn't completely fix it. It looks like it's still drawing a little too much of the image (1 pixel to be exact) and in a long row of tiles this causes a very noticeable horizontal line.


    Does anyone have any idea what could be causing these issues?


    Thanks!

    Here is the code I'm using to render about 1000 polygons per frame. I'd like to eventually be able to draw many more, but I need to fix these issues first.
    Code :
    public void render(float scaleX, float scaleY, float scaleZ)
    {
        GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertex_buffer_id);
        GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertex_buffer_data, GL15.GL_STATIC_DRAW);
     
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, GameApplet.getTilesTexture().getTextureID());
     
        GL11.glVertexPointer(3, GL11.GL_FLOAT, 48, 0);
        GL11.glNormalPointer(GL11.GL_FLOAT, 48, 12);
        GL11.glColorPointer(4, GL11.GL_FLOAT, 48, 24);
        GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 48, 40);
     
        GL11.glScalef(scaleX, scaleY, scaleZ);
        GL11.glDrawArrays(GL11.GL_QUADS, 0, vertex_data_array.length / 12);
    }

  2. #2
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,169
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertex_buffer_data, GL15.GL_STATIC_DRAW);
    So you are uploading new data to the VBO each frame? Does the size of the data array change each frame or always the same?
    As for the texture issue - it sounds like your edges of the tiles are sampling the neighbours due to the bilinear filtering h/w. If you set the texture filtering to GL_NEAREST does the issue go away?

  3. #3
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,264
    If your VBO data is static, then don't call glBufferData.
    If it is dynamic, there are some tricks to get better performance
    http://www.opengl.org/wiki/VBO_-_more#Dynamic_VBO
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  4. #4
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    2
    Ah, ok thanks guys, that makes sense. I removed glBufferData call and unlimited the frame rate that got things from 104fps to 345fps. Looks very smooth at 60fps.
    Code :
    public void render(float scaleX, float scaleY, float scaleZ)
    {
        GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertex_buffer_id);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, GameApplet.getTilesTexture().getTextureID());
     
        GL11.glVertexPointer(3, GL11.GL_FLOAT, 48, 0);
        GL11.glNormalPointer(GL11.GL_FLOAT, 48, 12);
        GL11.glColorPointer(4, GL11.GL_FLOAT, 48, 24);
        GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 48, 40);
     
        GL11.glScalef(scaleX, scaleY, scaleZ);
        GL11.glDrawArrays(GL11.GL_QUADS, 0, vertex_data_array.length / 12);
    }

    As for the textures, I have them set like so:
    Code :
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);

    If I put them on linear, they look pretty bad, and have lines on all sides from their surrounding areas in the png. On nearest, it seems like only at certain distances from the camera they have black lines (so only one or two rows of tiles have black lines on their botton at a time, and only at a couple of distances).
    I was going to say it sounded like a rounding error, but I don't have any black lines on my texture png, so I'm not sure where it would be getting it from.

    --EDIT--
    Here is my test texture which is 512x512:
    Click image for larger version. 

Name:	post1.jpg 
Views:	37 
Size:	18.6 KB 
ID:	716
    Which is divided up into 16ths so each tile will have the texture:
    Name:  post2.png
Views: 59
Size:  186 Bytes
    And here is the result:
    Click image for larger version. 

Name:	post3.jpg 
Views:	43 
Size:	20.8 KB 
ID:	718

    --EDIT 2--
    Upon further investigation, this black line is actually the clear/background color showing through. That means that every once in a while the tiles are rendered as not touching. What can I do to fix this?
    Last edited by Brad811; 05-12-2012 at 10:04 PM. Reason: Added screenshots

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •