MacOS 塞拉利昂
?  fun_python $ pip --version
pip 9.0.1 from /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (python 3.5)
pip install pygame给我以下错误:src/scrap.c:27:10: fatal error: 'SDL.h' file not found, error: command '/usr/bin/clang' failed with exit status 1, #include "SDL.h"。我在/usr/include/...文件夹树下没有看到这个 SDL/SDL.h 文件。
给了我以下错误。
?  fun_python $ pip install pygame
Collecting pygame
  Downloading pygame-1.9.3.tar.gz (3.0MB)
    100% |????????????????????????????????| 3.0MB 490kB/s
Installing collected packages: pygame
  Running setup.py install for pygame ... error
    Complete output from command /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/private/var/folders/lx/smky81v534q9ydghqkjbkqv80000gp/T/pip-build-to90wzsv/pygame/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', …我正在尝试在 Xcode 11.2.1 上使用 SDL2 和 C++ 制作一个简单的游戏;但是,我的进度因错误而停止。
遇到这些错误所需要的只是初始化 SDL。只是调用这个函数会导致程序崩溃:
SDL_Init(SDL_INIT_EVERYTHING);
给出这些错误:
Westerino[16795:847932] Metal API Validation Enabled
Westerino[16795:848288] flock failed to lock maps file: errno = 35
Westerino[16795:848288] flock failed to lock maps file: errno = 35
Westerino[16795:847932] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x102157f00> F8BB1C28-BAE8-11D6-9C31-00039315CD46
Westerino[16795:847932]  HALC_ShellDriverPlugIn::Open: Can't get a pointer to the Open routine
Westerino[16795:847932]  HALC_ShellDriverPlugIn::Open: Can't get a pointer to the Open routine
我尝试清除缓存、清理构建、删除首选项、重新安装框架等,但还没有任何帮助。
当我更新 Xcode 时,这些问题似乎已经开始,但我无法确认。
我正在开始一系列关于SDL的教程.在我挖掘太多之前,我想知道SDL通过GLUT给我的控制类型是什么?
此外,是支持网络摄像头访问(用于面部跟踪还是运动检测),还是通过OpenCV进行最佳管理?
使用SDL 1.3我想在linux下创建假的全屏SDL_Window.如果我只有一个显示器很容易.我刚刚获得当前显示模式并创建了一个窗口.
SDL_GetDesktopDisplayMode(0, &mode);
SDL_Window *win = SDL_CreateWindow("my window",
    0,0,mode.w, mode.h,
    SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS );
