Getting A Classic Zelda View
Code:
gluOrtho2D(0, game_width, game_height, 0);
Ok so if I subtract from a Y value it will still go down. Ok.
How can I get things to draw in the proper order visibly? (see my last post)
How can I get things to draw in the proper order visibly? (see my last post)
draw what you want on top after you draw what's on the bottom. 
Draw O first then P. It's like painting. Whatever you paint first will get covered by what you paint next.

Draw O first then P. It's like painting. Whatever you paint first will get covered by what you paint next.
"Pay no attention to that man behind the curtain." - Wizard of Oz
Oh, I didn't know that worked but then again I've never been working with just 2 dimensions with OpenGL yet. Thanks.
You can still submit the z coordinate if you want openGL to sort things for you. It won't change how things look on the screen, but it will tell openGL what layer you want to draw into.
Otherwise you can just turn of depth testing with glDisable(GL_DEPTH_TEST); and draw things in the order that you want them to appear.
Otherwise you can just turn of depth testing with glDisable(GL_DEPTH_TEST); and draw things in the order that you want them to appear.
I forgot to mention turning off the depth test, but yeah! If you are doing 2D and want good performance, it should be faster for you to do your own depth testing than letting OpenGL sort it out. Plus, if you want good alpha layering you'll end up having to do a lot of sorting yourself anyway.
"Pay no attention to that man behind the curtain." - Wizard of Oz
Oh yeah and this might help you out too:
http://nehe.gamedev.net/data/lessons/les...?lesson=32
It's lesson 32 from the nehe tutorials and most of the questions you've had here are answered in it.
I think there is an SDL version (generic linux but can be fixed for mac quickly)
http://nehe.gamedev.net/data/lessons/les...?lesson=32
It's lesson 32 from the nehe tutorials and most of the questions you've had here are answered in it.
I think there is an SDL version (generic linux but can be fixed for mac quickly)
"Pay no attention to that man behind the curtain." - Wizard of Oz
aaronsullivan Wrote:I forgot to mention turning off the depth test, but yeah! If you are doing 2D and want good performance, it should be faster for you to do your own depth testing than letting OpenGL sort it out. Plus, if you want good alpha layering you'll end up having to do a lot of sorting yourself anyway.
Why is it faster for me to do it? What is alpha layering? Does that have anything to do with transparency?
Pretend for a second that you don't have a video card that can draw a billion pixels a second. Pretend you have a NES. How are you going to draw a pushable block on top of the floor tiles?
Put the Z-order of your objects into your map structure (or sprite structure, whichever) and just draw everything back-to-front.
Put the Z-order of your objects into your map structure (or sprite structure, whichever) and just draw everything back-to-front.
Ok that makes sense. What about the alpha layering? I've heard that term before but I'm not sure what it means.
On a NES, sprite pixels are either there or they aren't. You had 4 pixel values per sprite, so typically three colors plus transparent.
In OpenGL you have 32* bits per pixel. 8 for red, green, blue, and alpha. The alpha determines the translucency. So a torch flame, drawn on top of a floor tile, could show part of the floor through it. Go read the GL spec for blending for more info (man glBlendFunc)
* assuming the old fixed function GL pipeline. Current video cards can allocate 128 color bits per pixel with floating point framebuffers. But this is only of use with fragment shader intermediate results, since all current consumer displays are 24 bpp.
In OpenGL you have 32* bits per pixel. 8 for red, green, blue, and alpha. The alpha determines the translucency. So a torch flame, drawn on top of a floor tile, could show part of the floor through it. Go read the GL spec for blending for more info (man glBlendFunc)
* assuming the old fixed function GL pipeline. Current video cards can allocate 128 color bits per pixel with floating point framebuffers. But this is only of use with fragment shader intermediate results, since all current consumer displays are 24 bpp.
Ok that's cool and useful. Is there a way to designate the transparent color of my sprites?
You can specify the alpha data per pixel exactly like you specify the color data, just use a bitmap format with an alpha channel like PNG or TIFF and an RGBA texture.
Or you can specify the alpha value per primitive with glColor4f.
Or you can specify the alpha value per primitive with glColor4f.
Ok cool. I'll give that a try. Is the alpha channel only a float or can I use glColor4ub?
4ub is fine.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| When to create custom OpenGL view instead of subclass NSOpenGL view | Coyote | 37 | 17,172 |
Oct 20, 2009 08:16 PM Last Post: Coyote |
|

