Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (115)
games submitted by our members
Games in WIP (563)
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  
  Buffer Question  (Read 1839 times)
0 Members and 1 Guest are viewing this topic.
Offline Mojomonkey

Senior Member




ooh ooh eee eeee


« Posted 2003-10-07 14:03:45 »

Once I send a Buffer to a gl call (e.g. Gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, colorBuf);

is it safe to reuse colorBuf? That is, once the call is made is the reference kept or can I change color buf without affecting the gl call?

Basically I'm doing this:

//set color buf to ambient
//call ambient light param
//set color buf to diffuse
//call diffuse light param
//set color buf to specular
//call specular light param.

Is that safe?

Don't send a man to do a monkey's work.
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #1 - Posted 2003-10-07 14:29:12 »

Most of the time it is - light properties and such are copied into the internal GL state if i remember correctly. Its just things like glVertexPointer that you can't do that with.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Mac_Systems

Junior Member




I love my Java


« Reply #2 - Posted 2003-10-09 07:45:13 »

Hi,

for me the reuse of Color Buffers are ok.
If you use some new Buffers in short intervals
you produce to much garbage. This can slow down performance .

- jens

The Network is the Music
http://www.mac-systems.de
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Mac_Systems

Junior Member




I love my Java


« Reply #3 - Posted 2003-10-12 16:03:52 »

Hi,

Did someone made something with VertexPointer or NormalPointer ?
Seems to be trivial, simply some FloatBuffer that get filled
by some loop like:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
      GL.glEnableClientState(GL.GL_NORMAL_ARRAY);
      GL.glEnableClientState(GL.GL_VERTEX_ARRAY);

      for(int i=0;i<hrm_v3Vertexes.length;i++)
      {
        v3Vertexes[i].store(vertexBuffer);
        v3Normals[i].store(normalBuffer);
      }

      GL.glVertexPointer(3,GL.GL_FLOAT,vertexBuffer);
      GL.glNormalPointer(GL.GL_FLOAT,vertexBuffer);



- Jens


The Network is the Music
http://www.mac-systems.de
Offline princec

JGO Kernel


Medals: 379
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #4 - Posted 2003-10-12 16:39:51 »

You forgot the flip()'s after filling the buffers with vertices!

Cas Smiley

Offline Mac_Systems

Junior Member




I love my Java


« Reply #5 - Posted 2003-10-12 17:54:25 »

Thx,

i ran in some Exepetions without doing it  Roll Eyes

Seems to be a good Way to "serialize" Vertex or Normal
Data.

- Jens

The Network is the Music
http://www.mac-systems.de
Offline Mac_Systems

Junior Member




I love my Java


« Reply #6 - Posted 2003-10-12 19:28:41 »

Hi again  ;D


Did some see something why i get only crap on my Screen ?

The Vertex Buffer is the Vertex Buffer#
and the Normal Buffer holds the Normals
also the index Buffer seems to be correct!

Is there something i forgot ?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
      GL.glEnableClientState(GL.GL_NORMAL_ARRAY);
      GL.glEnableClientState(GL.GL_VERTEX_ARRAY);

      for(int i=0;i<hrm_v3Vertexes.length-1;i++)
      {
        hrm_v3Vertexes[i].store(vertexBuffer);
        hrm_v3Normals[i].store(normalBuffer);
      }
      indexesBuffer.put(hrm_iIndexes);


      GL.glVertexPointer(4,GL.GL_FLOAT,vertexBuffer);// umwandeln der Vertex Pointer in floafBuffer !

      GL.glNormalPointer(GL.GL_FLOAT,normalBuffer);

      GL.glPushMatrix();

      //draw here
     GL.glDrawElements(GL.GL_QUADS,indexesBuffer);

      GL.glPopMatrix();

      vertexBuffer.flip();
      normalBuffer.flip();
      indexesBuffer.flip();

      GL.glDisableClientState(GL.GL_NORMAL_ARRAY);
      GL.glDisableClientState(GL.GL_VERTEX_ARRAY);

      GL.glDisable(GL.GL_TEXTURE_GEN_S);
      GL.glDisable(GL.GL_TEXTURE_GEN_T);


thx 4 helping :=)


- jens

The Network is the Music
http://www.mac-systems.de
Offline Mojomonkey

Senior Member




ooh ooh eee eeee


« Reply #7 - Posted 2003-10-12 19:58:23 »

call flip() before calling glVertexPointer, etc.

