I have a problem with my header Surface.h. Which is basically just a set off inline class for SDL_Surface and limited animation. The animation is where my problem is.
I have Graphics.h which is a simple wrapper for some SDL procedures (surface loading, blitting, and freeing).
the line with the error is commented, and in red.
Graphics.h - No problems with this file.
Code:
#pragma once
#include <SDL.h>
#include <SDL_TTF.h>
//
#include "ErrorValues.h"
#include "Surface.h"
namespace varia
{
class Graphics
{
public:
Graphics();
~Graphics();
//Initialize SDL and the display surface
int Init(unsigned int windowWidth = 800, unsigned int windowHeight = 600, bool fullscreen = false,
const char* windowTitle = NULL, unsigned int bgR = 0, unsigned int bgG = 0, unsigned int bgB = 0);
int createSurfaceFromFile(Surface& dst, int tran_r = -1, int tran_g = -1, int tran_b = -1);
void closeSurface(Surface& src);
int drawSurface(Surface& src, SDL_Rect* clip = NULL, unsigned int x_pos = 0, unsigned int y_pos = 0);
int beginScene();
int renderScene();
private:
SDL_Surface* m_screen;
unsigned int m_bgR;
unsigned int m_bgG;
unsigned int m_bgB;
};
}
Surface.h - Error in the Animation class
Code:
#pragma once
//Still surface
namespace varia
{
class Surface
{
public:
Surface(const char* FILE):m_file(FILE),m_surface(NULL)
{};
~Surface()
{
if ( m_surface != NULL )
{
SDL_FreeSurface(m_surface);
m_surface = NULL;
}
};
SDL_Surface*& getSurface()
{
return m_surface;
}
const char* getFile()
{
return m_file.c_str();
}
protected:
std::string m_file;
SDL_Surface* m_surface;
};
class Animation : public Surface
{
public:
Animation();
~Animation();
//If clip does not exist it will create one ( or overwrite ) to the keyID provided
void SetClip(int keyID, int x, int y, int w, int h);
void Animate();
int Show(varia::Graphics* graphics);//Error: 'Graphics' undeclared identifier
private:
//The Animation Timer
Timer* m_timer;
//The region vector
std::map<int, SDL_Rect> clips;
//animation vars
int m_frame;
int m_endFrame;
float m_framesPerSecond;
};
}
This makes no sense. I have Surface.h included before Graphics.h and even if i put #include "Graphics.h" in the Surface.h it won't work. I am lost for a solution.
It will be greatly appreciated if anyone has a insight to my problem.