Any way to mask certain colours in an opengl texture map?
For example, how can I stop it drawing the pure white texels in this program; ?
I've been right through the red book and I cant seem to find what I need..
option explicit
option static
'-------------------------------------
' Includes
'-------------------------------------
#include "GL/gl.bi"
#include "GL/glu.bi"
#include "windows.bi"
dim shared pfd as PIXELFORMATDESCRIPTOR
dim shared hdc as hDC
declare sub InitOGL()
DECLARE SUB LOGO_TEXTURE()
InitOGL()
'===============================================================================
' LOGO XOR TEXTURE GENERATION;
'===============================================================================
DIM SHARED AS UINTEGER LOGOBUFFER ( 256 * 256 )
DIM SHARED tex1 AS GLUINT
DIM AS UINTEGER X,Y,PIXEL
for y = 0 TO 255
for x = 0 TO 255
PIXEL = X XOR Y
pixel=int(rnd(1)*2)
if pixel=1 then
PIXEL=255
else
PIXEL=100
end if
LOGOBUFFER((y * 256)+X) = RGBA(PIXEL,PIXEL,PIXEL,255)
NEXT
NEXT
glGenTextures 1, @tex1
glBindTexture(GL_TEXTURE_2D, tex1)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR)
gluBuild2DMipmaps (GL_TEXTURE_2D, 3, 256, 256,GL_RGBA, GL_UNSIGNED_BYTE, @LOGOBUFFER(0))
'===============================================================================
' MAIN LOOP
'===============================================================================
while(GetAsyncKeyState(VK_ESCAPE)<>-32767)
glClear(GL_DEPTH_BUFFER_BIT + GL_COLOR_BUFFER_BIT )
LOGO_TEXTURE()
SwapBuffers(hDC)
wend
'===============================================================================
' Initialise OpenGL
'===============================================================================
sub InitOGL()
pfd.cColorBits = 32
pfd.cDepthBits = 32
pfd.dwFlags = PFD_SUPPORT_OPENGL + PFD_DOUBLEBUFFER
hDC = GetDC(CreateWindow("edit", 0,WS_POPUP+WS_VISIBLE+WS_MAXIMIZE,0, 0, 0 , 0, 0, 0, 0, 0))
SetPixelFormat ( hDC, ChoosePixelFormat ( hDC, @pfd) , @pfd )
wglMakeCurrent ( hDC, wglCreateContext(hDC) )
ShowCursor(FALSE)
glMatrixMode(GL_PROJECTION)
gluPerspective(45.0f,1024/768,0.1f,100.0f)
glMatrixMode(GL_MODELVIEW)
end sub
'===============================================================================
' DRAW THE "LOGO"
'===============================================================================
SUB LOGO_TEXTURE()
glLoadIdentity()
glTranslatef(0, 0, -6)
glEnable(GL_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D, tex1)
glenable gl_blend
GLBEGIN GL_QUADS
glNormal3f 0.0f, 0.0f, 1.0f
glTexCoord2f 0.0, 0.0
glVertex3f -1.0f, -1.0f, 1.0f
glTexCoord2f 1.0, 0.0
glVertex3f 1.0f, -1.0f, 1.0f
glTexCoord2f 1.0, 1.0
glVertex3f 1.0f, 1.0f, 1.0f
glTexCoord2f 0.0, 1.0
glVertex3f -1.0f, 1.0f, 1.0f
GLEND
gldisable gl_blend
END SUB