Original Post
Hello, I'm a new OpenGL programmer as well as a new member to this messageboard, and let me stress I'm a VERY new OpenGL programmer :) I'm just going through NeHe's (http://nehe.gamedev.net, which is an *excellent* starting point for OpenGL) tutorials, and I've decided to test my knowledge by creating a scene with a random starfield, with some of the stars being "large" (a twinkle BMP texture of size 128x128). The problem I'm having is getting the texture to show up on the quad. This is the relevant code(or what I think is relevant): I'm pretty sure the problem lays in here somewhere because I previously had the starfield drawing fine. The resulting code is from me pulling the starfield out to isolate the problem. Any suggestions are greatly appreciated. Thanks in advance, Visser
//...
int LoadGLTextures() {
int Status = FALSE;
AUX_RGBImageRec *TextureImage[1];
memset(TextureImage, 0, sizeof(void *)*1);
//load streaks
TextureImage[0] = LoadBMP("streaks.bmp");
Status = TRUE;
glGenTextures(1, &texture[0]);
//GL_NICEST
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
if (TextureImage[0]) {
if (TextureImage[0]->data) {
free(TextureImage[0]->data);
}
free(TextureImage[0]);
}
return TRUE;
}
//...
int InitGL(GLvoid) {
if (!LoadGLTextures()) { return FALSE; }
glEnable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glLightfv(GL_LIGHT1, GL_AMBIENT, lightAmbient); //Add Ambient Light
glLightfv(GL_LIGHT1, GL_DIFFUSE, lightDiffuse); //Add Diffuse Light
glLightfv(GL_LIGHT1, GL_POSITION, lightPosition); //Set Position
//glEnable(GL_LIGHT1);
return TRUE;
}
int DrawGLScene(GLvoid) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_QUADS);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -5.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -5.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(1.0f, -1.0f, -5.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(1.0f, 1.0f, -5.0f);
glEnd();
glLoadIdentity();
return TRUE;
}