Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Using OpenGL & SDL Together

  1. #1
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Using OpenGL & SDL Together

    What exactly is involved in using OpenGL with SDL to take care of the rotations, scaling and blending effects one would nowadays task to their GPU?

    How does this work?
    Jason McMillen
    Pascal Game Development
    Co-Founder





  2. #2

    Using OpenGL & SDL Together

    Not much, initialize SDL, setup SDL for OpenGL, push the matrix, rotate, scale, transform as normal, pop matrix, flip and proceed as normal.

    The problem I found was that you can't combine SDL and OpenGL surfaces successfully on all systems. You can find hacks that work on this, that, or some other thing, but not everything. So up front you have to decide on SDL or OpenGL IMHO.

    For this reason I went with pure SDL inside my JumpStart engine, though Project Phoenix uses OpenGL through SDL. You can take a look at that project if you want to see how its done.

  3. #3

    Using OpenGL & SDL Together

    If you have a look at the JEDI-SDL OpenGL demos, I ported one of the nehe 2D games that uses OpenGL. Have a look at the code and play around with it. I think it's Nehe's tutorial 21, the game is called Grid Crazy. C code and explanation can be see here - http://nehe.gamedev.net/data/lessons....asp?lesson=21.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  4. #4
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Using OpenGL & SDL Together

    Thanks Dom, I'll do that.

    Jeremy: Hmm... well that does give me quite a bit to think on. I think I will have to do more research before I make a choice like that though. Going pure OpenGL sounds like I'd have to redo quite a bit of my graphics routines in my game engine. [size=9px](and my already established codebase for all my projects)[/size]
    Jason McMillen
    Pascal Game Development
    Co-Founder





  5. #5
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Using OpenGL & SDL Together

    Ok I've looked a bit at your ported NeHe tutorial.

    Automatically it doesn't compile in Lazarus. But I think that is a no duff. It looks like if I do want to use OpenGL and SDL together I'll have to resolve the SDL & FPC issues first.

    So seeing as how I do use Lazarus and there is an issue here, I might as well see if I cannot help to make JEDI-SDL's gl.pas unit compatable on Lazarus + Win32. [size=9px](I'm using the latest version of Laz 0.9.18 & it uses FPC 2.0.4 and I'm running WinXP Home. Yay me! )[/size]

    Running in Delphi Compatability mode, first error I get is...

    C:\Documents and Settings\WILL\My Documents\Pascal Projects\JEDI-SDLv1.0\OpenGL\Pas\gl.pas(80,2) Fatal: Can't open include file "jedi-sdl.inc"
    So I comment that line out and try again. Next one is on line 1584.

    C:\Documents and Settings\WILL\My Documents\Pascal Projects\JEDI-SDLv1.0\OpenGL\Pas\gl.pas(1584,3) Error: Can't assign values to an address
    Then I get nothing but 49 more just like 'em. [size=9px](debugger stops after this amount)[/size]

    I take it that this is not suported on FPC? What would be the FPC/Lazarus equivalent?
    Jason McMillen
    Pascal Game Development
    Co-Founder





  6. #6
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    Using OpenGL & SDL Together

    Hi WILL

    S2DL (http:\\www.cairnsgames.co.za\files\s2dlv1-10.zip) is already a fully OpenGL and SDL (JEDI-SDL) implementation. It uses OpenGL for all the resizing, rotating and alpha drawing.

    Cheers
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

  7. #7

    Using OpenGL & SDL Together

    Quote Originally Posted by WILL
    Running in Delphi Compatability mode, first error I get is...

    C:\Documents and Settings\WILL\My Documents\Pascal Projects\JEDI-SDLv1.0\OpenGL\Pas\gl.pas(80,2) Fatal: Can't open include file "jedi-sdl.inc"
    I take it that this is not suported on FPC? What would be the FPC/Lazarus equivalent?
    It is all supported under FPC, if you set up the paths correctly. Ensure that the path for the projects include libraries point to where jedi-sdl.inc is located. If you do that, all your other paths are correct it WILL compile using FPC and I assume Laz. I have only ever used FPC to compile these demos and never used Laz.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  8. #8
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Using OpenGL & SDL Together

    Ok I figured out what I was doing wrong. It works in Lazarus just fine.

    2 things to note however...

    1st: Make sure you put the jedi-sdl.pas in the 'Include' path NOT the 'Other Unit Files' path in the Compiler Options settings of your project.

    2nd: Don't forget to turn on Delphi Compatability :doh: Gets me every time.

    :lol:

    I'll see what I can make of this. If it allows me to do ADD/SUB/MUL + Fade/Alpha + Rotate + Scale at the same time then I'm set.


    Thanks William, I'll take a look at S2DL too if I can. Could provide me some more insight.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  9. #9

    Using OpenGL & SDL Together

    Will, you can use the JEDI-SDL stuff w/o Delphi Compat mode, but you have to completely re-write the application. The SDL headers all work fine with no compat mode on . You do have to make a few result to function name switches, but hey it works .

    I've done this for a few of the demos myself, nothing to be proud of so I haven't posted them up. I might have to take the time to throw together a simple SDL sample, but I'm starting to like Lua integration too much, so it would have Lua support in it as well .

  10. #10

    Using OpenGL & SDL Together

    There is {$MODE DELPHI} switch in jedi_sdl.inc, so you don't have to turn on
    delphi comatibility, unless some of your headers does not include jedi_sdl.inc.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •