I didn't use OpenGl in more than 2 years, so now I became a n00b at it :(
I have a simple question:
Say I have a surface that was previously draw. I have a memory buffer of the size x * y (unsigned char).
That memory buffer represents an alpha map, and has values ranging from 0 to 255.
I am putting that buffer in a texture like this:
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture); //failsafe
bind_texture_id(texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,NIGHT_MAP_X_LEN, NIGHT_MAP_Y_LEN,0,GL_ALPHA8,GL_UNSIGNED_BYTE,night_map_memory);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,NIGHT_MAP_X_LEN, NIGHT_MAP_Y_LEN,0,GL_LUMINANCE8,GL_UNSIGNED_BYTE,night_map_memory);
(I tried both GL_ALPHA8 and GL_LUMINANCE8)
Then later on I have this code:
//attempt to draw the night
get_and_set_texture_id(night_map_text);
glColor4f(0.0f,0.0f,0.0f,0.5f);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE,GL_SRC_ALPHA);
glBegin(GL_QUADS);
draw_2d_thing(0,1,1,0,0,0,window_width,window_height-(window_height-512));
glEnd();
glDisable(GL_BLEND);
Now, this doesn't work, I tried various blending functions and stuff.
Can anyone point out where my mistake is, and how I can get it to work?
[Edited by - Raduprv on January 4, 2006 9:22:05 PM]