Skip to main content
gamedev.net
🔒 Locked

SDL Questions

Started by boone Feb 20, 2001 at 9:39 AM 6 replies 700+ views
Original Post
boone
boone
Hi, I''ve downloaded SDL to both my PC and the iMacs we use at school. We use Codewarrior on both platforms. Now, SDL is written in C, and I only know C++, but the site says that it will function correctly within C++. Now, the documentation for SDL that comes with it, is all for C. Its not completely different, but its different enough that I can''t get the things to work correctly. Do you guys know of any places that explain how to take advantage of the graphics capibilities of SDL within C++, and perhaps a tutorial on how to blit and use surfaces? I''m learning, and I appreciate your patience with my questions, and your time, too. Any ideas?
Prefect
Prefect
Uhh? What is your problem? It really doesn''t matter whether you''re writing a game in C or C++. The way you use SDL is always the same, SDL just won''t use any of the C++ extensions, but that doesn''t hurt...

Remember, anything (well, almost) that works with C can be implemented in C++ the exact same way. You just don''t take advantage of the C++ extensions.

If you really can''t get it to work, then just take one of the examples (in the test/-directory of the source release) and try it. Then you just copy it and rename it to a .cpp-file. Make sure the C++-compiler is actually used. Then you just build on the existing code to write your program.
Of course it won''t be fully OOPed, but why should it be? Game programmers shouldn''t be all-OOP maniacs

cu,
Prefect

---
Sanity is the trademark of a weak mind.
Widelands - laid back, free software strategy
boone
boone
I''m sorry I didn''t explain it well enough. I understand perfectly what C is, and what C++ is, and beyond the OO extensions there are also lots of syntax differences. Lots of them. I did exactly that; I copied a segment of code into my compiler, and I linked the library path, and did everything right, but I got like 3000 errors. Literaly. I''m sure I could hammer away at it for the next couple weeks and understand it, but I thought that that was what these forums were for. I really only wanted to draw from your experience, because I honestly don''t understand it thatt well. I''ve never used a library like this, or any kind of SDK. I''m new, and I want to learn, and it dissapoints me to have resistance from you guys about that.

Prefect
Prefect
quote:

I''m sorry I didn''t explain it well enough. I understand perfectly what C is, and what C++ is, and beyond the OO extensions there are also lots of syntax differences. Lots of them.



This doesn''t change the fact that you can easily compile a C program with a C++ compiler. The only possible problems are with linking (due to the C++ name mangling) as pouya already mentioned.
Most likely you didn''t set up the compiler/linker correctly. Posting the error messages you get will probably help us (only the first few though...)

cu,
Prefect

---
Sanity is the trademark of a weak mind.
Widelands - laid back, free software strategy
Brin
Brin
Try adding a -lSDL to the end of your compile line :0
-AfroFire is Brin & Brin is AfroFire
Gametaku
Gametaku
> Lots of them. I did exactly that; I copied a segment of code into my compiler, and I linked the library path, and did everything right, but I got like 3000 errors.<

Do the errors say undefined this and undefined that?

I got a whole bunch of them when I tried to compile the samples, i needed to add a few header files.

You are with me.
Or you are not.
The choice is yours.
Witch shall you choose?
Just me
Kwizatz
Kwizatz
The SDL development Libs for windows come in only 2 flavors, Mingw and Visual C++, I doubt you can link it using codewarior, but I''ve never seen or worked with codewarior, I guess you should have to generate the libraries out of the sdl.dll binary.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.