[转载]SDL Setup Guide 1.1

Snaill:图例给得很清楚,就不再翻译了,要住的是,在Application Setting中,如果要作弹出窗体的程序一定要用Window Applicaition选项

Welcome to the SDL Tutorial!

for Visual Studio .NET

Written by


SDL Version is 1.2.5 as of writing this tutorial.

Browse to the lib SDL home page...http://www.libsdl.org
Then click on the download -> SDL 1.2 link.

SDL Homepage

Under the Win32 development libraries, download the latest version of SDL-devel VC6 package.

SDL Download Page

Create a directory in C:/ named LIB_SDL. This will be used to store all your include files, DLL flies, and libraries.
Save the zip file to this directory.

Saving the file

Extract the zip file to the directory, it should create a folder named with the latest version of SDL. If you open the folder, its contents should look similar to this.

Folder after unzipping

Launch Microsoft Visual Studio .NET

Launching Visual Studio

Click on the Tools->Options. Then select the Projects->VC++ Directories. Select "Include Files" from the top right pull down and add the C:/LIB_SDL/SDL-1.2.5/include directory.  

Adding the include path

Select the top right pull down menu again and choose "Library Files". Then add the directory C:/LIB_SDL/SDL-1.2.5/lib.

Now that this is done, the compiler will know where to look for SDL libraries and header files. These settings are global and set as default for every new project.

Adding the lib path

Go to the file menu, and select "New->Project".

Creating the new project

Select the Visual C++ Projects folder, and scroll down and create a Win32 Project.
Enter the name of the project, and the folder where you want to save it and hit OK.

Initial project settings

Select "Application Settings" and change the application type to Console Application
Select "Empty Project" under Additional Options.

Application Settings

Right-click on the name of your project in the Solution explorer and select "Properties".

Project Properties

Select the "code Generation" on the left. On the right, select the "Runtime Library" pull down menu and choose Multi-Threaded DLL or Multi-Threaded Debug DLL if you wish to use debugging. Hit OK.

Choose Multi-Threaded DLL

Right click on the Project name in the solution exploer, and select "Add->Add New Item...".

Add new item...

Select C++ File and name it main, and hit Open.

Create the main file

Copy and paste this source code or manually type it in to the main.cpp file.


/* -- Include the precompiled libraries -- */
#ifdef WIN32
#pragma comment(lib, "SDL.lib")
#pragma comment(lib, "SDLmain.lib")
#endif

#include "SDL.h"

int main(int argc, char **argv)
{
	printf("/nHello SDL User!/n");

	/* initialize SDL */
	if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
	{
		fprintf( stderr, "Video initialization failed: %s/n",
			SDL_GetError( ) );
		SDL_Quit( );
	}
	
	SDL_Quit( );

	return 0;
}


Test code

Select the "Build" menu and choose "Build Solution"

Build the project

You need to copy the SDL.dll file from the lib directory (C:/LIB_SDL/SDL-1.2.5/lib) to your Debug directory where your freshly bulit executable now lays (c:/SDL_Test/SDL_Test/Debug) so the program may run.

Copy the DLL's

From the windows menu, Click "Run" and type cmd, then hit the open button to open a command window. You will use this to run your appication.

Load the commandline

Use cd to change to your directory:

cd C:/SDL_Test/SDL_Test/Debug, then type SDL_Test.exe and hit enter!

Run the program!

Congratulations! You have successfully written, compiled, and run your first SDL program. While this does not use any SDL code, it does show that SDL is successfully installed. You must change the project properties, include the libraries in the code, and copy the dll for every project you make. Use the documentation available on http://sdldoc.csn.ul.ie/ or from the www.libsdl.org main site to create your first programs! Enjoy!

Back to the Purdue Game Development Club
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值