PDA

View Full Version : GLUT underwater example and multitexturing



skwirl
12-13-2001, 02:55 PM
I think I'm doing something wrong... I'm using multitexturing for a school project, and what I'm trying isn't working. So I decided to modify the inspiration, the underwater example from GLUT.

My modified version doesn't work either, so that's why I think I'm doing something wrong. Could someone take a look at it? I've placed the modified underwater.c at http://loki.skwirl.ca/underwater.c

It compiles under Apple's OpenGL for MacOS X, I don't know if it'll compile elsewhere.

skwirl
12-13-2001, 05:27 PM
Okay, I've managed to get this working... however, I don't have it working in my own code... ugh... any insight as to where I could possibly be going wrong?

I have some primitives with a primary texture, some with materials. In order to keep my caustic texture, I'm using a blank texture for the primitives with materials. For the others, the first texture unit is that primitive's texture. For all primitives, texture 2 is the caustic texture. However, at the moment, it's not showing up on any of them.

Thanks!

Dodger
12-13-2001, 09:52 PM
Are you calling glEnable(GL_TEXTURE_2D) for both texture units?

skwirl
12-16-2001, 11:57 AM
GLfloat sPlane[4] = { 0.05, 0.03, 0.0, 0.0 };
GLfloat tPlane[4] = { 0.0, 0.03, 0.05, 0.0 };
static const float causticScale = 1.0;

// First set the texture coordinates for that point
glMultiTexCoord2f(GL_TEXTURE0_ARB, fTexS, fTexT);
sPlane[0] = 0.05 * causticScale;
sPlane[1] = 0.03 * causticScale;

tPlane[1] = 0.03 * causticScale;
tPlane[2] = 0.05 * causticScale;

glActiveTexture(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
// see tex coord generation mode
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGenfv(GL_S, GL_OBJECT_PLANE, sPlane);
glTexGenfv(GL_T, GL_OBJECT_PLANE, tPlane);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);


This is done just before I define the vertex. Is everything in the proper order? Should texture coordinate generation be elsewhere? Thanks!

[This message has been edited by skwirl (edited 12-16-2001).]