Hi,
I tracked down a problem that caused the rpm and speed meters in Torcs
to be invisible if TCL was disabled. I think it boils down to a missing
radeonEmitState. It is possible that radeonEmitState is not called after
ValidateState has updated the state atoms and before the first primitive
with the new state is emitted. Adding a radeonEmitState at the end of
radeonValidateState fixes the problem but I'm not sure this is the right
place. It also fixes a flashing texture problem reported with Quake3 (on
Radeon VE or with TCL disabled) a long time ago. In many cases,
especially with TCL enabled there seem to be enough radeonEmitState and
RADEON_FIREVERTICES calls scattered throughout the driver to never cause
problems. Maybe some of them are no longer necessary if state is emitted
in radeonValidataState.
I attached a small commented example programme that demonstrates the
problem if TCL is disabled.
Regards,
Felix
__\|/__ ___ ___ ___
__Tsch��_______\_6 6_/___/__ \___/__ \___/___\___You can do anything,___
_____Felix_______\�/\ \_____\ \_____\ \______U___just not everything____
[EMAIL PROTECTED] >o<__/ \___/ \___/ at the same time!
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <stdio.h>
#include <stdlib.h>
#define PRIMITIVE GL_TRIANGLES
#define LAST_PRIMITIVE 1
unsigned char texData[2][8*8*3];
GLuint textures[2];
void init () {
int i;
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_FLAT);
for (i = 0; i < 8*8; ++i) {
/* red texture */
texData[0][3*i+0] = rand();
texData[0][3*i+1] = 0;
texData[0][3*i+2] = 0;
/* green texture */
texData[1][3*i+0] = 0;
texData[1][3*i+1] = rand();
texData[1][3*i+2] = 0;
}
glGenTextures (2, textures);
/* textures[0]: red */
glBindTexture (GL_TEXTURE_2D, textures[0]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, 8, 8, 0, GL_RGB, GL_UNSIGNED_BYTE, texData[0]);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
/* texture[1]: green */
glBindTexture (GL_TEXTURE_2D, textures[1]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, 8, 8, 0, GL_RGB, GL_UNSIGNED_BYTE, texData[1]);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glBindTexture (GL_TEXTURE_2D, 0);
}
void display () {
glClear (GL_COLOR_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);
/* top left corner, texture[0] (red) */
glBindTexture (GL_TEXTURE_2D, textures[0]);
glBegin(GL_QUADS);
glColor3f(1.0, 1.0, 0.0);
glTexCoord2f(0.0, 0.0); glVertex2f(-1.0, 0.0);
glTexCoord2f(1.0, 0.0); glVertex2f(0.0, 0.0);
glTexCoord2f(1.0, 1.0); glVertex2f(0.0, 1.0);
glTexCoord2f(0.0, 1.0); glVertex2f(-1.0, 1.0);
glEnd();
/* top right corner, texture[1] (green) */
glBindTexture (GL_TEXTURE_2D, textures[1]);
glBegin(PRIMITIVE);
glColor3f(1.0, 1.0, 0.0);
#if (PRIMITIVE == GL_TRIANGLES)
glTexCoord2f(0.0, 0.0); glVertex2f(0.0, 0.0);
glTexCoord2f(1.0, 0.0); glVertex2f(1.0, 0.0);
glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 1.0);
glTexCoord2f(1.0, 0.0); glVertex2f(1.0, 0.0);
glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 1.0);
glTexCoord2f(1.0, 1.0); glVertex2f(1.0, 1.0);
#elif (PRIMITIVE == GL_TRIANGLE_STRIP)
glTexCoord2f(0.0, 0.0); glVertex2f(0.0, 0.0);
glTexCoord2f(1.0, 0.0); glVertex2f(1.0, 0.0);
glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 1.0);
glTexCoord2f(1.0, 1.0); glVertex2f(1.0, 1.0);
#elif (PRIMITIVE == GL_TRIANGLE_FAN)
glTexCoord2f(0.0, 0.0); glVertex2f(0.0, 0.0);
glTexCoord2f(1.0, 0.0); glVertex2f(1.0, 0.0);
glTexCoord2f(1.0, 1.0); glVertex2f(1.0, 1.0);
glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 1.0);
#elif (PRIMITIVE == GL_QUADS)
glTexCoord2f(0.0, 0.0); glVertex2f(0.0, 0.0);
glTexCoord2f(1.0, 0.0); glVertex2f(1.0, 0.0);
glTexCoord2f(1.0, 1.0); glVertex2f(1.0, 1.0);
glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 1.0);
#elif (PRIMITIVE == GL_QUAD_STRIP)
glTexCoord2f(0.0, 0.0); glVertex2f(0.0, 0.0);
glTexCoord2f(1.0, 0.0); glVertex2f(1.0, 0.0);
glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 1.0);
glTexCoord2f(1.0, 1.0); glVertex2f(1.0, 1.0);
#elif (PRIMITIVE == GL_POLYGON)
glTexCoord2f(0.0, 0.0); glVertex2f(0.0, 0.0);
glTexCoord2f(1.0, 0.0); glVertex2f(1.0, 0.0);
glTexCoord2f(1.0, 1.0); glVertex2f(1.0, 1.0);
glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 1.0);
#endif
glEnd();
/* bottom left corner, no texture
* Conditions:
* - TCL disabled
* - primitive not QUADS or QUAD_STRIP
* Trigger:
* - glBegin-End pair (even if empty) after glDisable(GL_TEXTURE_2D)
* Symptom:
* previous primitive is rendered with textures[0] instead of textures[1]
*/
glDisable(GL_TEXTURE_2D);
#if (LAST_PRIMITIVE)
glBegin(GL_QUADS);
glEnd();
#endif
glutSwapBuffers();
}
void reshape (int w, int h) {
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho (-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glMatrixMode (GL_MODELVIEW);
}
int main (int argc, char *argv[]) {
int winId;
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_RGBA | GLUT_DOUBLE);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
winId = glutCreateWindow ("Texture Test");
init ();
glutDisplayFunc (display);
glutReshapeFunc (reshape);
//glutIdleFunc (display);
glutMainLoop ();
return 0;
}