Set transparent color in RGB image

Started by
4 comments, last by V-man 14 years, 1 month ago
I am new to OpenGL ES, hopefully someone could kindly help me out. I have a RGB image with pink color set as transparency color. While in Direct3D, we can easily set the modulate color while creating the texture, my question is, how do we set up a transparency modulate color in OpenGL ES? In another word, how can I tell the graphic unit not to draw pink color when it's processing the texture. Thanks in advance.
Advertisement
Hi lyen!

I haven't used OpenGL ES, but IMO, it's easier to apply the alpha layer in any graphics program (like Phothoshop), and save the image as png.
Thanks for the reply and your suggestion, Juanxo.

I know what you suggested is a viable solution, but the programmer in me would like to know if there is a solution to programatically handle such issue =).
I don't think OpenGL has a function for this (possibly some obscure extension that I don't know of though).

To do this you can either use a shader, or loop through the texture on CPU replacing pink with alpha before uploading.

The latter is probably the best idea as its a one time hit, and the branching required to implement this in a shader may not be very efficient.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
After a day of research, looks like Karwosts' suggestion is the most feasible.

DirectX does this for programmer during texture creation, I think OpenGL just wants us work a bit harder =).

Thanks all for your suggestions and help!
Quote:Original post by lyen
After a day of research, looks like Karwosts' suggestion is the most feasible.

DirectX does this for programmer during texture creation, I think OpenGL just wants us work a bit harder =).

Thanks all for your suggestions and help!


You are thinking of D3DX, the utility library.
The equivalent of the D3DX are some libraries at the Alternative Game Lib forum
here on gamedev.
A lot of stuff for doing math, quaternion, image manipulation.
Perhaps DevIL do what you want (DevIL = Developer Image Library)
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement