Jump to content
  • Advertisement
Sign in to follow this  
Teenage Death Boy

Basic OpenGL + SDL setup

This topic is 4802 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok so what I want is to use SDL to handle all the window stuff and input etc, and use OpenGL for drawing my tiles and sprites etc. (2d game, will be using orthographic mode). I'm after some help with how my main.cpp should look like, and how to set it up. I've read a few articles that I could find but all seem to advise different things which confuse me. I think I saw a thread recently (in the past couple of days) either here or in one of the other forums (probably For Beginners) which had the base code to setup the window ready for drawing etc, but can't for the life of me find it, even using the search. So if anyone could point me in the right direction, any links or ideas I would appreciate it

Share this post


Link to post
Share on other sites
Advertisement
Here ya go. Since that's not copy/paste friendly, here's the .cpp file. What you will want to do though is after the code: Screen = SDL_GetVideoSurface(); and before the code SDL_Event Event; where I setup the model display, you will want to use the 2D Ortho code instead there.

Share this post


Link to post
Share on other sites
Take a look at this page; it should answer most of your questions. Post back if you have more specific ones:
http://sdldoc.csn.ul.ie/guidevideoopengl.php

Share this post


Link to post
Share on other sites
Thanks for the help guys. Using Drews code I get the following warning:

Linking...
MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library

My project settings are set as "Use Run Time Library = Debug Multithreaded DLL" and object/library modules is "sdl.lib sdlmain.lib OpenGL32.lib GLaux.lib GLu32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "

I am guessing I did something wrong in one of those sections?

Share this post


Link to post
Share on other sites
Quote:
Original post by Teenage Death Boy
Thanks for the help guys. Using Drews code I get the following warning:

Linking...
MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library

My project settings are set as "Use Run Time Library = Debug Multithreaded DLL" and object/library modules is "sdl.lib sdlmain.lib OpenGL32.lib GLaux.lib GLu32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "

I am guessing I did something wrong in one of those sections?


I sometimes get this, and sometimes I don't. I think my compiler is just being retarded. Notice it's just a warning anyway.

Share this post


Link to post
Share on other sites
Take a look at NeHe lesson 1. Scroll down to the bottom of the page and get the Linux/SDL code for the lesson. Taking a quick look at the code I don't see any reason it wouldn't compile with minor or no changes on windows.

Also take a look through the SDL_opengl.h header (though the documentation currently seems to be pretty nonexistant for it), and if you have the source distribution to SDL look at testgl.c in the test directory

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!