VC++6.0如何配置SDL环境
1、首先安装好VC6.0,然后下载SDL开发文件包(链接: https://pan.baidu.com/s/1qYD5gWO 密码: zgqn)

2、然后找到VC的安装位置,单击快捷方式,右键,打开文件所在位置,如图:

3、一直点击向上,直到出现VC98那个文件夹,如图:
(路径和图中不一样没关系,有VC98文件夹就行)

4、在…\VC98\Include\”目录下建立SDL文件夹,并将开发包内include文件夹下的所有文件复制到SDL文件夹中。

5、将开发包中lib文件夹下的所有文件复制到“…\VC98\Lib\”目录下。

6、再将lib文件夹下的SDL.dll文件复制到“C:\WINDOWS\system32\”文件夹和“C:\Windows\syswow64”文件夹(64位需要)中。

7、现在,打开VC6.0,新建一个Win32 Console Application类型的空工程;

8、按ALT+F7打开project settings面板,点选C/C++,在分类下拉框下选择Code Generation;

9、在use run-time library下拉框下选择Multithreaded DLL。

10、点选连接,在对象/库模块文本框的内容后面添加SDL.lib和SDLmain.lib(用空格隔开)

11、点击确定返回,新建一个cpp文件,复制贴粘以下内容,如果编译通过则说明配置成功:
#include <stdio.h>
#include <SDL/SDL.h>
#define WIDTH 640
#define HEIGHT 480
#define BPP 4
#define DEPTH 32
void setpixel(SDL_Surface *screen, int x, int y, Uint8 r, Uint8 g, Uint8 b)
{
Uint32 *pixmem32;
Uint32 colour;
colour = SDL_MapRGB( screen->format, r, g, b );
pixmem32 = (Uint32*) screen->pixels + y + x;
*pixmem32 = colour;
}
void DrawScreen(SDL_Surface* screen, int h)
{
int x, y, ytimesw;
if(SDL_MUSTLOCK(screen))
{
if(SDL_LockSurface(screen) < 0) return;
}
for(y = 0; y < screen->h; y++ )
{
ytimesw = y*screen->pitch/BPP;
for( x = 0; x < screen->w; x++ )
{
setpixel(screen, x, ytimesw, (x*x)/256+3*y+h, (y*y)/256+x+h, h);
}
}
if(SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen);
SDL_Flip(screen);
}
int main(int argc, char* argv[])
{
SDL_Surface *screen;
SDL_Event event;
int keypress = 0;
int h=0;
if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 1;
if (!(screen = SDL_SetVideoMode(WIDTH, HEIGHT, DEPTH, SDL_FULLSCREEN|SDL_HWSURFACE)))
{
SDL_Quit();
return 1;
}
while(!keypress)
{
DrawScreen(screen,h++);
while(SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
keypress = 1;
break;
case SDL_KEYDOWN:
keypress = 1;
break;
}
}
}
SDL_Quit();
return 0;
}
