Moyaa
Moyaa

Reputation: 61

'SDL_SetVideoMode': identifier not found

I have a problem with SDL lib. I'm using VS2012 Ultimate and i was actually using this tutorial: http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index2.php to set everything and i did it step by step few times, but I still have problems this is my code, very simple:

#include <iostream> 
#include <SDL.h>

SDL_Surface * ekran = NULL;

int main (int argc, char *args [] )
{
   SDL_Init( SDL_INIT_EVERYTHING );
   ekran = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE );
   SDL_Flip( ekran );
   SDL_Delay( 2000 );
   SDL_Quit();
   return 0;
} 

and im having this errors:

error C3861: 'SDL_SetVideoMode': identifier not found
error C3861: 'SDL_Flip': identifier not found

Upvotes: 3

Views: 7947

Answers (2)

LastBlow
LastBlow

Reputation: 707

Here below is an example how to replace SDL_SetVideoMode() in SDL2. The old way to init SDL is commented and left along with the new way for comparison purposes. Basically, SDL2 creates a window with a title, then a surface attached to it, while SDL1 creates a surface alone and then calls the window manager to give it a name.

if (SDL_Init(SDL_INIT_VIDEO) < 0) {
    fprintf(stderr, "SDL video init failed: %s\n", SDL_GetError());
    return 1;
}

// SDL_Surface *screenSurface = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_SWSURFACE);

SDL_Window* window = NULL;
SDL_Surface* screenSurface = NULL;

window = SDL_CreateWindow("Sphere Rendering", 
    SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 
    SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);

if (window == NULL) {
    fprintf(stderr, "Window could not be created: %s\n", SDL_GetError());
    return 1;
}

screenSurface = SDL_GetWindowSurface(window);

if (!screenSurface) {
    fprintf(stderr, "Screen surface could not be created: %s\n", SDL_GetError());
    SDL_Quit();
    return 1;
}

// SDL_WM_SetCaption("Sphere Rendering", NULL);

Upvotes: 6

Jonny D
Jonny D

Reputation: 2344

Take a look at that tutorial page again. Your code does not match it (e.g. SDL_SetVideoMode() no longer exists). Your code uses SDL 1.2 and the (updated) tutorial uses SDL 2.0. Are you using an old cached version of that page?

Upvotes: 4

Related Questions