下载MinGW版的文件

http://www.libsdl.org/release/SDL2-devel-2.0.3-mingw.tar.gz

解压放到mysys下面

运行Makefile

mysys的include目录加入了SDL2的头文件目录

lib目录加入了libSDL2.a等文件

复制一份bin目录下的SDL2.dll以备后用

然后复制mysys的indluce目录下的SDL2目录和lib目录下的几个SDL2.a到MinGW的include和lib目录一份

编译IDE依然使用Codeblocks,设置同Ubuntu

http://www.cnblogs.com/kileyi/p/5005002.html

不同的是windows环境源码要加上一句

#undef main

这个在Visual Studio中使用SDL2也要加这句

 #include <iostream>
#include <SDL2/SDL.h> #define WIDTH 640
#define HEIGHT 480
#define BPP 4
#define DEPTH 32 using namespace std; #undef main int main(int argc, char* argv[])
{
SDL_Surface *screen;
SDL_Event event; int keypress = ;
int h = ; if (SDL_Init(SDL_INIT_EVERYTHING) == - ) {
cout << "error: " << SDL_GetError() << endl;
return ;
} SDL_Window* window = SDL_CreateWindow("hello", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, , , SDL_WINDOW_SHOWN);
if (window == NULL){
cout << "Error: " << SDL_GetError() << endl;
return ;
}
SDL_Renderer* renderer = SDL_CreateRenderer(window, -, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (renderer == NULL){
cout << "Error: " << SDL_GetError() << endl;
return ;
} SDL_Surface* surface = SDL_LoadBMP("bk.bmp");
SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, surface);
SDL_FreeSurface(surface); SDL_RenderClear(renderer); //清除屏幕
SDL_RenderCopy(renderer, texture, , ); //把texture画到renderer上
SDL_RenderPresent(renderer); while(!keypress)
{
//DrawScreen(screen, h++);
while(SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
keypress = ;
break;
case SDL_KEYDOWN:
keypress = ;
break;
}
}
} SDL_Quit();
return ;
}

编译可能出现

winapifamily.h: No such file or directory

搜索到这贴,说是SDL2.0.3的一个bug,下载修正的SDL_platform.h文件替换

http://stackoverflow.com/questions/22446008/winapifamily-h-no-such-file-or-directory-when-compiling-sdl-in-codeblocks

https://hg.libsdl.org/SDL/raw-file/e217ed463f25/include/SDL_platform.h

运行提示缺少SDL2.dll

把之前那个SDL2.dll放到测试程序目录下

D:\Program Files\CBProjects\SDL2Test\bin\Debug

运行成功

下一步考虑怎么搞个跨平台工程

Win7 64位 MinGW环境测试SDL2.0.3的更多相关文章

  1. Win7 MinGW环境测试SDL2.0.3

    下载MinGW版的文件 http://www.libsdl.org/release/SDL2-devel-2.0.3-mingw.tar.gz 解压放到mysys下面 运行Makefile mysys ...

  2. Win7 64位 VS2015环境使用SDL2-2.0.4

    之前在VS中使用SDL2,如果只链接SDL2.lib,会提示 error LNK2019: unresolved external symbol _main referenced in functio ...

  3. win7 64位 php环境开启curl服务Call to undefined function

    无法使用curl_init(),一般情况问题可能出在没有去加载php的扩展文件php_curl.dll(windows操作系统),但是检查了一下系统配置,发现,环境下已经将php.ini文件里 ;ex ...

  4. Win7 64位 VS2013环境编译CGAL-4.7

    看到有人在QQ空间感叹编译CGAL配置折腾了一天时间,自己也想试试,虽然并不打算用,但感觉这库也挺有名的,想必日后用得着,于是着手试着编译. 首先是看一下官网的windows下配置说明 http:// ...

  5. Win7 64位 VS2013环境编译Squirrel 3.0.7

    Squirrel是一个类似Lua,但是更面向对象的脚本语言. 国内这个介绍很少,环境配置更是没有任何文章提到,花了点时间搞定了,备忘记录下过程. 首先是下载,写本文时Squirrel最新版本为3.0. ...

  6. Win7 64位 VS2015环境使用qt-msvc2015-5.6.0

    QT下载 http://www.qt.io/download-open-source/#section-2 我用的是 qt-opensource-windows-x86-msvc2015-5.6.0. ...

  7. Win7 64位 VS2013环境cuda_7.5.18的一些坑

    thrust库的sort算法,在x86平台使用就崩溃,x64就没问题,搜了下好像是很早的版本,4开始就有这样的问题了,原因不明. http://stackoverflow.com/questions/ ...

  8. Win7 64位 VS2013环境编译boost1_58_0

    备忘,发现好多不常用的东西不记笔记再想用要重新花时间找,所以试着开始记笔记,写入博客吧. 首先去官网下最新的版本 http://www.boost.org/ 写本文时boost最新版本为1_58_0, ...

  9. LDPY Ghost Win7 64位 纯净自选版 V5.0

    ★ 概述: ☆ 源安装盘是[Windows7_SP1_ULTIMATE]微软官方SP1正式版. ☆ 破解激活WIN7,补丁更新至2013/06/18所有系统安全关键补丁. ☆ 破解 Windows 7 ...

随机推荐

  1. 《IT蓝豹》吹雪花demo,学习android传感器

    吹雪花demo,学习android传感器 吹雪花demo,学习android传感器,嘴巴对着手机底部吹一下就会出现飘着雪花效果. 算是学习android传感器效果.本例子主要是通过android.me ...

  2. iOS点击状态栏返回顶部问题。

    在适配点击状态栏返回顶部的时候,有一个viewcontroller里面有一个UITableView和一个UITextView,UITableView的cell里面没有UIScrollView和UITa ...

  3. information_schema.TABLES

    获取所有表结构(TABLES) SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA='数据库名'; TABLES表:提供了关于数据库中 ...

  4. 关于git中git pull --rebase中的一些坑

    在公司里面,每次我更改完代码,准备pull最新代码时,总是会遇到各种各样的问题.,因为对应的问题不同,解决方法很多.但是比较通用的办法还是有的: git pull --rebase   //报错时 g ...

  5. (转)不停止Nginx服务的情况下平滑变更Nginx配置

    在不停止Nginx服务的情况下平滑变更Nginx配置 1.修改/usr/local/webserver/nginx/conf/nginx.conf配置文件后,请执行以下命令检查配置文件是否正确: /u ...

  6. linux组、用户操作相关

    Linux删除用户组和用户时常用的一些命令和参数.1.从组中删除用户编辑/etc/group 找到GROUP1那一行,删除 A或者用命令gpasswd -d A GROUP2.建用户:adduser ...

  7. linux 定时执行php脚本

    第一种方法: 1.编写shell脚本: shell文件:/home/www/shell/phpshell.php #!/bin/bash while [ true ]; do /bin/sleep 1 ...

  8. 【接口测试】jmeter的使用

    学习地址: https://ke.qq.com/webcourse/index.html#course_id=89002&term_id=100088372&taid=15345918 ...

  9. Linux中多线程信号的处理

    1. 博文:Linux多线程中使用信号-1  http://blog.csdn.net/qq276592716/article/details/7325250 2. 博文:Linux多线程信号总结  ...

  10. WinForm richtextbox 关键字变红色

    private void HilightRichText(RichTextBox control, string hilightString)        {            int nSel ...