Hi,
I've been working on a project for some time now and as time has passed, my code have become very messy.
In an attempt to clean everything up in structures, headers and cpp's, I now find that my TGA-loader function no longer, well, functions and I'm at a complete loss.
I'm also doing this restructuring for the purpose of trying to get a functional gluLookAt-camera with quaternions.
When running the "old" code everything is working fine, now when I'm trying to use the same code in my new program the texture turns out like this:
I'm using NeHe's base code and did the tutorial for a TGA-loader (quite a newbie here).
LoadGLTextures (main.cpp)
bool LoadTGA(Texture *, char *);
Texture texture[2];
int LoadGLTextures(){
int Status = false;
if (LoadTGA(&texture[0], "data/globe.tga") && LoadTGA(&texture[1], "data/starmap.tga")){
Status = true;
glGenTextures(2, &texture[0].texID);
glBindTexture(GL_TEXTURE_2D, texture[0].texID);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, 3, texture[0].width, texture[0].height, 0, GL_RGB, GL_UNSIGNED_BYTE, texture[0].imageData);
glBindTexture(GL_TEXTURE_2D, texture[1].texID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, texture[1].width, texture[1].height, 0, GL_RGB, GL_UNSIGNED_BYTE, texture[1].imageData);
if(texture[0].imageData){
free(texture[0].imageData);
}
if(texture[1].imageData){
free(texture[1].imageData);
}
}
return Status;
}
Draw (main.cpp)
void Draw (void){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SetupLights();
glLoadIdentity();
gluLookAt( 0.0f, 1.0f, 50.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
GLUquadric *q = gluNewQuadric();
gluQuadricNormals(q, GLU_SMOOTH);
gluQuadricTexture(q, GL_TRUE);
glBindTexture(GL_TEXTURE_2D, texture[0].texID);
gluQuadricOrientation(q, GLU_OUTSIDE);
gluSphere(q, 10.0f, 4096, 4096);
glTranslatef(20.0f, 0.0f, 0.0f);
gluSphere(q, 10.0f, 4096, 4096);
glFlush();
}
Another problem I'm having is this part:
case WM_KEYDOWN:
if((wParam >= 0) && (wParam <= 255)){
window->keys->keyDown[wParam] = true;
return 0;
}
break;
Dev-C++ is telling me that this is will allways ">= 0", still just a warning but it's irratic, sometimes it pops up, sometimes it doesn't.
The really annoying this is that all the code is the exact same that I'm using for my other program. NeHe's base code is just copied and the TGA-loader is also just copied.
I'd really appreciate the help :)
Thanks!
Marcus