• Advertisement

Archived

This topic is now archived and is closed to further replies.

Can anyone give me an example?

This topic is 5947 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

can anyone posy or give me a link that shows how to create a basic OpenGL window with SDL? i would really appreciate it thx "Those who serve no purpose, have no purpose"

Share this post


Link to post
Share on other sites
Advertisement
I don''t know any links and I''m not gonna post straight from someone elses copywrited material , but check out the book called Linux Game Programming. Its not too expensive and it covers SDL with OpenGL.
~Thek

Share this post


Link to post
Share on other sites
Umm... if the OpenGL book was written for Windows, it would use the Windows API, not SDL.
Trust me, you can ignore all the Linux stuff if you want and just stick with the SDL and OpenGL part. I''m not in to Linux programming myself, but it may be a topic you''ll want to explore later anyway. And as I said, I highly doubt you''ll find a Windows centered graphics book discussing SDL in any detail at all. SDL is often used for porting code from Windows to other operating systems, namely Linux or for making an open-OS program in the first place. Windows is not open-OS .

The Long and the Short: If you want to learn SDL, you''re gonna have to look at books centered on the 10% of operating systems that aren''t Windows.

~Thek

Share this post


Link to post
Share on other sites
heh i suppose ure right

time to find a bootleg copy of the book cuz im poor

"Those who serve no purpose, have no purpose"

Share this post


Link to post
Share on other sites
It's really simple to setup an SDL window for OpenGL rendering (all you really need to know is in the docs at www.libsdl.org).
This is an example:

          
SDL_Init(SDL_INIT_VIDEO);

// Set some attributes for the OpenGL rendering context.

// Look in the docs to see what other attributes there are.

// These are mostly treated as hints.

SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

SDL_SetVideoMode(640, 480, 16, SDL_RESIZABLE | SDL_OPENGL);

// now we have a window to render in, so just setup

// an SDL event loop and start rendering stuff here...


// We must swap buffers using this function instead of the windows standard SwapBuffers

SDL_GL_SwapBuffers();

Of course you should add some error-checking and stuff.

Edited by - Dactylos on October 7, 2001 1:48:18 PM

Share this post


Link to post
Share on other sites
ic interestin...

can I still use the nehe code besides the windows specific stuff?

"Those who serve no purpose, have no purpose"

Share this post


Link to post
Share on other sites
You can use any OpenGL code to render in a window setup by SDL.
I think most of the NeHe tutorials are ported to SDL, look at the bottom of the tutorial pages for the download labeled "Linux/SDL". I haven''t tried running the SDL ports on Windows, but they should work, as long as they only use SDL and OpenGL.

Share this post


Link to post
Share on other sites
Just remember that the depth buffer (and other buffers) need to be setup before you call SDL_SetVideoMode. It''s the same as the Win32 API in that respect. Other than that, he''s right, you can use the NeHe code. Remember that most of NeHe''s tutorials are ported to SDL also.

[Resist Windows XP''s Invasive Production Activation Technology!]

Share this post


Link to post
Share on other sites
hehe what do you know, its there


what SDL files do i d/l?
the runtime and development ones for win32?


and where do i unzip them?


thx

"Those who serve no purpose, have no purpose"

Share this post


Link to post
Share on other sites
Download the developer files for whatever compiler you have, of course for Windows, since that's what you're using. Put the in your compiler's include and lib folders. Download the runtime files and put them in one of two places: (a) The same folder as your program's executable, or (b) the Windows system folder.

[Resist Windows XP's Invasive Production Activation Technology!]

Edited by - Null and Void on October 7, 2001 2:37:44 PM

Share this post


Link to post
Share on other sites
i did that but i cant compile the first nehe tut

it says SDL.h does not exist

do i have to include a lib or something?

"Those who serve no purpose, have no purpose"

Share this post


Link to post
Share on other sites
that is what i have
i have the correct files but it still wont work

"Those who serve no purpose, have no purpose"

Share this post


Link to post
Share on other sites
argh forget it, ill use win32
im more used to it anyway

thx for trying to help guy

"Those who serve no purpose, have no purpose"

Share this post


Link to post
Share on other sites

  • Advertisement