Skip to main content
gamedev.net
🔒 Locked

alpha texture

Started by kampfgnu 1 reply 550+ views
Original Post
kampfgnu
kampfgnu
hello, how do i generate a texture only representing alphas by hand and load it? e.g. a 4x4 texture: float data[4*4] = [0.1, 0.1, 0.1, 0.1, 0.1, 0.5, 0.5, 0.1, 0.1, 0.5, 0.5, 0.1, 0.1, 0.1, 0.1, 0.1 ] defining it like that and then do:

glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 4, 4, 0, GL_ALPHA, GL_FLOAT, &data);
seems not to work... anyone?
kampfgnu
kampfgnu
in comparison, if i create a float array with values like:

float data = [1,0,0,1, 1,0,0,1, 1,0,0,1,....]

and do a:

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size, size, 0, GL_RGBA, GL_FLOAT, &data);

when drawing, it should be red, but also is not.
should this work, or am i on the totally wrong path?
greets
V-man
V-man
It depends on lighting, the texture environment state.
If you use GL_ALPHA, it says
Quote:
Each element is a single alpha component.
The GL converts it to floating point and assembles it into an RGBA element
by attaching 0 for red, green, and blue.
Each component is then multiplied by the signed scale factor GL_c_SCALE,
added to the signed bias GL_c_BIAS,
and clamped to the range [0,1]
(see glPixelTransfer).


so the alpha will be right

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.