小编ste*_*e3e的帖子

SDL2 鼠标抓取不起作用

在 SDL 1.2 中,我使用 SDL_WM_GrabInput 将(隐藏的)鼠标在屏幕上居中。对于第一人称射击游戏,这给了我无限的转弯自由。SDL2 不再提供此功能,但具有 SDL_SetWindowGrab。这似乎不是在每次循环(事件读取)后将鼠标重新定位到屏幕中心。在鼠标碰到窗口边缘之前,我只能将播放器转动 1 次半,并且不再产生 xrel 值。这是一个错误还是我应该使用其他功能?

mouse events sdl

5
推荐指数
1
解决办法
5499
查看次数

你如何在DMD 2上设置废弃3?

大多数材料都是DMD1和Derelict2.我已经尝试了所有我能想到的东西,而我得到的只是不同种类的垃圾.DMD2安装正常,因为我可以编译hello worlds.我的sc.ini写道:

[Version]
version=7.51 Build 020

[Environment]
LIB="%@P%\..\lib";\dm\lib
DFLAGS="-I%@P%\..\..\src\phobos" "-I%@P%\..\..\src\druntime\import" "-I%@P%\..\..\src\etc"
LINKCMD=%@P%\link.exe
Run Code Online (Sandbox Code Playgroud)

如果没有包含gl3.d的路径(我正在使用Eclipse并且还使用命令shell,Windows XP中的dmd/bud检查)我得到"无法读取gl3.d"错误,这是在路径时修复的被添加到库引用中.

我试图编译的文件是:

import std.stdio;
import derelict.opengl3.gl3;

pragma(lib, "DerelictGL3.lib");

void main(){
    DerelictGL3.load();


    writeln("Fred");

}
Run Code Online (Sandbox Code Playgroud)

如果我注释掉pragma,那么错误是:

OPTLINK (R) for Win32  Release 8.00.12
Copyright (C) Digital Mars 1989-2010  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
bin\Main.obj(Main) 
 Error 42: Symbol Undefined _D8derelict7opengl33gl312__ModuleInfoZ
bin\Main.obj(Main) 
 Error 42: Symbol Undefined _D8derelict7opengl33gl311DerelictGL3C8derelict7opengl33gl317DerelictGL3Loader
--- errorlevel 2
Run Code Online (Sandbox Code Playgroud)

如果我取消注释该编译指示,则错误为:

--------  Build Commands:  --------
-od"bin"
-of"bin\Main.exe"

-I"src"

"src\Main.d"



OPTLINK (R) for Win32  Release 8.00.12
Copyright (C) Digital Mars 1989-2010  All rights reserved. …
Run Code Online (Sandbox Code Playgroud)

d

1
推荐指数
1
解决办法
1058
查看次数

为什么我会得到:错误:在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;
    } …
Run Code Online (Sandbox Code Playgroud)

sdl d

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

d ×2

sdl ×2

events ×1

mouse ×1