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 > Re: OpenGL stat...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 12 Topic 4824 of 5017
Post > Topic >>

Re: OpenGL states and performances

by Wolfgang Draxinger <wdraxinger@[EMAIL PROTECTED] > Jul 7, 2008 at 05:28 PM

karim.atiki@[EMAIL PROTECTED]
 wrote:

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

Both are excellent ideas, and it's the way how it should be done.
Now a suggestion: Before doing the actual rendering to a
pre-pass to determine all the textures you actually need. Then
group them by layer, and within each layer group the rendering
order by texture, so that you get the least amount of texture
switching.
 
> 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:


You can't "active" the alpha channel. If you've got a RGBA
texture, it's always there. What you can enable/disable is the
blending between new fragments and the old content of the
framebuffer.

glEnable/glDiable(GL_BLEND); 


Wolfgang Draxinger
-- 
E-Mail address works, Jabber: hexarith@[EMAIL PROTECTED]
 ICQ: 134682867
 




 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 Fri Nov 21 5:03:47 CST 2008.