Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  vertex arrays  (Read 1840 times)
0 Members and 1 Guest are viewing this topic.
Offline bedelf

Junior Member




Are you suggesting coconuts migrate?


« Posted 2003-06-03 20:00:47 »

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.  Roll Eyes

..or sleep.. or both. Wink
Offline elias

Senior Member





« Reply #1 - Posted 2003-06-03 20:54:30 »

Well, where's the code?

- elias

Offline bedelf

Junior Member




Are you suggesting coconuts migrate?


« Reply #2 - Posted 2003-06-03 21:52:32 »

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. :/

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.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #3 - Posted 2003-06-04 03:34:21 »

Quote
Anyone else like that?


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 Sad (assuming I really had a solution when I was drunk Smiley )

Offline bedelf

Junior Member




Are you suggesting coconuts migrate?


« Reply #4 - Posted 2003-06-04 09:08:58 »

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. Roll Eyes
Offline bedelf

Junior Member




Are you suggesting coconuts migrate?


« Reply #5 - Posted 2003-06-04 16:17:02 »

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 );
Offline bedelf

Junior Member




Are you suggesting coconuts migrate?


« Reply #6 - Posted 2003-06-04 22:06:06 »

..either this question is hard, or the question is really stupid. Kiss

I ponder.

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

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #7 - Posted 2003-06-04 22:19:25 »

Quote
..either this question is hard, or the question is really stupid.  

OR I am too drunk to answer - Neighbors & redwine = bad combo

Offline bedelf

Junior Member




Are you suggesting coconuts migrate?


« Reply #8 - Posted 2003-06-05 11:32:46 »

Quote

OR I am too drunk to answer - Neighbors & redwine = bad combo


Someone get him some coffee. Wink
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (25 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (43 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!