Jump to content
  • Advertisement
Sign in to follow this  
Manny_D

SDL Tutorials with pure C++ please!

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

Hi! I've been looking up tutorials for SDL and I've noticed that, at least the ones I could find, all of them use plain 'ol C for use with the library. I guess this is understandable since the library was written with it, but, my problem is I have a fairly good knowledge of C++ but very little if any with plain C! If I had to, I can use a reference for looking up C functions and the like, but I think I would be spending half the time that I am right now if there was a good C++ tutorial. If anyone else had this problem that can share a link or has some wisdom to share I'll be thankful. :)

Share this post


Link to post
Share on other sites
Advertisement
I dunno if you've been here, but I really liked the tutorials there. I really don't get what you mean about the differences between C and C++, they are very similiar.

Share this post


Link to post
Share on other sites
When it comes to using a graphical API, using C or C++ should not make much of a difference. And even if there was, C is very not much different from C=+.

Share this post


Link to post
Share on other sites
Thanks for the replys.
I've been using Cone3D tutorials. I've been reading on a tutorial that uses C functions for dealing with C-style strings and file I/O. Those two are not similar to C++. I even thought about changing the code to something more to my liking. I just get a little paranoid writing a program with C++ and having some C-code interchangeably, seems wrong.

Share this post


Link to post
Share on other sites
Maybe I didn't explain myself well. What I meant by saying I know C++ better is that I'm used to seeing the string class used for strings or the fstream class used for file I/O. What I wanted to see was a tutorial about SDL using these mechanics as oposed to the ones usually used in most tutorials which is char * strings or FILE *fp I/O which I'm not familiar with. Not that I am saying that there should be one but if there is one I would like to see if someone has a link. Most of what I learned about C++ is from a book that doesn't dive off into C much so I would give a ton of thanks to anybody who knows. If I never get to find one I swear I will sit down and write one myself, LOL.

Share this post


Link to post
Share on other sites
Hi Manny_D.

First, for your first fear, "char *" strings. Nothing could be much simpler, you can use std::string easily with them. To assign a C-style string to a C++ string, just do it:

std::string bob = my_c_style_string;

It'll work.

When you want to pass a C style string as a parameter, use the c_str() member of std::string.

As for files, though, I'd say just learn them if you need'em. It's really not that hard.

fopen( filename, mode );
fclose()
fseek()
fread()
fwrite()
fflush()

Quite intuitive :)


As for a C++ wrapper for SDL, I'm not sure, but I think I saw this somewhere...

[edit]

I haven't checked it out thoroughly, but it seems like what you're asking for.

http://sourceforge.net/projects/libmgtk

Share this post


Link to post
Share on other sites
I'm working on some SDL tutorials that use C++:
Lazy Foo's SDL tutorials

I still have 4 tutorials to go, but the most important ones are already finished.
I expect to have all the non IDE/compiler specific tutorials finished by the end of the month.

[Edited by - Lazy Foo on August 9, 2007 7:46:30 PM]

Share this post


Link to post
Share on other sites
Thanks for all the useful info. [smile]

I dived a little into some C-style and doesn't seem that hard, although some things give me headaches from just looking at them. I'll check out that wrapper and see if it serves me well, if not I'll guess I will have to just learn a little more C with those tutorials. [smile]

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!