但是当我有两个显示器时,事情会变得复杂.窗口分布在多个监视器上.SDL只能看到一个双倍大小的虚拟显示器.
我用这段代码测试了它
int num = SDL_GetNumVideoDisplays();
for( int i=0; i < num; i++ )
{
    SDL_Rect displayRect;
    SDL_GetDisplayBounds( i, &displayRect );
    std::cout
        << "display " << i << ": x,y,w,h("
        << displayRect.x << ", "
        << displayRect.y << ", "
        << displayRect.w << ", "
        << displayRect.h << ")"
        << std::endl;
}
输出:
display 0: x,y,w,h(0, 0, 2960, 1050)
但我有两个显示器(1680x1050和1280x1024).
如何强制窗口只保留一个(假设主要)显示?
我正在Haskell中编写一个小型RTS游戏,现在是时候为它创建一些GUI(按钮,菜单等).但是,我没有任何GUI工具包创建经验,所以我要感谢有关如何选择正确的数据类型,事件处理例程等的想法.
所需功能:菜单屏幕(主要,加载/保存,设置,网络游戏),文本输入,游戏界面(主屏幕(C&C)),按钮,选择和复选框.
我当前的方法是将整个GUI表示为一个状态机,它在它们之间有许多状态和转换,当事件到达时触发它们:
-- Local client state.  Actual game state is stored on the server
-- and is updated/synced separately.
data ClientState = […]
-- Keyboard state, mouse state, quadtree of clickables, list of
-- widgets.
data UIState = […]
uiCycle :: UIState -> ClientState -> IO ()
uiCycle uiState clientState = do
  event <- waitEvent
  let widget = findWidget uiState event
  let (uiState', clientStateAction, ioAction) =
        uiTransition widget event uiState clientState
  -- Update game state (execute game logic).
  let …我不知道为什么这段代码不起作用.所有的源文件都编译好了,但是当我尝试链接它们时,编译器会因为未定义的引用错误而对我大喊大叫.这是代码:
main.cpp中:
#include "SDL/SDL.h"
#include "Initilize.cpp"
int main(int argc, char* args[]) 
{
    //Keeps the program looping
    bool quit = false;
    SDL_Event exit;
    //Initilizes, checks for errors
    if(Initilize::Start() == -1) 
    {
        SDL_Quit();
    }
    //main program loop
    while(quit == false) 
    {
        //checks for events
        while(SDL_PollEvent(&exit)) 
        {
            //checks for type of event;
            switch(exit.type) 
            {
                case SDL_QUIT:
                quit = true;
                break;
            }
        }
    }
    return 0;
}
Initilize.h:
#ifndef INITILIZE_H
#define INITILIZE_H
#include "SDL/SDL.h"
/* Declares surface screen, its attributes, and Start(); */
class …我正在使用OpenGL 3.2核心配置文件处理SDL2应用程序.编译时,我收到以下警告:
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:5:2:警告:#warning gl.h和gl3.h都包括在内.如果使用已删除的OpenGL功能,编译器将不会调用错误.[-Wcpp]
我必须假设SDL在某处包含gl.h,因为我的唯一包括如下:
#define GL3_PROTOTYPES
#include <OpenGL/gl3.h>
#include <SDL2/SDL.h>
虽然我可以简单地忽略这一点,但是当我意外地使用核心配置文件中没有的枚举值时,它已经导致了一个难以发现的错误.有没有办法阻止gl.h被包括在内?
刚刚从SDL1.2跳转到SDL2,转换了我的代码,但无法弄清楚如何调整窗口大小.这是我现在的代码:
SDL_DestroyWindow(Window);
Window = SDL_CreateWindow("Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, ScreenSizeX, ScreenSizeY, SDL_WINDOW_SHOWN);
screen = SDL_GetWindowSurface(Window);
你可以看到只是破坏窗口并创建一个新窗口.邋but但它的工作原理.我想要的只是调整窗口大小,是否可能?
   #include "SDL2/SDL.h"
   int main(int argc, char* args[])
   {
       SDL_Init(SDL_INIT_EVERYTHING);
       SDL_QUIT();
       return 0;
  }
我已经通过debian存储库安装了SDL2,我正在运行
g++ -o test.cpp a.out -lSDL2 
我收到了很多错误:
a.out:(.rodata+0x0): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o:(.rodata.cst4+0x0): first defined here
a.out: In function `data_start':
(.data+0x8): multiple definition of `__dso_handle'
/usr/lib/gcc/x86_64-linux-gnu/4.7/crtbegin.o:(.data+0x0): first defined here
a.out: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crti.o:(.fini+0x0): first defined here
a.out: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o:(.text+0x0): first defined here
a.out: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crti.o:(.init+0x0): first defined …(我正在使用SDL2)
SDL是一个相对较小的库,用于"通过OpenGL和Direct3D低级访问音频,键盘,鼠标,操纵杆和图形硬件". 它用于游戏开发,在我的例子中,用作简单的视听输出和鼠标+键盘输入.它不是像GTK,Qt,wxWindows等"工具包".但它是跨平台的.
但我能找到绘制形状的唯一方法是使用line,rect和pixel函数.
除了使用trig或"圆的方程"之外,我怎样画一条曲线?一般矢量图形怎么样?
SDL是一个合适的起点还是我应该在其他地方寻找?