Jump to content
  • Advertisement
Sign in to follow this  
SpacedOut

C++ question

This topic is 4871 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

main.h:
[source lang = "cpp"]#ifndef MAIN_H_
#define MAIN_H_

// SDL/OpenGL/C++ Includes
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>
#include <gl/glu.h>
#include <gl/glaux.h>
#include <stdlib.h>

// globals
// booleans
#ifndef TRUE            // are booleans already defined?
typedef int      BOOL;
#define TRUE     1
#define FALSE    0
#endif                  // end booleans

// game state
typedef int         STATE;
#define EXITING     0
#define RUNNING     1
#define PAUSED      2
#define GAMEOVER    3

// Engine Includes
#include "Texture.h"
#include "Engine.h"


#endif
Texture.h
[source lang = "cpp"]// Texture.h
#ifndef TEXTURE_H
#define TEXTURE_H

#include "main.h"


#ifndef GL_BGR
#define GL_BGR 0x80E0
#endif

// texture class
class Texture
{
private:
    unsigned int min_filter;
    unsigned int mag_filter;
    
public:
    Texture();
    
    // general methods
    void LoadTexture(GLuint *texture, char *filename);
    
    // accessor methods
    void SetMinFilter(unsigned int i) { min_filter = i; }
    void SetMagFilter(unsigned int i) { mag_filter = i; }
};

#endif // TEXTURE_H
Engine.h:
[source lang = "cpp"]// Engine.h
#ifndef ENGINE_H_           // main engine class and related declarations
#define ENGINE_H_

// SDL/OpenGL/C++ Includes
#include "main.h"
#include "texture.h"

// Engine Includes

// engine class
class Engine
{
private:
    // window
    int m_width, m_height;
    int m_bpp;
    int m_videoflags;
    
    // sdl stuff
    SDL_Surface *m_screen;

	// opengl stuff
	Texture		*m_texture;
    
    // engine stuff
    STATE m_state;
    
	// private methods
	void ResizeWindow(int width, int height);   // window resized

public:
    // constructors
    Engine();
    Engine(int width, int height, int bpp, int videoflags);
    
    // initialization
    BOOL InitWindow();
    
    // public methods
    void HandleEvents(SDL_Event *event);        // events specific to engine

	// textures
	void EnableTexture(Texture *t);				// enable texturing
    
    // accessor methods
    SDL_Surface *GetScreen() { return m_screen; }
    int GetWindowWidth() { return m_width; }
    int GetWindowHeight() { return m_height; }
    int GetBPP() { return m_bpp; }
    int GetVideoFlags() { return m_videoflags; }
    STATE GetState() { return m_state; }
	Texture *GetTexture() { return m_texture; }
    
    // static quit method, deletes the instance of engine
    static void Quit(Engine *engine, int returnCode);
};

#endif      // end main engine class

for some reason Texture.h and Engine.h can't see each other and I can't figure out why. any help appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by SpacedOut
for some reason Texture.h and Engine.h can't see each other and I can't figure out why. any help appreciated.


What do you mean by can't see each other? Are you having problems compiling? If so, what are the error messages?

Share this post


Link to post
Share on other sites
What does "can't see each other" mean? What is the error that you get? I believe that case matters if you are using Linux, i.e. "Texture.h" != "texture.h".

BTW, in a header file, it is generally better to include only files that are needed by the header file itself. In a small project it might not make much difference, but in a large project putting unnecessary includes in a header file causes problems.

Share this post


Link to post
Share on other sites
c:\documents and settings\blake skinner\my documents\visual studio 2005\projects\opengl_practice\opengl_practice\engine.h(24) : error C2143: syntax error : missing ';' before '*'
c:\documents and settings\blake skinner\my documents\visual studio 2005\projects\opengl_practice\opengl_practice\engine.h(24) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\blake skinner\my documents\visual studio 2005\projects\opengl_practice\opengl_practice\engine.h(24) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\blake skinner\my documents\visual studio 2005\projects\opengl_practice\opengl_practice\engine.h(44) : error C2061: syntax error : identifier 'Texture'
c:\documents and settings\blake skinner\my documents\visual studio 2005\projects\opengl_practice\opengl_practice\engine.h(53) : error C2143: syntax error : missing ';' before '*'
c:\documents and settings\blake skinner\my documents\visual studio 2005\projects\opengl_practice\opengl_practice\engine.h(53) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\blake skinner\my documents\visual studio 2005\projects\opengl_practice\opengl_practice\engine.h(53) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\blake skinner\my documents\visual studio 2005\projects\opengl_practice\opengl_practice\engine.h(53) : warning C4183: 'GetTexture': missing return type; assumed to be a member function returning 'int'
c:\documents and settings\blake skinner\my documents\visual studio 2005\projects\opengl_practice\opengl_practice\engine.h(53) : error C2065: 'm_texture' : undeclared identifier

Share this post


Link to post
Share on other sites
Try removing
// Engine Includes
#include "Texture.h"
#include "Engine.h"

from main.h. There doesn't seem to be any reason to have them there.

Share this post


Link to post
Share on other sites
It is possible that it is including a different file named texture.h. It is also possible that TEXTURE_H is already defined somewhere (perhaps in one of the SDL includes) so the contents of your texture.h are skipped.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!