Jump to content
  • Advertisement
Sign in to follow this  
fazekaim

OpenGL code problem with vbo + opengl shader language

This topic is 5080 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! My code doesn't work, and I don't know why. Probably, I oversight an important mistake. Can anyone help me? Thanks. My water render cycle::
if(needcreateNames){
int[] temp = CreationFactory.createInt1DArray( 3 );
        gl.glGenBuffersARB( 3, temp );

        gl.glBindBufferARB( GL.GL_ARRAY_BUFFER_ARB, waterNames[actualTerrain] = temp[0] );
        gl.glBufferDataARB( GL.GL_ARRAY_BUFFER_ARB, stepLimits[ actualTerrain ] * stepLimits[ actualTerrain ] * 3 * vertexCount * BufferUtils.SIZEOF_FLOAT, waterBuffer[actualTerrain], GL.GL_DYNAMIC_DRAW_ARB );
        gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, 0);

        gl.glBindBufferARB( GL.GL_ARRAY_BUFFER_ARB, waterNormalNames[actualTerrain] = temp[1] );
        gl.glBufferDataARB( GL.GL_ARRAY_BUFFER_ARB, stepLimits[ actualTerrain ] * stepLimits[ actualTerrain ] * vertexCount * BufferUtils.SIZEOF_FLOAT, waterNormalBuffer[actualTerrain], GL.GL_DYNAMIC_DRAW_ARB );
        gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, 0);

        gl.glBindBufferARB( GL.GL_ARRAY_BUFFER_ARB, waterDistanceNames[actualTerrain] = temp[2] );
        gl.glBufferDataARB( GL.GL_ARRAY_BUFFER_ARB, stepLimits[ actualTerrain ] * stepLimits[ actualTerrain ] * vertexCount * BufferUtils.SIZEOF_FLOAT, waterDistanceBuffer[actualTerrain], GL.GL_STATIC_DRAW_ARB );
        gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, 0);
}
gl.glBindBufferARB( GL.GL_ARRAY_BUFFER_ARB, 1);
        gl.glDisable( GL.GL_TEXTURE_2D );

        for(int k=0; k< stepLimits[actualTerrain]; ++k){
            for(int l=0; l< stepLimits[actualTerrain]; ++l){
                gl.glEnable( GL.GL_BLEND );
                gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA );
                if( needWaterRender[actualTerrain][k][l] ){

                    gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, waterNames[actualTerrain] );
                    gl.glVertexPointer( 3, GL.GL_FLOAT, 0, BufferUtils.bufferOffset( waterOffsets[actualTerrain][k][l] * BufferUtils.SIZEOF_FLOAT ) );

                    gl.glUseProgramObjectARB( waterShaderObj );

                        gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, waterNormalNames[actualTerrain] );
                        gl.glVertexAttribPointerARB( NORMAL_BUFFER,  1, GL.GL_FLOAT, false, 0, BufferUtils.bufferOffset( waterNormalOffsets[actualTerrain][k][l] * BufferUtils.SIZEOF_FLOAT ) );

                        gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, waterDistanceNames[actualTerrain] );
                        gl.glVertexAttribPointerARB( DISTANCE_BUFFER,  1, GL.GL_FLOAT, false, 0, BufferUtils.bufferOffset( waterDistanceOffsets[actualTerrain][k][l] * BufferUtils.SIZEOF_FLOAT ) );

                        gl.glBindBufferARB(GL.GL_ELEMENT_ARRAY_BUFFER_ARB, names[0] );

                        gl.glEnableClientState( GL.GL_VERTEX_ARRAY);
                        gl.glEnableClientState( GL.GL_COLOR_ARRAY);
                        gl.glEnableVertexAttribArrayARB( DISTANCE_BUFFER );
                        gl.glEnableVertexAttribArrayARB( NORMAL_BUFFER );
                        gl.glDrawRangeElements( GL.GL_TRIANGLE_STRIP, 0, vertexIndexCount, vertexIndexCount, GL.GL_UNSIGNED_INT, BufferUtils.bufferOffset( 0 ) );
                        gl.glDisableClientState( GL.GL_COLOR_ARRAY );
                        gl.glDisableClientState( GL.GL_VERTEX_ARRAY );
                        gl.glDisableVertexAttribArrayARB( NORMAL_BUFFER );
                        gl.glDisableVertexAttribArrayARB( DISTANCE_BUFFER );

                    gl.glUseProgramObjectARB( 0 );

                }
                gl.glDisable( GL.GL_BLEND );
            }
        }

Share this post


Link to post
Share on other sites
Advertisement
I guess there are people on this board who can handle this without it, but id claim that most people (me too) would be interested in what exactly doesnt work, if there are compiler errors and which and so on...

Cheers
TwilightShade

Share this post


Link to post
Share on other sites
ok,ok.
The code can be compiled. But when I try to run it, I receive this message:
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6915739c, pid=2348, tid=1468
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0-b64 mixed mode, sharing)
# Problematic frame:
# C [atioglxx.dll+0x15739c]
#
# An error report file with more information is saved as hs_err_pid2348.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#

Share this post


Link to post
Share on other sites
Well, looks like a problem with your ati card... cant say more cuz this is a little too cryptic for me, but you could try upgrading to newer graphic drivers (beware of the newest, for me they make only problems (radeon9500)), but i wouldnt really expect this to solve your problem... sorry.

Cheers
TwilightShade

Share this post


Link to post
Share on other sites
It looks like you haven't allocated the memory properly, have you tried running both the VBOs and the shaders seperate? (check the shader using a few glBegin(GL_QUAD) quads)

Share this post


Link to post
Share on other sites
Ok, I found the problem!

This line is the source of the exception:
gl.glEnableClientState( GL.GL_COLOR_ARRAY);
I don't have color array:)

By the way, thanks very much.
considering your tips, I tested the vbo code without the shader and I corrected some bugs.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!