Advertisement

Texture manager?

Started by June 11, 2003 07:16 PM
3 comments, last by Feblex 21 years, 8 months ago
Hi all, I''m trying to make a really simple texture loader so that I can use it in very project I do. What I''ve done is take Nehe''s texture code and stick it into it''s own header file. However, I have a perplexing problem: I''ve done the same thing with the code to render a little room I made (in order to keep my main.cpp file small). My big problem is that I can''t seem to find a way to make it work. I can''t have multiple instances of "Texture.h" included in both my main.cpp and my room.h files- I get the "Already has a body" error. And I can''t do this:


#include "Texture.h"

int RoomRender(GLvoid)
{
  LoadGLTextures();
 // Code to render room
}

 
Because it causes my program to slow way down and run out of resources. I''ve tried putting the LoadGLTextures() outside of the RoomRender thing, but it does not do anything. I realize this is probably confusing, but any help is appreciated!
Are you using inclusion guards within the header?

Examples:

This is Windows specific
#pragma once//Rest of header file 


This is cross platform
#ifndef _HEADER_H_#define _HEADER_H_//Header file contents#endif 
"...."
Advertisement
Are you using "Duplicate header include" protection? (Not sure on the correct word for it...) If you are using VC++ put "#pragma once" at the top of your texture.h file. Otherwise you'll need to do something like the following:

#ifndef _TEXTURE_H_INCLUDED_
#define _TEXTURE_H_INCLUDED_

// The header file contents here

#endif //_TEXTURE_H_INCLUDED_

( Bah I'm too slow )

[edited by - Hawkeye3 on June 11, 2003 8:23:11 PM]
Already has a body? Do you have the function definition (as opposed to the declaration) in the header?

Definition = This is the function called X (where you write the function).
Declaration = There is a function called X (where you write the prototype).


Why you shouldn''t use iostream.h - ever! | A Good free online C++ book
Whoohoo! Thanks a lot guys. All answers were correct

This topic is closed to new replies.

Advertisement