Ortho ?

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

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?

A tutorial for single color masking :
http://jerome.jouvie.free.fr/OpenGl/Tutorials/Tutorial21.php
This should explain the basics.

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.

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);

Thanks, solved it.
Now using PNGs.