diff --git a/GL/draw.c b/GL/draw.c index f6b2b3a..5e9a231 100644 --- a/GL/draw.c +++ b/GL/draw.c @@ -1224,7 +1224,9 @@ static void submitVertices(GLenum mode, GLsizei first, GLuint count, GLenum type glDepthFunc(GL_EQUAL); glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + /* This is modulation, we need to switch depending on the texture env mode! */ + glBlendFunc(GL_DST_COLOR, GL_ZERO); /* Send the buffer again to the transparent list */ push(mtHeader, mtStart, target->count, _glTransparentPolyList(), 1); diff --git a/samples/zclip/main.c b/samples/zclip/main.c index b99f3a0..cbb88fd 100644 --- a/samples/zclip/main.c +++ b/samples/zclip/main.c @@ -3,6 +3,7 @@ #include #include "gl.h" +#include "glext.h" #include "glu.h" #include "glkos.h" @@ -23,6 +24,7 @@ typedef struct // Create A Structure TextureImage textures[3]; TextureImage road; +TextureImage lightmap; GLboolean LoadTGA(TextureImage *texture, const char *filename) // Loads A TGA File Into Memory @@ -123,7 +125,11 @@ void LoadGLTextures() { if(!LoadTGA(&road, "/rd/floor.tga")) { fprintf(stderr, "Error loading road texture"); } -}; + + if(!LoadTGA(&lightmap, "/rd/lightmap.tga")) { + fprintf(stderr, "Error loading lightmap texture"); + } +} /* A general OpenGL initialization function. Sets all of the initial parameters. */ @@ -170,40 +176,64 @@ void RenderTower(counter) { float v = 1.0f * (counter + 1); + glActiveTexture(GL_TEXTURE0); + glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, textures[counter].texID); + + glActiveTexture(GL_TEXTURE1); + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, lightmap.texID); + glBegin(GL_QUADS); - glTexCoord2f(0, 0); + glMultiTexCoord2f(GL_TEXTURE0, 0, 0); + glMultiTexCoord2f(GL_TEXTURE1, 0, 0); glVertex3f(-width, 0,-width); - glTexCoord2f(1, 0); + glMultiTexCoord2f(GL_TEXTURE0, 1, 0); + glMultiTexCoord2f(GL_TEXTURE1, 1, 0); glVertex3f(-width, 0, width); - glTexCoord2f(1, v); + glMultiTexCoord2f(GL_TEXTURE0, 1, v); + glMultiTexCoord2f(GL_TEXTURE1, 1, 1); glVertex3f(-width, height, width); - glTexCoord2f(0, v); + glMultiTexCoord2f(GL_TEXTURE0, 0, v); + glMultiTexCoord2f(GL_TEXTURE1, 0, 1); glVertex3f(-width, height,-width); - glTexCoord2f(0, 0); + glMultiTexCoord2f(GL_TEXTURE0, 0, 0); + glMultiTexCoord2f(GL_TEXTURE1, 0, 0); glVertex3f(-width, 0, width); - glTexCoord2f(1, 0); + glMultiTexCoord2f(GL_TEXTURE0, 1, 0); + glMultiTexCoord2f(GL_TEXTURE1, 1, 0); glVertex3f( width, 0, width); - glTexCoord2f(1, v); + glMultiTexCoord2f(GL_TEXTURE0, 1, v); + glMultiTexCoord2f(GL_TEXTURE1, 1, 1); glVertex3f( width, height, width); - glTexCoord2f(0, v); + glMultiTexCoord2f(GL_TEXTURE0, 0, v); + glMultiTexCoord2f(GL_TEXTURE1, 0, 1); glVertex3f(-width, height, width); - glTexCoord2f(0, 0); + glMultiTexCoord2f(GL_TEXTURE0, 0, 0); + glMultiTexCoord2f(GL_TEXTURE1, 0, 0); glVertex3f(width, 0,width); - glTexCoord2f(1, 0); + glMultiTexCoord2f(GL_TEXTURE0, 1, 0); + glMultiTexCoord2f(GL_TEXTURE1, 1, 0); glVertex3f(width, 0,-width); - glTexCoord2f(1, v); + glMultiTexCoord2f(GL_TEXTURE0, 1, v); + glMultiTexCoord2f(GL_TEXTURE1, 1, 1); glVertex3f(width, height,-width); - glTexCoord2f(0, v); + glMultiTexCoord2f(GL_TEXTURE0, 0, v); + glMultiTexCoord2f(GL_TEXTURE1, 0, 1); glVertex3f(width, height, width); glEnd(); } void RenderFloor() { + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, road.texID); + + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, 0); + glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex3f(-100, 0, 0); diff --git a/samples/zclip/romdisk/lightmap.tga b/samples/zclip/romdisk/lightmap.tga new file mode 100644 index 0000000..af277b6 Binary files /dev/null and b/samples/zclip/romdisk/lightmap.tga differ