2

已经有几个问题了,但是所有的提问者,可以这么说,比我高一级。我只知道这里有一些下载链接我可能应该下载SDL-1.2.15-win32-x64.zip(64 位 Windows)以匹配我的系统和SDL-devel-1.2.15-mingw32.tar.gz (Mingw32)来匹配我的编译器。怎么办?开发档案包含一些 C++ 项目,我不知道该怎么处理它。要包括哪些文件?链接器中要链接哪些文件?

编辑:

信息

系统:Windows 7x64
IDE:代码::块编译器:G++

4

3 回答 3

5

所以我的问题的实际答案只是这个傻瓜手册的链接:http: //lazyfoo.net/SDL_tutorials/lesson01/index.php
在这里任何人都可以选择他的环境来获得帮助。我对这个答案没有任何贡献 - @Ergo Proxy 已将其发布为对我的问题的评论。但这正是我所需要的。

于 2013-02-01T14:17:47.350 回答
3

这似乎是一个好的开始:使用 SDL2 创建应用程序窗口。您只需链接静态 sdl.lib(或 sdl2.lib,如果您拥有最新版本的 SDL)。尝试编译并执行它。

#include <SDL2/SDL.h>
#include <iostream>

int main(int argc, char* argv[]){

  SDL_Init(SDL_INIT_VIDEO);   // Initialize SDL2

  SDL_Window *window;        // Declare a pointer to an SDL_Window

  // Create an application window with the following settings:
  window = SDL_CreateWindow( 
    "An SDL2 window",                  //    window title
    SDL_WINDOWPOS_UNDEFINED,           //    initial x position
    SDL_WINDOWPOS_UNDEFINED,           //    initial y position
    640,                               //    width, in pixels
    480,                               //    height, in pixels
    SDL_WINDOW_SHOWN|SDL_WINDOW_OPENGL //    flags - see below
  );

  // Check that the window was successfully made
  if(window==NULL){   
    // In the event that the window could not be made...
    std::cout << "Could not create window: " << SDL_GetError() << '\n';
    return 1;
  }

  // The window is open: enter program loop (see SDL_PollEvent)

  SDL_Delay(3000);  // Pause execution for 3000 milliseconds, for example

  // Close and destroy the window
  SDL_DestroyWindow(window); 

  // Clean up
  SDL_Quit(); 
  return 0;   

}
于 2013-02-01T12:34:24.207 回答
0

我已经在 Visual Studio 上安装了 SDL。这很容易,你最好使用它,因为它不需要 mingw。访问 SDL 网站并下载 SDL-devel-1.2.15-vc.zip 包。然后将其提取到您的系统中。然后打开你的Visual Studio,在“VC 目录”部分进入你的项目属性,你应该设置SDL地址。将 SDL\lib 添加到“lib 目录”,将 SDL\include 添加到“包含”。在此之后,在项目属性中转到链接器\输入,然后将“SDL.lib”添加到它的第一个属性中。毕竟你可以用它编译你的代码。

于 2013-02-01T12:42:22.073 回答