C and SDL for a beginner

This is a discussion on C and SDL for a beginner within the C Programming forums, part of the General Programming Boards category; Hi, I have been programming in C for a while now as an Mech eng student, so its all been ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    190

    C and SDL for a beginner

    Hi,

    I have been programming in C for a while now as an Mech eng student, so its all been calculations and stuff up to now, but I have recently wanted to be able to add basic graphics. I have installed FINALLY after a lot of hell the SDL libraries and it all works in Codeblocks - the editor i am using.

    I am struggling to find a way to draw to the screen for instance just a box around Hello World! would get me on my way, the graphics dont need to be animated, but i cant find a decent tutorial for C anywhere. Please can someone help me with a basic tamplate c file that will draw a box say 2 pixels thick around a printf statement, just to get it to look a bit nicer.

    P.S is C dieing out because everytime i do a search for C SDL tutorials, they seem to all really be in C++???

    Thanks

  2. #2
    Registered User
    Join Date
    Feb 2009
    Posts
    138
    P.S is C dieing out because everytime i do a search for C SDL tutorials, they seem to all really be in C++???
    searching for c anything is hard because it's a bad keyword. c++ gives more results and a lot of c++ stuff can be used or translated to c without a problem. c isn't dying out, it's still going strong. the c++ cabal just wants you to think it is so you'll join the dark side.

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    190
    cheers, can you help with my other question?

  4. #4
    Registered User
    Join Date
    Feb 2009
    Posts
    138
    no, that's why i didn't answer it.

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    google for "simple SDL example" gives this:
    http://friedspace.com/SDLTest.c

    I don't know if that's helpful or not.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    Registered User
    Join Date
    Apr 2008
    Posts
    190
    Cheers but he uses C++ there i think...

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,914
    Quote Originally Posted by a.mlw.walker
    Cheers but he uses C++ there i think...
    It looks like perfectly valid C to me.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by laserlight View Post
    It looks like perfectly valid C to me.
    Not only do I agree, but "gcc -Wall -Wextra -ansi -pedantic sdl.c" compiles fine - which means that gcc thinks it's ANSI C too. [ok, two warnings for argc and argv not being used - but that's not a "this is not ANSI" warnings].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    In my head happyclown's Avatar
    Join Date
    Dec 2008
    Location
    In my head
    Posts
    391
    Quote Originally Posted by a.mlw.walker View Post
    I have installed FINALLY after a lot of hell the SDL libraries and it all works in Codeblocks - the editor i am using.
    I've never heard of SDL before, but if it can do graphics and sound, I am interested.

    I am going to install SDL, but can you tell me what problems you had with that?

    Thanks in advance.

    EDIT: I am using Win XP
    OS: Linux Mint 13(Maya) LTS 64 bit.

  10. #10
    Registered User
    Join Date
    Apr 2008
    Posts
    190
    Basically (also using xp) i installed codeblocks with mingw and then followed this tutorial for SDL:

    http://lazyfoo.net/SDL_tutorials/lesson01/index.php

    the rest of the tutorials are for c++ but that one is very good.

    its not too bad SDL been having a look

Popular pages Recent additions subscribe to a feed

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