Don't send a man to do a monkey's work.
Offline Mac_Systems

Junior Member




I love my Java


« Reply #8 - Posted 2003-10-17 10:18:32 »

Hi,  Grin

im a bit frustated  Angry about the fact that i cant get
any Quad / Triangle working with VertexBuffers
and NormalBuffers, and all other buffers like ColorBuffers.

Is it common that the following Code produce a VM crash ?


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
      GL.glColor3f(1.0f,1.0f,1.0f);
      GL.glLoadIdentity();
      GL.glTranslatef(0f,0.0f,-10.0f);
//      GL.glEnable(GL.GL_TEXTURE_2D);
     GL.glDisable(GL.GL_LIGHTING);

      GL.glEnableClientState(GL.GL_VERTEX_ARRAY);
//      GL.glEnableClientState(GL.GL_NORMAL_ARRAY);

      GL.glVertexPointer(4,GL.GL_FLOAT,vertexBuffer);// umwandeln der Vertex Pointer in floafBuffer !
     GL.glDrawElements(GL.GL_QUADS,indexesBuffer); //<- makes my VM crash

      GL.glDisableClientState(GL.GL_VERTEX_ARRAY);


I have disabled ligthing and set the Lighting Color to white. Now i moved the  GL.glDrawElement( method behind GL.glDisableClientState(GL.GL_VERTEX_ARRAY);
and the Code work, but i see nowthing at all.

Now my Question : Must the glDrawElements called between the enabled Client States ? Or can it be done after the Vertex Pointer was comited to the Gfx Card,and the client state is disabled ?

Sorry for such stupid question again. but i see nothing or my VM crashes.


Thx 4 helping again.

- jens












The Network is the Music
http://www.mac-systems.de
Offline Mojomonkey

Senior Member




ooh ooh eee eeee


« Reply #9 - Posted 2003-10-17 11:08:14 »

How do you set up your indexesBuffer?

Don't send a man to do a monkey's work.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Mac_Systems

Junior Member




I love my Java


« Reply #10 - Posted 2003-10-18 09:30:57 »

Hi,


The Indexnuffer holds indicies for Quads.
all i do is to increment a variable when the
Vertex Data is Calulcated this way :


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
 loop:

           doCalcQuad(); //  

           hrm_iIndexes[ni] = ni;
           hrm_v3Normals[ntri] = n[0];
           hrm_v3Vertexes[ntri] = q[0];
           ntri++;
           ni++;

           hrm_iIndexes[ni] = ni;
           hrm_v3Normals[ntri] = n[1];
           hrm_v3Vertexes[ntri] = q[1];
           ntri++;
           ni++;

           hrm_iIndexes[ni] = ni;
           hrm_v3Normals[ntri] = n[2];
           hrm_v3Vertexes[ntri] = q[2];
           ntri++;
           ni++;

           hrm_iIndexes[ni] = ni;
           hrm_v3Normals[ntri] = n[3];
           hrm_v3Vertexes[ntri] = q[3];
           ntri++;
           ni++;

 loop:end



Well i haven't post all code, coz it is lot more, but the indexing are done there.


thx,
- jens



The Network is the Music
http://www.mac-systems.de
Offline Mojomonkey

Senior Member




ooh ooh eee eeee


« Reply #11 - Posted 2003-10-18 15:12:44 »

Well, if I were you, I'd confirm that your arrays are being set how you think they are. The actual rendering part looks fine to me, but if you are setting the data incorrectly, it won't matter. Confirm your arrays and indices are correct first.

Don't send a man to do a monkey's work.
Offline Mac_Systems

Junior Member




I love my Java


« Reply #12 - Posted 2003-10-18 18:09:14 »

Well, i done this, the index goes up
from 0 to end nothing more.

Ok, i have a look again, it's a very small bug to be find .
As some others also know: Working with new API's
allways produce failures like this, it thing  Angry

Thx mojo so far  Grin

Did someone know some small Code that use the VertexBuffers ? So i be able test it ...

- jens

The Network is the Music
http://www.mac-systems.de
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.

radar3301 (12 views)
2014-09-21 23:33:17

BurntPizza (30 views)
2014-09-21 02:42:18

BurntPizza (19 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (27 views)
2014-09-20 20:14:06

BurntPizza (31 views)
2014-09-19 03:14:18

Dwinin (48 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (102 views)
2014-09-10 06:39:09

Tekkerue (50 views)
2014-09-09 02:24:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

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

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

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!