Rendering a Texture's Alpha Channel only.

Hello,

this question has nothing to do with jogl, but OpenGL only.

i have a RGBA texture loaded. how would i render the alpha-channel only and completely ignoring the color channels?
pixels with an alpha of 1 should be white, pixels with an alpha of 0 should be transparent.
is that possible? if so, how?

thanks!

http://www.java-gaming.org/forums/index.php?topic=12137.0

Of course, this is trivially easy to do with shaders, but maybe thats not an option.

thanks a lot!

this is giving me an all white texture, but i also want to use other colors.
if i change the color in
gl.glSecondaryColor3ubEXT((byte)col, (byte)col, (byte)col);
then it is not completely one color anymore.

( i am trying to implementing color coded picking, where i render objects to a backbuffer tinted in a specific color and picking them according to the color under the mouse pointer)

as for shaders, yes i’d like to avoid them, since i am targeting also older graphics cards.

thanks

The secondary colour with that setup should be added to whatever the sprite/texture colour is. If you want a specific colour you should be able to set the primary/normal vertex colour to black, so you’d get

(vertexCol * spriteCol) + secondary

where the vertex col is 0/black.

thanks again!

but that did not seem to change anything.

here is the code i am using now:


gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE);
gl.glColor4f(0,0,0,1);

if (gl.isExtensionAvailable("GL_EXT_secondary_color")) {
 gl.glEnable(GL.GL_COLOR_SUM_EXT);
}

for (allObjects) {
 col = calculateUniqueColor(); 
 gl.glSecondaryColor3ubEXT(col.R, col.G, col.B);
 renderObject():
}

pixels still seem to get colored depending on the texture color.
actually i am seeing no difference to whatever i set the primary color to. example: gl.glColor4f(0,0,1,1); looks the same.

if anyone is interested, i found a solution using texture combiners.