I really thought that syntax errors were behind me, but Visual Studio 2008 just served me a cold plate of humble pie.
I am getting the errors:
videosystem.h(27) : error C2065: 's' : undeclared identifier
videosystem.h(27) : error C3867: 'lichen::VideoSystem::Screen': function call missing argument list; use '&lichen::VideoSystem::Screen' to create a pointer to member.
And here is the offending code:
ScreenPtr SetVideoMode(int width, int height, int bpp,
bool useHw = false, bool fs = false) {
unsigned flags = 0;
if(useHw)
flags |= SDL_HWSURFACE;
else
flags |= SDL_SWSURFACE;
if(fs)
flags |= SDL_FULLSCREEN;
flags |= SDL_DOUBLEBUF;
SDL_Surface* scr = SDL_SetVideoMode(width, height, bpp, flags);
ScreenPtr temp (new Screen(scr));
screen = temp;
return screen;
}
And here are the Screen and Surface classes:
class Screen : public Surface {
public:
~Screen() {} //a screen doesn't release its backbuffer when it's destroyed
Screen() {}
Screen(SDL_Surface* screen) { this->sdlSurface = screen; this->created = true; }
void Flip() { SDL_Flip(sdlSurface); }
void Clear() { SDL_FillRect(sdlSurface, NULL, 0); }
};
typedef boost::shared_ptr <Screen> ScreenPtr;
class Surface {
public:
Surface() {}
Surface(SDL_Surface* toWrap) : sdlSurface(toWrap), created(true) {}
Surface(int width, int height, int bpp) { Create(width, height, bpp); }
virtual ~Surface() { Destroy(); }
void Create(int width, int height, int bpp)
{ SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, bpp,
RMASK, GMASK, BMASK, AMASK);
created = true; }
void Destroy() { if(created) SDL_FreeSurface(sdlSurface); }
const SDL_Surface* SdlSurface() const { return sdlSurface; }
void BlitFrom(SDL_Surface* src, const SDL_Rect& srcRect,
const SDL_Rect& dstRect);
void BlitTo(Surface& surface, const BlitRect& blitRect) const;
void BlitTo(Surface& surface) const;
void Magnify(int magFactor);
//assumes 32-bits. Other depths will be added later if needed
void SetPixel(int pixRow, int pixCol, const Pixel& pix);
Pixel GetPixel(int row, int col) const;
void FillRect(int row, int col, int rows, int cols, const Pixel& pix);
int BitsPerPixel() const { return sdlSurface->format->BitsPerPixel; }
int Width() const { return sdlSurface->w; }
int Height() const { return sdlSurface->h; }
void Copy(const SDL_Surface* other)
{ SDL_BlitSurface((SDL_Surface*)other, NULL, sdlSurface, NULL);
created = true; }
void Copy(const Surface& other) { Copy(other.SdlSurface()); created = true; }
Surface& operator = (const Surface& other) { Copy(other); return *this; }
protected:
SDL_Surface* sdlSurface;
bool created;
};
typedef boost::shared_ptr <Surface> SurfacePtr;
This has me confused. I can't even use Screen* s = new Screen(), I get the same error. I have no problem creating surfaces, just screens.
Also, why is it that when I change the Screen constructor from
Screen(SDL_Surface* screen) { this->sdlSurface = screen; this->created = true; }
to
Screen(SDL_Surface* scr) sdlSurface(scr), created(true) {}
I get a ton of errors, the top of which is:
screen.h(14) : error C3646: 'sdlSurface' : unknown override specifier
When sdlSurface is clearly an inherited member.
Thanks for any help!
Edit: Also, I meant to put this in General Programming. Sorry about that.