Build an sdl Development Environment on vc6

Source: Internet
Author: User

Sdl is known as cross-platform directx and can be used with opengl to develop 3d games,

 

First, go to http://www.libsdl.org/index.php to download the SDK's vcpus. the SDK package contains the development Libraries version, not the Source Code. Of course, you can also download the Source Code and compile it with VC. If it is too troublesome, skip it. directory, these two are the most important, and then go to the installation directory of vc6, usually in C: \ Program Files \ under the Microsoft Visual Studio directory,

Go to the vc98 directory, see the include directory and lib directory, and put the header file and library file downloaded by sdl in these two directories respectively. First, go to the include directory of vc98, create the sdl folder, and then copy the include files in the sdl decompression package to the sdl folder,

Then decompress the sdl package to the sdl under the lib directory. lib and sdlmain. copy the lib file to the lib directory of vc98. Note that the lib directory under the sdl decompression package is divided into x86 and x64 versions. If your development host is 32-bit, copy the x86 folder. in the past, if it was 64-bit, it would be troublesome.

 

Finally, copy the sdl. dll of the corresponding platform to the C: \ WINDOWS \ system32 directory. Now we are done. You can write a small piece of code to test whether the environment is normal,

Create a win32 program in vc6, select "An Empty Project" in the next step, create cpp, and enter the following code

# Pragma comment (lib, "sdl. lib ") # include <windows. h> # include "sdl/sdl. h "int _ stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {if (SDL_Init (SDL_INIT_AUDIO | SDL_INIT_VIDEO) <0) {fprintf (stderr, "Unable to initialize SDL: % s \ n", SDL_GetError (); exit (1);} atexit (SDL_Quit); SDL_Surface * screen; screen = SDL_SetVideoMode (640,480, 16, SDL_SWSURFACE); if (screen = NULL) {fprintf (stderr, "the video mode of 640xlarge cannot be set: % s \ n", SDL_GetError (); exit (1 );} return 0 ;}

 

There will be a window to flash, because there is no loop, if there is no error, it will be a big success,

 

============

Next, let's talk about if your machine is 64-bit, for example, your machine is the 64-bit version of win7, the Environment configuration needs to be changed, but it is still copying the x86 library file, in the 64-bit the installation methods of 32-bit programs, header files, and library files are the same, but the difference is that the dynamic link library is not copied to the windwos/system32 directory, but to windows/syswow64 under the directory, syswow64 is a 32-seat operating system under the 64-bit operating system, so do not see the name of a 64-bit operating system, it is very wrong, inside the 64-bit Library are 32-bit program files, as for further analysis can see Baidu encyclopedia on the resolution (http://baike.baidu.com/view/3403344.htm)

 

Reference:

Http://blog.csdn.net/lukecheng/article/details/2962176

Http://baike.baidu.com/view/3403344.htm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.