EDIT: Earlier, I was passing an SDLTexture by reference to w.Draw([here],0,0 )), and had SDLWindow's Draw function simply invoke SDLTexture's Draw function onto SDLWindow's mScreen (SDLSetVideo) which would indeed be my preferred method, though neither works (not that it's REALLY different here)
The main implementation making use of the code below, is simply: ( w.Render contains only SDL_Flip right now. )
Code: Select all
SDLTexture eye = SDLTexture( "Lucid_Eye_Auras.jpg" );
w.Draw( eye.Surface(), 0, 0 );
w.Render();
Code: Select all
bool SDLWindow::Init()
{
if( SDL_Init( SDL_INIT_EVERYTHING ) < 0 )
return false;
/* AS YOU CAN SEE, mScreen IS BEING PROPERLY SET UP */
if( ( mScreen = SDL_SetVideoMode( mWidth, mHeight, mBPP, mFlags ) ) == NULL )
return false;
SDL_EnableUNICODE( SDL_TRUE );
SDL_WM_SetCaption( mTitle, mIcon );
return true;
}
/* draw function */
void SDLWindow::Draw( SDL_Surface* surface, int x, int y, SDL_Rect *clip )
{
SDL_Rect offset;
offset.x = x;
offset.y = y;
if( ( surface != NULL ) && ( mScreen != NULL ) )
SDL_BlitSurface( surface, clip, mScreen, &offset );
}
Code: Select all
void SDLTexture::Load( std::string filename, Uint32 trans ) // trans = 0xff00ff by default
{
SDL_Surface* loadedSurface = NULL, *optimizedSurface = NULL;
loadedSurface = IMG_Load( filename.c_str() );
if( loadedSurface != NULL )
{
optimizedSurface = SDL_DisplayFormat( loadedSurface );
SDL_FreeSurface( loadedSurface );
SDL_SetColorKey( optimizedSurface, SDL_SRCCOLORKEY | SDL_RLEACCEL, trans );
}
mSurface = optimizedSurface;
}
/* This one is used in other functions, but in particular it's used to get the surface pointer from within the class, in the main implementation */
inline SDL_Surface* Surface(){ return mSurface; }