Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Graphics > OpenGL 3D API > OpenGL states a...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 12 Topic 4824 of 4952
Post > Topic >>

OpenGL states and performances

by karim.atiki@[EMAIL PROTECTED] Jul 7, 2008 at 02:21 AM

Hi all,

I have some questions about OpenGL.
I am actually writing a 2D tile based game.
I decided to choose OpenGL as I have never really been "allright" with
DX.
The main engine is almost finished but I'm worrying by some technical
points (of view...)

I really worry about the way I'm using OpenGL and particularly about
Texturing and its respective states.
For example:


1) The back and foreground of the game is based on tile. tiles are
extracted from 1 or N textures.
For each tile, the texture should be bound and the triangles/quads are
drawn.
But before binding the texID I store the current texID in a variable
so that it is bound
only if it's different from the current one.
Is it a good to achieve it ?


2) My sprites are composed of key-frames.
Each frame is grabbed from a Sprite-sheet using texture coordinates.
When a sprite is display I apply the same rule than above so that if
several sprites to be displayed are grabbed  from a same sheet,
the texID is bound just one time.


For displaying the sprites I use to activate the alpha channel
therefore I might use glEnable(GL_ALPHA_CHANNEL) etc.
But some other elements (backgrounds, tiles, sprites) may not use it.
At which moment should I enable/disable the GL_ALPHA_CHANNEL ?
I have a Texure2D c++ class in wich I store the GL_RGBA information.
heres a pseudo code:

Texture2D::bind()
{
  if( Texture2D::current_tex_id != this->mTexID) {
  	glBindTexture(GL_TEXTURE_2D, mTexID);

  	if( mUseAlpha ) {
  	  glEnable(GL_ALPHA_CHANNEL);
  	  glAlphaFunc(...)
  	}
  	else {
  	  glDisable(GL_ALPHA_CHANNEL);
  	  ...
  	}
  }
}

Does it make sense for you ?

You might think I worry about ridiculous details as I don't display
millions of triangles,
but I try no to make too many ugly  things .

Basically, I ignore what's the cost of OpenGL state-change function
calls.
Should we limit the glIsEnable(xxx) and glGetIntegerv(xxx) ?



Thanks for your feedback.

Zyend
 




 12 Posts in Topic:
OpenGL states and performances
karim.atiki@[EMAIL PROTEC  2008-07-07 02:21:18 
Re: OpenGL states and performances
Wolfgang Draxinger <wd  2008-07-07 17:28:16 
Re: OpenGL states and performances
karim.atiki@[EMAIL PROTEC  2008-07-07 08:40:25 
Re: OpenGL states and performances
Wolfgang Draxinger <wd  2008-07-07 19:27:36 
Re: OpenGL states and performances
karim.atiki@[EMAIL PROTEC  2008-07-07 11:39:11 
Re: OpenGL states and performances
Wolfgang Draxinger <wd  2008-07-07 21:02:50 
Re: OpenGL states and performances
fungus <openglMYSOCKS@  2008-07-07 14:12:36 
Re: OpenGL states and performances
fungus <openglMYSOCKS@  2008-07-07 14:15:36 
Re: OpenGL states and performances
fungus <openglMYSOCKS@  2008-07-07 20:22:15 
Re: OpenGL states and performances
Wolfgang Draxinger <wd  2008-07-08 10:05:13 
Re: OpenGL states and performances
zyend <karim.atiki@[EM  2008-07-08 05:57:05 
Re: OpenGL states and performances
folays <folays@[EMAIL   2008-07-08 16:01:36 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 7 14:07:23 CDT 2008.