ste3e
ste3e

Reputation: 1035

why do I get: Error: undefined identifier SDL_SetVideoMode when compiling SDL2 on DMD2

I can find no examples of code running SDL2, and when I try to compile the following code on DMD2 using Derelict SDL2 I get the above error. Is there a new set of procedure for initializing SDL2?

The code is:

import std.stdio;
import derelict.sdl2.sdl;
import derelict.sdl2.types;
import derelict.opengl3.gl3;

private import EventHub;

pragma(lib, "DerelictUtil.lib");
pragma(lib, "DerelictGL3.lib");
pragma(lib, "derelictSDL2.lib");

bool running=true;
SDL_Surface *screen;

class App{
    private EventHub ehub;
    private bool virgin=true;
    private int w=1024, h=768, bpp=24;
    private int flags=SDL_GL_DOUBLEBUFFER;//| SDL_FULLSCREEN

    public void init(){
        initSDL();
    }

    private bool initSDL(){
        if(SDL_Init(SDL_INIT_VIDEO)<0){
            SDL_Quit();
            writeln("Error initializing SDL_Video");
            writeln(SDL_GetError());
            return false;
        }
        writeln("fred");

        SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
        SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
        SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
        SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2);
        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

        screen=SDL_SetVideoMode(w, h, bpp, flags);

        return true;
    }
}

void main(){
    try{
        DerelictGL3.load();
    }catch(Exception e){
        writeln("Error loading GL3");
    }
    try{
        DerelictSDL2.load();
    }catch(Exception e){
        writeln("Error loading SDL");
    }

    App a=new App();
    a.init();
}

The program prints "fred" if the screen=SDL_SetVideoMode(w, h, bpp, flags); statement is commented out, therefore SDL is loading and initializing OK. Does anyone have any clues?

Upvotes: 2

Views: 14434

Answers (1)

Vladimir Panteleev
Vladimir Panteleev

Reputation: 25187

SDL 1.3 (to be released as version 2 when completed) doesn't have a real SDL_SetVideoMode function. (The documentation mentions a compatibility stub, but it's probably absent from Derelict.) See the migration guide for more details.

Upvotes: 5

Related Questions