Zaki Mirza’s Blog

Icon

… About software and beyond!

Setting up SDL-OPENGL in Visual Studio

And this CG assignment’s been giving some people pain in the gut so i thought okay why not share this with others. hopefully they’ll learn from it. So here goes.

Well the problem lies in the fact that people cant setup SDL and OpenGL together in Visual Studio (6,7,8).

Here are the steps you can follow to make it all work:

Downloading and setting up SDL:

1. For the Easiest way to do this, (on your home PC) download the sdl libraries and headers from www.libsdl.org . extract the file (in my case its: SDL_devel-1.2.11-VC6.zip). hunt the folder where you installled the visual studio. Find the folder (VC98 on VC6… VC7 on .net 2003 and vc8 on .net 2005).

2. in the include folder, create a folder called “sdl” and copy the contents of the “sdl_devel-1.2.11/include” folder ( where you jus extracted the sdl headers). These will be many header files. in other words copy *.* from sdl_devel-1.2.11/include to vc6/include. 🙂

3. in the lib folder (of visual studio) copy *.lib of the “lib” folder in sdl_devel-1.2.11 folder.

4. copy the sdl.dll file in the sdl_devel-1.2.11/lib folder to your windows/system32 folder.
Creating The SDL-OPENGL Project:

1. fireup Visual Studio of your choice.

2. Create a new Windows 32 Console Application. Name it .. i_suck :p

3. Click finish. The visual studio will create a default cpp file with the main() function declared in it.

4. In VC6 goto Project>Settings, in VC7 and VC8 right click the project in the solution explorer and click properties.

5. Under Linker>Input option: include the following libraries:
opengl32.lib glu32.lib sdl.lib sdlmain.lib

6. (OPTIONAL STEP) in the Linker>System option (im not sure if this is in VC6, but it is in VC7. This step is optional. Only if you do not want to show the console window with the graphics window) Set the subsystem to windows (or add /SUBSYSTEM:WINDOWS to the commandline option in the linker). in the linker>advanced option, set the entry point to “mainCRTStartup” or add “/ENTRY:mainCRTStartup” to commandline option of linker.

7. In c/C++ > Code Generation option, set the Runtime Library option to MULTI-THREADED DEBUG DLL.

8. Click ok and the project is setup for opengl and sdl.

The Code:

1. In you code, include the following files:
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <sdl/sdl.h>

Note that the ordering of the file should be right. because gl.h file requires that windows.h be included beforehand.

2. build your code. it should be successful. if it isnt, reconsider the above steps.
The Coding Part:
Do it yourself :p. Read the SDL Documentation that came with the SDL libraries and headers. Its right there in the doc folder :p. And ah yes, it will be very comfy once you switch to Visual Studio .net 2003 (and even more to .net 2005, but .net 2003 is more stable. Thats from my experience and mishi and umar manzoor recommend that as well). I have tested these steps on .Net 2003. ( dunno about VC6, i left using it ages ago). Any problems you find drop in a comment. Yes i do take donations as well :p
 

Filed under: opengl, sdl, Troubleshooter, visual studio

Blog Stats

  • 104,198 landed here so far...
May 2017
M T W T F S S
« Jan    
1234567
891011121314
15161718192021
22232425262728
293031  

tweet

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

RSS Google Shared Items

  • An error has occurred; the feed is probably down. Try again later.

RSS Google Reader Starred Items

  • An error has occurred; the feed is probably down. Try again later.

Top Clicks

  • None