Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (408)
games submitted by our members
Games in WIP (293)
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  
  Performance when using more/less buffers  (Read 831 times)
0 Members and 1 Guest are viewing this topic.
Offline teletubo
« League of Dukes »

JGO Ninja


Medals: 42
Projects: 6



« Posted 2011-05-02 18:59:09 »

How much, or does it even affect performance when I use more buffers (on Vertex arrays, for example) in opengl calls ?

For example , in this case, I enable 3 arrays (normal, vertex, color).

1  
2  
3  
4  
5  
6  
7  
      GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); 
      GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
      GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
/* populate buffers */
      GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
      GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
      GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);



But if I drop the color array, how faster will it be ? Will it make any difference at all ? (not counting the filling of the float arrays . let's suppose they are static) 

1  
2  
3  
4  
5  
      GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); 
      GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
/* populate buffers */
      GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
      GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);



Thank you .



Offline lhkbob

JGO Knight


Medals: 32



« Reply #1 - Posted 2011-05-02 22:23:56 »

If you're using vertex arrays, you're sending the data to the card every time you call glColorPointer/glVertexPointer or with every glDrawArrays/glDrawElements call (I think this depends on how smart the graphics card is, and when it does the transfer). If you are using VBOs, there will probably be less of a performance hit, since all the buffers are on the graphics card anyway.

If you consider OpenGL as a client-server model, enabling the color buffer doesn't change the amount of work being done server side when determining a vertex's color, since it would just take the color from the last call to glColor3f.  There would be more work on the client side (or in the bridge between client and server), to change this color with each vertex.

For many purposes, I don't think you'll see much of a performance hit compared to the draw command itself, or using more detailed geometry.  However, I think it's usually recommended to take the practice of not enabling things that you don't need to.  So if you don't use the colors or texture coordinates for a draw command, then don't have them enabled that time around.  It would be fastest of all to sort by what needs to be enabled so that these changes are across multiple calls to the draw methods.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (147 views)
2013-05-17 21:29:12

alaslipknot (155 views)
2013-05-16 21:24:48

gouessej (186 views)
2013-05-16 00:53:38

gouessej (180 views)
2013-05-16 00:17:58

theagentd (190 views)
2013-05-15 15:01:13

theagentd (174 views)
2013-05-15 15:00:54

StreetDoggy (218 views)
2013-05-14 15:56:26

kutucuk (243 views)
2013-05-12 17:10:36

kutucuk (241 views)
2013-05-12 15:36:09

UnluckyDevil (247 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.099 seconds with 20 queries.