An update on my graphics system

Published November 20, 2006
Advertisement
Brief addendum to my previous post:

After thinking about the problem, I came to the conclusion that it's better to get the system up and running first before I start mucking around with the internals of the graphics engine; that way I'll have a proper game to test it with. So the thing to do is cobble together a working depth system by switching to using 3D coordinates instead of 2D in my OpenGL sprite drawing code.

Only problem is - it's not working properly. The depth sorting seems to be working, but I can't seem to get OpenGL to draw my sprites with proper transparency; the alpha values just wipe out the values of the sprites behind them. Obviously I haven't set up something properly with the myriad of confusing OpenGL flags and settings.

Another thing is I'm not sure how efficient this sprite system is going to be; from my tests it seems I can only render several thousand text glyphs before the frame rate drops down to potentially sluggish levels. I'm not going to worry about fine tuning at this early stage, but it's something I'm a bit concerned about. Might be due to some weird OpenGL settings as well.

Edit: Ah, I seem to have found a fix: I needed to enable GL_ALPHA_TEST and use something like glAlphaFunc(GL_GREATER, 0.05f) to get it to work.
0 likes 3 comments

Comments

LachlanL
Heya. You'll still need to draw any objects that are partially transparent in order of depth. From furthest from the camera to closest. Otherwise, just draw all opaque objects first, turn depth writes off and draw trasparent as usual.
November 20, 2006 04:25 PM
Trapper Zoid
Quote: Original post by LachlanL
Heya. You'll still need to draw any objects that are partially transparent in order of depth. From furthest from the camera to closest. Otherwise, just draw all opaque objects first, turn depth writes off and draw trasparent as usual.

Will I? The key elements that will be problem will have transparency, namely the character and object sprites.

Darn it. I might as well then resort to plan B and stick references to the objects in a big ol' linked list for in-order drawing then, and disable the OpenGL depth testing.

November 20, 2006 08:32 PM
LachlanL
Sorry if I was misleading. I'm only talking about when you have partially transparent pixels (like an alpha value of 100 or something). If your pixels are all either completely opaque (alpha 255) or completely transparent (alpha 0), then you won't have to worry about it.
November 21, 2006 05:08 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement