Java里mode能不能做标识符_sdl - 为什么我得到:错误:在DMD2上编译SDL2时出现未定义标识符SDL_SetVideoMode - 堆栈内存溢出...

我找不到运行SDL2的代码示例,当我尝试使用Derelict SDL2在DMD2上编译以下代码时,出现上述错误。 是否有一套用于初始化SDL2的新过程?

代码是:

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();

}

如果screen = SDL_SetVideoMode(w,h,bpp,flags),程序将打印“ fred”。 语句被注释掉,因此SDL正在加载并初始化OK。 有人有任何线索吗?

你可能感兴趣的:(Java里mode能不能做标识符_sdl - 为什么我得到:错误:在DMD2上编译SDL2时出现未定义标识符SDL_SetVideoMode - 堆栈内存溢出...)