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: Same OpenGl code - three different behaviours on three different machines.

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2012
    Posts
    9

    Same OpenGl code - three different behaviours on three different machines.

    I have a program that I wrote that is behaving completely differently on all three of my test machines.
    The behaviour is coming from gldrawelements(). On my crappy work laptop (with an Intel graphics chipset) everything draws perfectly. It provides opengl 3.0. On my desktop at home with an ATI Radeon HD 5770 I get a machine exception when it hits the gldrawelements function. This machine runs Opengl 4.2. Finally, my crappy Lenovo laptop with a ATI Radeon Mobility chipset runs the program but doesn't display anything drawn with gldrawelements but doesn't crash. This is the same binary on three different computers. Making the situation more bizarre is that all three machines work perfectly with glDrawArrays. The only thing I can think of is the opengl version each is using? Why does the crappy intel chipset work perfectly? I am running WinXp on my work laptop, vista on my desktop, and win7 on my personal laptop. All have updated drivers.

    I have attached the precompiled code below, its in Euphoria so I am not sure how much help it will be. Also, if my code was bad, why does it work perfectly on my work laptop?

    I have a compiled OpenGL program with the following EU code. The entire codebase is way too large to post. I can provide a binary if anyone thinks it will help.
    vbo creation:
    ----------------------------
    Code :
    gl_genBuffers(1, vboverts)
    gl_bindBuffer(GL_ARRAY_BUFFER, peek4u(vboverts))
    gl_bufferData(GL_ARRAY_BUFFER, length(Verts)*4, VertsArray, GL_STATIC_DRAW)
    gl_bindBuffer(GL_ARRAY_BUFFER, 0)
     
    gl_genBuffers(1, vbotxt)
    gl_bindBuffer(GL_ARRAY_BUFFER, peek4u(vbotxt))
    gl_bufferData(GL_ARRAY_BUFFER, length(Txtr)*4, TextArray, GL_STATIC_DRAW)
    gl_bindBuffer(GL_ARRAY_BUFFER, 0)	
     
    gl_genBuffers(1, vbonorms)
    gl_bindBuffer(GL_ARRAY_BUFFER, peek4u(vbonorms))
    gl_bufferData(GL_ARRAY_BUFFER, length(Norms)*4, NormArray, GL_STATIC_DRAW)
    gl_bindBuffer(GL_ARRAY_BUFFER, 0)
     
    gl_genBuffers(1, iboidx)
    gl_bindBuffer(GL_ELEMENT_ARRAY_BUFFER, peek4u(iboidx))
    gl_bufferData(GL_ELEMENT_ARRAY_BUFFER, length(Shapes)*2, IdxArray, GL_STATIC_DRAW)
    gl_bindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)


    Render:
    ----------------------------
    Code :
    gl_enable(GL_BLEND)		
    gl_useProgram(glprogs[2][1])
    gl_activeTexture(GL_TEXTURE0)		
    gl_bindTexture(GL_TEXTURE_2D, peek4u(texture_mem + ( ( n_3dx[4][glcmds[$]]-1 ) * 4 ) ) )  
    gl_uniform1i(glprogs[2][3][4], 0)
     
    gl_uniform1i(glprogs[2][3][5], shade)
     
    gl_uniformMatrix4fv(glprogs[2][3][1], 1, GL_FALSE, CoreMatrix)		-- push model matrix
    gl_uniformMatrix4fv(glprogs[2][3][2], 1, GL_FALSE, xCamera[7] )		-- push view matrix	
    gl_uniformMatrix4fv(glprogs[2][3][3], 1, GL_FALSE, PerspectiveMatrixArray )	-- push perspective matrix
     
    gl_enableVertexAttribArray(0)				-- coord3d
    gl_bindBuffer(GL_ARRAY_BUFFER, peek4u(n_3dx[6][1]))
    gl_vertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0)	
     
    gl_enableVertexAttribArray(1)				-- textcoords
    gl_bindBuffer(GL_ARRAY_BUFFER, peek4u(n_3dx[6][2]))
    gl_vertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, 0)	
     
    gl_bindBuffer(GL_ELEMENT_ARRAY_BUFFER, n_3dx[6][3])
    gl_drawRangeElements(GL_TRIANGLES, 0, n_3dx[6][5], n_3dx[6][5], GL_UNSIGNED_SHORT, n_3dx[6][4])		
    errCode = gl_getError()
     
    if errCode > 0 then
    	writetofile(sprintf("\nRender code %d thrown!   %d\n", {errCode, rendnum}), ZA_LOG)
    end if
     
    gl_disableVertexAttribArray(0)
    gl_disableVertexAttribArray(1)	
     
    cntp += 1
     
    gl_disable(GL_BLEND)


    Thanks for any help!
    Steve A.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,106
    The first thing I would do is put ina few more glError calls. Also check you shader code. There may be something that is wrong that is forcing different code for each version.

  3. #3
    Newbie Newbie
    Join Date
    Nov 2012
    Posts
    3
    In gl_DrawRangeElements, you appear to be overrunning the length of your array. Your third argument, for 'end', should be one less than your fourth argument, for 'count'.

  4. #4
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,264
    >>gl_drawRangeElements(GL_TRIANGLES, 0, n_3dx[6][5], n_3dx[6][5], GL_UNSIGNED_SHORT, n_3dx[6][4])

    The code looks convoluted. I agree with Steven McGrath. Your call to
    glDrawRangeElements looks bad.
    Your start and end values are the same. If you are rendering vertices 0, 1, 2, 3
    then your values need to be 0 and 3.


    Also, the last parameter, n_3dx[6][4], I hope it contains 0.

    You might want to use a debugger like glIntercept. Works on Windows.
    http://www.opengl.org/wiki/Debugging_Tools
    ------------------------------
    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);

Posting Permissions

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