转载于:https://blog.51cto.com/scalpel00/247399
【SDL的编程】VC环境搭建,摩托xt701
cpugpu芯片开发光刻机
开发者生态
11
文件名:【SDL的编程】VC环境搭建,摩托xt701
【SDL的编程】VC环境搭建
SDL(simple DirectMedia Layer)是一个可跨平台的开源库,最近由于自己的兴趣,就把它windosXP下的环境搭建了下。 PC:Mircrosoft Windows XP Service Pack3 Platform:Mircrosoft Visual C++ 6.0 SourceCode:SDL-devel-1.2.14-VC6.zip 步骤 1. 解压SDL-devel-1.2.14-VC6.zip.将解压后的lib文件夹里把SDL.lib SDLmain.lib拷贝到VC6.0安装目录的lib文件夹下面。 2. 将SDL.dll拷贝到系统盘的WINDOWS/SYSTEM32目录下(如果你要将之后生成的SDL应用程序转移到其他没有配置SDL环境的机器上用的话,请将SDL.dll一起拷贝)。 3. 在VC6.0安装目录的include文件夹下面新建一个SDL的目录,并将SDL-devel-1.2.14-VC6.zip解压后的include里的文件拷贝到这个SDL目录下面。 4. 打开VC6,新建一个project->win32 Application.打开project目录下面的那个setting,选中C/C++,Category里选中Code Generation,Use run-time library使用Multithread DLL. 5. 继续在上面的setting中选中Link,Category里选中input,在Object/library modules中填入SDL.lib SDLmain.lib 6. 在VC项目中新建一个cpp,并添加到项目中,编译,运行. 相关链接 1.SDL http://www.libsdl.org/download-1.2.php 测试代码 #include <stdlib.h> #include "SDL/SDL.h" SDL_Surface *screen; void render() { // Lock surface if needed if (SDL_MUSTLOCK(screen)) if (SDL_LockSurface(screen) < 0) return; // Ask SDL for the time in milliseconds int tick = SDL_GetTicks(); // Declare a couple of variables int i, j, yofs, ofs; // Draw to screen yofs = 0; for (i = 0; i < 480; i++) { for (j = 0, ofs = yofs; j < 640; j++, ofs++) { ((unsigned int*)screen->pixels)[ofs] = i * i + j * j + tick; } yofs += screen->pitch / 4; } // Unlock if needed if (SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen); // Tell SDL to update the whole screen SDL_UpdateRect(screen, 0, 0, 640, 480); } // Entry point int main(int argc, char *argv[]) { // Initialize SDL's subsystems - in this case, only video. if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); exit(1); } // Register SDL_Quit to be called at exit; makes sure things are // cleaned up when we quit. atexit(SDL_Quit); // Attempt to create a 640x480 window with 32bit pixels. screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE); // If we fail, return error. if ( screen == NULL ) { fprintf(stderr, "Unable to set 640x480 video: %s\n", SDL_GetError()); exit(1); } // Main loop: loop forever. while (1) { // Render stuff render(); // Poll for events, and handle the ones we care about. SDL_Event event; while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_KEYDOWN: break; case SDL_KEYUP: // If escape is pressed, return (and thus, quit) if (event.key.keysym.sym == SDLK_ESCAPE) return 0; break; case SDL_QUIT: return(0); } } } return 0; }
同类推荐
-

【PTA刷题+代码+详解】求二叉树度为1的结点个数(递归法),声卡报价(pta二叉树度为2的结点求和)
查看 -

【QT】QGraphicsView和QGraphicsItem坐标转换,诺基亚c5-04(诺基亚qt组件)
查看 -

【Qt控件之微调框、进度条】QSpinBox、QDoubleSpinBox、QDial、QProgressBar介绍及使用,对联网
查看 -

【Qt高阶】老Qt都不一定清楚的“QObject线程亲和性”【2023.08.13】,硕美科g945
查看 -

【RK3399Pro学习笔记】十七、Debian安装ORB-SLAM3和单目demo的运行,vivoxshot(debian安装omv和直接安装omv)
查看 -

【RNA structures】RNA-seq 分析- RNA转录的重构和前沿测序技术,三星i728
查看 -

【RTP】4: 实例解析:一个SRTP的wireshark抓包:带padding、带扩展,htc inspire
查看 -

【React Hooks】useReducer(),诺基亚情侣手机
查看 -

【Redis】Redis作为缓存,够了够了已经高C了(redis用作缓存)
查看
控制面板
网站分类
搜索
最新留言
文章归档
网站收藏
友情链接