JOGL display list->JME TriMesh

Hi ALL!

I have a display list in my jogl program, and I do not know how to do it with jme.

In the display list I have the following data for each square (first a color,then a tri,then a tri):

  • glBegin GL_TRIANGLES
  • glColor3f(r,g,b)


  • glTexCoord2f(tx0,ty0)
  • glVertex3f(x0,y0,z0)
  • glTexCoord2f(tx1,ty1)
  • glVertex3f(x1,y1,z1)
  • glTexCoord2f(tx2,ty2)
  • glVertex3f(x2,y2,z2)


  • glTexCoord2f(tx0,ty0)
  • glVertex3f(x0,y0,z0)
  • glTexCoord2f(tx1,ty1)
  • glVertex3f(x1,y1,z1)
  • glTexCoord2f(tx2,ty2)
  • glVertex3f(x2,y2,z2)


  • glEnd


This way every square needs 3+3*5+3*5=33 float-> 33*4 bytes.
Every square may have different color, so I can't define only the vertices and use indexBuffer.
If I want to use TriMesh object I have to add so many unneeded floats to get the same picture.
vertices+texcoords+colors+indices
If I see the source code of TriMesh-GeomBatch, it contains that I must use indexBuffer.
Is there another way to represent my squares to jme?
Is there display lists in jme? My jogl prg not too slow...

- Do I have to use always floats when define color or texture coord values? If I would use 3 bytes for r,g,b and 2 bytes for texcoord (0,1), it would use much less memory -> greater performance... maybe?

Thanks

Yes there are display lists in jME, jME creates them when you use jME's lock methods.



If you really think a TriMesh is too heavy, you van port your JOGL code to LWJGL, and make a custom scenegraph object for it.

keep in mind that using more memory does not (necessarily) mean less performance.



I think the ease of use when using a high level API like jME outweigths the (usually) small loss of performance.

If I want to use TriMesh object I have to add so many unneeded floats to get the same picture.
vertices+texcoords+colors+indices

Even though you have to add those floats, you don't need to use immediate mode to send your geometry to the video card. Using your way right now, you spend 15 GL calls per quad to upload the data, if you use jME's trimesh you could pack all your quads in there and have 3-4 calls to send your whole scene. Also if you use a Vertex buffer object to store your data, you would not have the extra memory overhead of displaylists (requires storing all calls + additional data per GL call).

- Do I have to use always floats when define color or texture coord values? If I would use 3 bytes for r,g,b and 2 bytes for texcoord (0,1), it would use much less memory -> greater performance... maybe?

You have to use floats, or should, because that's how they are stored on the video card. Even if OpenGL supports other data types it probably converts them to floats before sending to the video card, thus you lose precision for absolutely no gain.