vertex arrays

So I’m trying to get some vertex array code working and it doesn’t poop and give me an error but it draws nothing (screen is grey). I’m looking at a working version and I can’t see any difference in the parts that matter.

Any idea on where the problem might be? I’m thinking my best shot at this point is just starting over. ::slight_smile:

…or sleep… or both. :wink:

Well, where’s the code?

  • elias

That’s a shitload of code, and it could be anywhere. I’m gonna go to sleep, and when I wake up i’ll try one more time to fix it, and if I have no success ill post the 4 billion lines. :confused:

I guess I was hoping for a “oh that” response so I could fix it before I went to sleep. I know it’s not very realistic, but I sleep like crap with programming on the brain, even falling down tired. Anyone else like that?

Seriously, I dream about it.

[quote]Anyone else like that?
[/quote]
Yep. I also tend to yell loudly about the solution to bugs when I’m totally drunk… but I can’t remember the solution when i sober up :frowning: (assuming I really had a solution when I was drunk :slight_smile: )

Damnit, I missed that vertex array example on the nehe/lwjgl port site when I looked the previous 2 times. Kicking myself. I thought it was just odd how that wasn’t on there so I was using a far more complicated piece of code to look at. (spgl SpriteRenderer)

I should be able to build on this slowly and see what acually breaks. Was a neat waste of 3-4 hours and a forum post though. ::slight_smile:

Since I seem to be unable to convert the tex demo into a single buffer deal (hes using one for textures,colors,and indices) I decided to go my own way and go as SLOW AS POSSIBLE. I also decided even though it’s a waste of space I would just try and exactly duplicate (to the number) the first working example I ever made with a quad/texture.

So far I’m doing ok, I can see the quad, except it’s coming out completely green, and it’s one of the colors in the tile texture. So something funky is going on here:

// setup
gl.enable( GL.TEXTURE_2D );
gl.matrixMode( GL.PROJECTION );
gl.loadIdentity();
gl.glu.ortho2D( 0, width, 0, height );
gl.scalef( 1, -1, 1 );
gl.translatef( 0, -height, 0 );
gl.matrixMode( GL.MODELVIEW );
gl.loadIdentity();
gl.viewport( 0, 0, width, height );

// edit: I’m loading textures here btw :wink:

        gl.enableClientState( GL.VERTEX_ARRAY );
        gl.enable( GL.TEXTURE_2D );
        gl.bindTexture( GL.TEXTURE_2D, 7 );

// my rendering code

        MultiBuffer buf = new MultiBuffer( 80 );
        
        buf.floats.put( 0.0f );
        buf.floats.put( 0.0f );
        buf.floats.put( 0.0f );
        buf.floats.put( 16.0f );
        buf.floats.put( 0.0f );
        buf.floats.put( 0.0f );
        buf.floats.put( 16.0f );
        buf.floats.put( 16.0f );
        buf.floats.put( 0.0f );
        buf.floats.put( 0.0f );
        buf.floats.put( 16.0f );
        buf.floats.put( 0.0f );
        
        buf.floats.put( 0.0f );
        buf.floats.put( 0.0f );
        buf.floats.put( 1.0f );
        buf.floats.put( 0.0f );
        buf.floats.put( 1.0f );
        buf.floats.put( 1.0f );
        buf.floats.put( 0.0f );
        buf.floats.put( 1.0f );
        
        gl.loadIdentity();
        gl.translatef( 50.0f, 50.0f, 0.0f );
        
        gl.vertexPointer( 3, GL.FLOAT, 0, buf.getAddress() );
        gl.texCoordPointer( 2, GL.FLOAT, 0, buf.getAddress() + 48 );
        
        gl.drawArrays( GL.QUADS, 0, 20 );

All the MultiBuffer is doing is maintaining a ByteBuffer/IntBuffer/FloatBuffer view and getAddress() is just the Sys.getDirectBufferAddresThingy(buf). The rest of the program is completely stipped down and is just enough to get everything working.

Shoot me, please.

EDIT: ok I think I’m putting the info in the buffer wrong, i.e. you supposed to be putting the info in for each vertice(s) not the whole quad but when I change it to this I get the same result:

        buf.floats.put( 0.0f );
        buf.floats.put( 0.0f );
        buf.floats.put( 0.0f );
        
        buf.floats.put( 0.0f );
        buf.floats.put( 0.0f );
        
        buf.floats.put( 16.0f );
        buf.floats.put( 0.0f );
        buf.floats.put( 0.0f );
        
        buf.floats.put( 1.0f );
        buf.floats.put( 0.0f );
        
        buf.floats.put( 16.0f );
        buf.floats.put( 16.0f );
        buf.floats.put( 0.0f );
        
        buf.floats.put( 1.0f );
        buf.floats.put( 1.0f );
        
        buf.floats.put( 0.0f );
        buf.floats.put( 16.0f );
        buf.floats.put( 0.0f );
        
        buf.floats.put( 0.0f );
        buf.floats.put( 1.0f );

        gl.vertexPointer( 3, GL.FLOAT, 20, buf.getAddress() );
        gl.texCoordPointer( 2, GL.FLOAT, 20, buf.getAddress() + 12 );

…either this question is hard, or the question is really stupid. :-*

I ponder.

I think I’ll take a nap and dream of vertex arrays stabbing me in the neck slowly over and over.

[quote] …either this question is hard, or the question is really stupid.
[/quote]
OR I am too drunk to answer - Neighbors & redwine = bad combo

Someone get him some coffee. :wink: