SDL (Simple DirectMedia Layer) is a cross-platform open source Library, recently, because of its interest, it windosxp under the environment. Pc:mircrosoft Windows XP Service Pack3 platform:mircrosoft Visual C + + 6.0 Sourcecode:sdl-devel-1.2.14-vc6.zip Step 1. Unzip the Sdl-devel-1.2.14-vc6.zip. Copies the SDL.lib SDLmain.lib to the Lib folder in the VC6.0 installation directory after the extracted Lib folder. 2. Copy the SDL.dll to the Windows/system32 directory on the system disk (if you want to transfer the later SDL application to another machine that does not have an SDL environment configured, please copy the SDL.dll together). 3. Create a new SDL directory under the Include folder of the VC6.0 installation directory and copy the files from the sdl-devel-1.2.14-vc6.zip include into the SDL directory below. 4. Open VC6 and create a new PROJECT-&GT;WIN32 application. Open the setting under the project directory, select the code c/c++,category in Generation,use The Run-time library uses the multithread DLL. 5. Continue to select input in Link,category in the setting above and fill in SDL.lib SDLmain.lib 6 in object/library modules. Create a new CPP in the VC project and add it to the project, compile, run. RELATED LINKS 1.SDL http://www.libsdl.org/download-1.2.php test code #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 milliseconds int tick = Sdl_getticks (); Declare a couple of variables int I, J, Yofs, OFS; Draw to Screen Yofs = 0; for (i = 0; i < 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 is called at exit; Makes sure things are cleaned when we quit. Atexit (Sdl_quit);
Attempt to create a 640x480 windows with 32bit pixels. Screen = Sdl_setvideomode (640, 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 |