PDA

View Full Version : Ortho ?



DarkShadow44
11-04-2009, 02:26 PM
Hi, I'm using glOrtho to setup my Screen.

So how can I set which objects are drawn in front of others ?

And how can I set which color should be the transparent color ?
That must be magenta...

Please help!!

scratt
11-04-2009, 07:57 PM
Not sure what you are actually doing as you don't provide details.. Is this a HUD type Ortho view or are you dealing with lots of sprites?

In any case I would suggest sorting your objects back to front and then drawing them in that order with depth testing off.

Also can you elaborate more on what your transparent colour is doing?

ZbuffeR
11-05-2009, 03:27 AM
A tutorial for single color masking :
http://jerome.jouvie.free.fr/OpenGl/Tutorials/Tutorial21.php
This should explain the basics.

DarkShadow44
11-05-2009, 04:28 AM
I am working with C++.

I just want to know how I can make, that all magenta pixels of my (3D)sprites are transparent. I'am loading BMPs, but others would also be OK.

AdrianPi
11-05-2009, 08:06 AM
That is called chroma-keying and as far as I know OpenGL has no built-in support for it. You should expand your texture by adding an alpha channel, and set alpha to be 1 (255) everywhere and 0 on the pixels that are magenta. I would consider also replacing magenta with black to avoid artifacts when textures are filtered, otherwise you'll get magenta borders.

Finally you have to enable alpha blending before rendering your transparent sprites:

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);

// Draw transparent sprites

glDisable(GL_BLEND);

DarkShadow44
11-05-2009, 02:23 PM
Thanks, solved it.
Now using PNGs.