PDA

View Full Version : MultiTex problem inside list creation routine



Holrin
04-07-2004, 05:00 AM
Hello.

Does anybody know something about similar problems with using glMultiTexCoord2fARB() function inside compiled list creation routines ?

Thanks for any help.

Best Regards.

Aeluned
04-07-2004, 06:19 AM
Could you be more specific? what problems are you having?

Holrin
04-07-2004, 11:44 AM
It is huge probability that my problem is simply implementation error so i paste some parts of my src.
I'm using only 2 texturing units called by glActiveTextureARB() routine. For texture coords I've used standard glMultiTexCoord2fARB(). But the point is I'm using these texcoord function INSIDE the list creation routine. The FPS results are as follows:
with MultiTex - 6 FPS
without MultiTex - 90 FPS
And the funniest thing: on GF4MX this executable with Multitexturing enabled runs 50 - 60 fps. On my Radeon 9200 it is only 6 fps...

And some code:

list calling with multitex enabled:

void WyswietlTerenMultiTex() {

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, Tekstura.ktora[0]);


glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, Tekstura.ktora[1]);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2);

glMatrixMode(GL_TEXTURE);

glLoadIdentity();
glScalef(8, 8, 1);

glMatrixMode(GL_MODELVIEW);

glCallList(2); // teren

//glDisable(GL_BLEND);
glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE0_ARB);
glDisable(GL_TEXTURE_2D);

}
list creation with multitex coord settings:

void Teren(cFace *faces) {

int X, Y = 0;

Tekstura.TworzTeksturySwiata();

glNewList(2, GL_COMPILE);

glCullFace(GL_FRONT);

for (X = 0; X < MAP_SIZE; X += STEP_SIZE) {

glBegin(GL_TRIANGLE_STRIP);

for (Y = 0; Y < MAP_SIZE; Y += STEP_SIZE) {

faces[X * (MAP_SIZE / STEP_SIZE) + Y].TworzFace();
TriangleCount += 2;

}

glEnd();
}

glEndList();

}
and the previously used TworzFace() routine:

void TworzFace() {

//glNormal3f(Normal_1.x, Normal_1.y, Normal_1.z);

glMultiTexCoord2fARB(verts[0].x / MAP_SIZE ,-(verts[0].z / MAP_SIZE));
glVertex3f(verts[0].x, verts[0].y, verts[0].z);

glMultiTexCoord2fARB(verts[1].x / MAP_SIZE ,-(verts[1].z / MAP_SIZE));
glVertex3f(verts[1].x, verts[1].y, verts[1].z);

glMultiTexCoord2fARB(verts[2].x / MAP_SIZE ,-(verts[2].z / MAP_SIZE));
glVertex3f(verts[2].x, verts[2].y, verts[2].z);

//glNormal3f(Normal_2.x, Normal_2.y, Normal_2.z);

glMultiTexCoord2fARB(verts[3].x / MAP_SIZE ,-(verts[3].z / MAP_SIZE));
glVertex3f(verts[3].x, verts[3].y, verts[3].z);
}
These parts of code are just fragments from object oriented project but i hope that essentials are visible.

Sorry for my poor english and thanks for ANY help.

Best Regards.

zeckensack
04-07-2004, 04:19 PM
glMultiTexCoord2fARB's first argument is the texture stage you want to specify coordinates for. This is valid:
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0.0f,0.0f);Yo ur snippet shouldn't even compile :confused:

edited because we apparently can't have bold tags inside code tags

Holrin
04-08-2004, 02:16 AM
It is my mistake. I want to simplify pasted code because in my project i have function SetTextureCoords(x,z) to set the tex coordinates. Body of this function contains:

void SetTextureCoords(float x, float z) {
float u = x / MAP_SIZE;
float v = -z / MAP_SIZE;

glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u, v);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, u, v);
}
In TworzFace routine i'm calling SetTextureCoords() function before each vertex.

void TworzFace() { //glNormal3f(Normal_1.x, Normal_1.y, Normal_1.z);
SetTextureCoords(verts[0].x,verts[0].z);
glVertex3f(verts[0].x, verts[0].y, verts[0].z);
SetTextureCoords(verts[1].x,verts[1].z);
glVertex3f(verts[1].x, verts[1].y, verts[1].z);
SetTextureCoords(verts[2].x,verts[2].z);
glVertex3f(verts[2].x, verts[2].y, verts[2].z);
//glNormal3f(Normal_2.x, Normal_2.y, Normal_2.z);
SetTextureCoords(verts[3].x,verts[3].z);
glVertex3f(verts[3].x, verts[3].y, verts[3].z);
}
So that's my code but it doesn't change anything. Fps results are still very low with multitex enabled.
I wonder if two passes of the glMultiTexCoord2fARB() could be a reason of this because when I call this function ONCE (for only one texturing unit) there seems to ok but unfortunately with only one texture.

Best Regards.