Programming with SDL

This is a discussion on Programming with SDL within the C++ Programming forums, part of the General Programming Boards category; I'm a beginner, I couldn't find any SDL forums, so I came here for help. I can code a simple ...

  1. #1
    Registered User Erebus's Avatar
    Join Date
    Sep 2005
    Posts
    10

    Smile Programming with SDL

    I'm a beginner, I couldn't find any SDL forums, so I came here for help.
    I can code a simple window, and handle simple mouse clicks and key hits, but that's it. I haven't found any tutorials that talk about anything other than displaying graphics or rendering windows and getting mouse clicks. I also looked in the SDL references.

    What I want to do is make simple applications, such as a text editor, but I have absolutely no idea how to put text boxes or buttons in the program. Another problem is icons, I can put an icon in the window it self, but not as the .exe icon, as you would do with resources and such.

    Can SDL handle buttons, text boxes, and executable icons, among other things? Or do I need another library?

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    Well you COULD make a program that looks just like a regular windows app using SDL, but it's kind of a round-about method. I'd recommend getting a library that's made specifically for making windows apps.

    There's the Win32 SDK, which is free, and quite similar in style to SDL (useable in both C and C++). If you'd like to try that out, google for "Forger's Win32 Tutorial" - depending on your compiler - you may already have the library.

    There are other libraries like MFC, OWL, etc... that you can research if you'd like, but I just use the Win32 SDK - it works in C and C++.

    If you're designing applications with GUIs (Graphical User Interface) in other OSes like Linux, there are other cross-platform libraries for this - a popular choice being qt.

  3. #3
    Registered User Erebus's Avatar
    Join Date
    Sep 2005
    Posts
    10
    I do have Forgers tutorial, and I've done quite a bit of it, but I like SDL better (seems alot easier as well) but I guess I need to just stick with Win32.

  4. #4
    Registered User Erebus's Avatar
    Join Date
    Sep 2005
    Posts
    10
    So, can anyone help with the icon problem?

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    SDL_LoadIcon() or something? Check the documentation.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    Registered User Erebus's Avatar
    Join Date
    Sep 2005
    Posts
    10
    It's actually SDL_WM_SetIcon(), but that's not what I'm talking about.

    SDL_WM_SetIcon sets the icon for the window, I need to know how to set actual executable file's icon.

    I know how to do this with Win32, but not with SDL.

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Select .EXE, ALT-ENTER, Change Icon, Select icon, Ok, Ok. Something like that.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  8. #8
    Registered User Erebus's Avatar
    Join Date
    Sep 2005
    Posts
    10
    First of all, that doesn't work. Secondly, that's still not what I mean.

    Can you use resources with SDL?

  9. #9
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    Erebus, you can use resources if you have a window's compiler but geting SDL(which is fairly platoform independent) to use the Win32 platform dependent resource types would be quite difficult, I think. So, if you just use your resource icons and call win32 functions with them you'll be OK, but if you want to turn a resource icon into a SDL_Surface you'll going to have to a bit of work.

  10. #10
    Registered User Erebus's Avatar
    Join Date
    Sep 2005
    Posts
    10
    I'd like to use the icon resources in a SDL program... Or use Win32 functions to use the icon resources... If that's what you mean.

  11. #11
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    You cane make a Win32 program and then just use SDL for the interface. That would allow you to use SDL for graphics, etc... but still use Win32 resource files like in Forger's.

  12. #12
    Registered User Erebus's Avatar
    Join Date
    Sep 2005
    Posts
    10
    I wouldn't really know how to go about doing that.

  13. #13
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    Having not doen it myself, I too am unsure, but you should be able to just write it like a regular SDL program, and if you need to make windows system calls, just include window.h and call the function. The same should, I believe, apply to the use of resource files, etc...

    Perhaps google may turn up a few tutorials on using SDL in Win32 programs.

  14. #14
    Registered User Erebus's Avatar
    Join Date
    Sep 2005
    Posts
    10
    Alright, figured it out on my own, was very simple, actually.

    Just had to make the resource file, then add it into the project and compile, worked perfectly.

    Thanks for the help though!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. SDL + Newbie
    By Livijn in forum Game Programming
    Replies: 7
    Last Post: 05-01-2007, 12:20 AM
  2. Problems compiling this SDL app
    By Rider in forum C++ Programming
    Replies: 3
    Last Post: 03-27-2007, 01:22 PM
  3. SDL and MinGW Studio
    By Vicious in forum Tech Board
    Replies: 0
    Last Post: 07-30-2004, 10:59 PM
  4. SDL and Windows
    By nickname_changed in forum Windows Programming
    Replies: 14
    Last Post: 10-24-2003, 01:19 AM
  5. sdl in c++
    By Klinerr1 in forum C++ Programming
    Replies: 8
    Last Post: 07-07-2002, 08:46 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21