Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SDL_DisplayFormat not declared in this scope: Using SDL2

Tags:

c++

sdl-2

Compiler doesn't return missing SDL.h, but rather that SDL_DisplayFormat is not declared in scope of a class member function located on a different header even though I have it initialized in main.

SDL_Surface *SpriteLoad::Load(char *File)
{
    SDL_Surface *temp = NULL;
    SDL_Surface *opt = NULL;

    if ((temp = IMG_Load(File)) == NULL)
    {
        return NULL;
    }

    opt = SDL_DisplayFormat(temp);
    SDL_FreeSurface(temp);

    return opt;
}

Where my main inits SDL through a class and member function:

int main (int args, char *argc[])
{
    bool quit = false;

    OnRun Game;           // Class that init's SDL
    Window TestWin;

    GlobalTimer fps;
    TestWin.Debug();

I'm able to create a window using SDL_Window using that Class and also use SDL_GetTick.

EDIT: Headers used for Sprite::Load are currently SDL, SDL_image, SDL_ttf, and SDL_mixer pulled and built from the mercurial repo. I do not think it's a linking error though

like image 584
0X1A Avatar asked Dec 04 '22 10:12

0X1A


1 Answers

The reason you're getting that compiler error is because SDL_DisplayFormat no longer exist in SDL-2.0.

After looking at the SDL wiki doc it appears SDL_DisplayFormat from SDL-1.2 has been replaced by SDL_ConvertSurfaceFormat in SDL-2.0.

like image 104
greatwolf Avatar answered Dec 07 '22 00:12

greatwolf