我已经让Derelict3在DMD 2.xx下工作了,但是现在我无法将我的SDL代码从C++移植到D,下面的代码给了我这个错误:
C:\Documents and Settings\Kevin Kowalczyk\My Documents\Code\D\Snippets\Dereli
DL>dmd main.d
main.d(14): Error: undefined identifier SDL_SetVideoMode
main.d(14): Error: undefined identifier SDL_HWSURFACE
main.d(14): Error: undefined identifier SDL_DOUBLEBUF
main.d(15): Error: undefined identifier SDL_WM_SetCaption
main.d(21): Error: cannot implicitly convert expression (SDL_Quit) of type ex
n (C) void function() nothrow to uint
main.d(20): Error: non-final switch statement without a default is deprecated代码如下:
import std.stdio;
import derelict.sdl2.sdl;
pragma(lib, "DerelictSDL2.lib");
pragma(lib, "DerelictUtil.lib");
SDL_Surface Surf_Display;
bool running = true;
void main() {
DerelictSDL2.load();
SDL_Init(SDL_INIT_EVERYTHING);
SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
SDL_WM_SetCaption("Derelict3SDL test", null);
SDL_Event event;
while(running) {
while(SDL_PollEvent(&event)) {
switch(event.type) {
case SDL_Quit:
running = false;
}
}
}
}发布于 2012-05-19 22:35:30
Derelict3使用SDL2,它没有这些函数/标志。
下面是新的接口:http://wiki.libsdl.org/moin.cgi/CategoryAPI
我认为你的新初始化代码应该是:
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Window* window = SDL_CreateWindow("Derelict3SDL test",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480,
SDL_WINDOW_FULLSCREEN|SDL_WINDOW_SHOWN);
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);这是完全没有经过测试的。我只是从SDL wiki复制代码。
https://stackoverflow.com/questions/10665730
复制相似问题