SDL的VC环境搭建
来源:互联网 发布:exec linux 编辑:程序博客网 时间:2024/05/21 13:50
SDL(simple DirectMedia Layer)是一个可跨平台的开源库,最近由于自己的兴趣,就把它windosXP下的环境搭建了下。PC:Mircrosoft Windows XP Service Pack3Platform:Mircrosoft Visual C++ 6.0SourceCode: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.lib6. 在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++)
{
((unsignedint*)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_Eventevent;
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;
}
本文出自 “Scalpel00” 博客,请务必保留此出处http://scalpel00.blog.51cto.com/1071749/247399
- SDL的VC环境搭建
- WINDOWS下SDL环境搭建
- VC++6.0环境下配置SDL
- 【SDL】 如何在RedHat6.5中搭建SDL开发环境
- SDL的编程与vc
- 玩一玩SDL——环境搭建
- VS2013下SDL开发环境搭建
- VS2013下搭建SDL开发环境
- SDL基础-1、搭建开发环境(CB)
- SDL系列讲解(二) 环境搭建
- 在Windows下搭建QT+SDL环境
- windows环境下eclipse for cpp +sdl+boost+mingw环境的搭建
- [1] ubuntu 16.04下ffmpeg+sdl的开发环境搭建及测试
- SQLite VC环境搭建
- 在VS2010上搭建FFMPEG环境与SDL环境配置
- 搭建SDL 的Android 开发环境,的详细步骤(建立sdl2.0 for Android开发环境)
- Ubuntu14.04搭建FFMPEG + SDL + CodeBlocks开发环境
- SDL2学习笔记1-环境搭建以及Hello SDL
- hdu 4340 树形dp
- 溫度對ccd成像的影響
- MBProgressHUD的使用
- 1、数据预处理(1)
- 第二阶段总结之---生活篇
- SDL的VC环境搭建
- Objective C--解释器模式
- IT人的娱乐--浏览器也可以成为我们的游戏机
- OpenGL ES着色器语言之着色
- 關於數碼相機光圈與景深問題的思考
- eclipse中的快捷键功能
- Android开发--身高体重指数(BIM)计算--添加对话框(Dialog)(Toast界面组件、错误处理try-catch)
- GetModuleFileName& GetCurrentDirectory
- Linux┊理解devfs、sysfs、udev