SDL的编程与vc
来源:互联网 发布:易知投资 编辑:程序博客网 时间:2024/06/14 17:33
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://scalpel00.blog.51cto.com/1071749/247399
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++)
{
((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;
}
- SDL的编程与vc
- SDL的VC环境搭建
- SDL编程,选DEVCPP还是VC
- SDL入门教程与socket编程入门教程
- SDL与MFC的混合
- SDL与MFC的混合 .
- SDL编程
- SDL自学教程-SDL的安装与测试
- vc下配置sdl
- VC与matlab的混合编程总结
- SDL图片的旋转与缩放
- VC#与Socket编程
- VC#与安全编程
- SDL编程学习网站
- SDL编程小结
- FFmpeg + SDL 编程基础
- SDL编程初步
- vc进行office(word)编程之一:开启vc与office接口编程的大门
- The Case For Automating Manual Time Tracking
- PagedGeometry使用
- 第一篇 技术路线
- STOP 0X00000018关机蓝屏重启问题
- dd
- SDL的编程与vc
- DirectX编程技术
- DLL线程注入 SetWindowsHookEx complete example source code
- 如何提高自己的Java编程水平
- Windows 脚本清除垃圾
- 08年帮同学写的文档,下载
- 当今之世,最贵的,还是人才
- 清理Windows7通知区域的图标缓存
- 命名空间