Advertisement

.TGA loading with multiple .cpp files

Started by March 06, 2002 10:07 AM
2 comments, last by Lord FlatHead 22 years, 11 months ago
I'm planning to send in an entry for the LOTR contest and I finally got to the eye candy part of my program yesterday. Turns out the TGA loading code from tutorial 25 doesn't want to work in the framework of my app. Let me explain. I've got a header file called gl_texture.h that includes the following :
  
#ifndef _GL_TEXTURE_H_
#define _GL_TEXTURE_H_

typedef	struct							
{
	GLubyte	*imageData;					
	GLuint	bpp;						
	GLuint	width;						
	GLuint	height;						
	GLuint	texID;						
} TextureImage;

extern TextureImage textures[1];

bool LoadTGA(TextureImage *texture, char *filename);


#endif
   
The code that is supposed to load the textures is in gl_texture.cpp :
  
TextureImage textures[1];

bool LoadTGA(TextureImage *texture, char *filename)
{
 ... all the code from tutorial 25 ...

 return true;
}
   
Problem is, I try to bring up a quad and texture it, and all I get is a white textureless quad. Now, you have to understand I'm not a total newbie at this. I'm including the right header files, I've enabled texture mapping and everything, so it's not a trivial C++ problem. In fact, the exact same code I'm using works just fine if I keep everything in one file (like tutorial 25 does). Yet when put this code over multiple files like this, it stops working. Doesn't give me any errors, it just doesn't work. I'm probably just defining "TextureImage textures[1];" wrong or something... Do any of you people have any idea what I'm doing wrong ? _________ "Maybe this world is another planet''s hell." -- Aldous Huxley Edited by - Lord FlatHead on March 6, 2002 11:08:06 AM
_________"Maybe this world is another planet''s hell." -- Aldous Huxley
You''ve traced through this with your debugger, right?

What''s the memory address of the parameters to the call? Do they match the address in the other C file?

What does the call to open the file return? Etc, etc.
Advertisement
Well you probably don't want to post your contest code, but we need more information than just what you posted to answer your question. I downloaded lesson 25, made a gl_texture.h file identical to yours, recompiled and everything works. If you're getting white quads the problem is most likely in the way you're enabling texturing or lighting... if it was in the texture loading code you should be getting a program crash or garbled textures.

The only other conclusion I can draw from the code you posted is that maybe you used texture[] somwhere you intended to use textures[] or vice-versa... using such similarly named arrays in tutorial 25 was a little confusing.

Edited by - Chromebender on March 6, 2002 4:45:08 PM
Agh. OK, thanks, I''ll give it a thorough look.

_________
"Maybe this world is another planet''''s hell." -- Aldous Huxley
_________"Maybe this world is another planet''s hell." -- Aldous Huxley

This topic is closed to new replies.

Advertisement