• Create Account

Using the SDL_gfx library?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

25 replies to this topic

#1CheddarCheese  Members

Posted 14 December 2010 - 02:11 PM

Hi there. I'm new to this forum, and I am also new to C++ SDL programming.

I hope I'm in the correct place to ask these questions.

Well, this is my problem. I require the SDL rotozoom function to rotate a ship for a game I am making at school. However, to have this function I need to include the SDL_gfx library. I have no clue how to do this.

This is on a school computer, so I cannot change operating systems/programs.

I am using Windows, and I am programming on Dev C++. Does anyone know of any way to use SDL_gfx under these conditions? If so, help would be greatly appreciated.

I have done multiple searches via Google to no avail.

#2bbr125  Members

Posted 14 December 2010 - 04:06 PM

I have only seen posts claiming that Dev C++ is old, outdated, and to avoid it at all costs. Most people will recommend Visual C++. There is a free version and also if you are a student you can use Visual Studio 2010 Professional for free (google Microsoft Dreamspark).

I don't use Dev C++ (and I doubt anyone here will recommend it). Anyway, usually you add a .LIB file(s) to the linker dependencies. In Visual Studio this is under Project Properties -> Linker -> Input -> Additional Dependencies.

Have a look here, on their FAQ:
http://www.bloodshed.net/faq.html#9

#3rip-off  Moderators

Posted 14 December 2010 - 09:30 PM

You can directly add the SDL_gfx source and headers to your project if you agree with the license terms. You can do it in the interim to get your project up and running. To retain full control of your executable, you should build SDL_gfx as a DLL and link to it.

I don't know how easy this is to do in Dev-C++, but it should be possible.

#4CheddarCheese  Members

Posted 15 December 2010 - 06:55 AM

Thanks for the replies.

@bbr125: Unfortunatly, our school network does not have this program, and if I did make it in Visual Studio, my teacher wouldn't be able to mark it.

What are the required files for adding SDL_gfx? I know how to link other types of SDL libraries, like SDL_ttf and SDL_mixer. I require a DLL, the lib and include folders and the linker.

Like I've said before, my knowledge doesn't extend past that since I am quite new to C++.

Do any of you know where I could find these files? So far, I've come across Linux setups, or setups without some files I seem to require.

Thanks!

[Edited by - CheddarCheese on December 15, 2010 2:55:08 PM]

#5signal_  Members

Posted 15 December 2010 - 11:04 AM

SDL_gfx Site.

Like rip-off said you could just add it to your project, but if you want to do it the formal way, then you will need to download the zip file from the above link. You then will need to build the project and link to the created dll file.

Also, if all this is just to have a rotated sprite image, then you could build your own rotated sprite sheet, that is have a sprite with each frame being a different rotation. Something like Image Magick could automate this process.

My last point is even if you get SDL_gfx up and running, you may have to examine if the rotozoomSurface function is fast enough for real time. If it is not, then you'd prolly be better off caching all the rotations which would basically be equivalent to the sprite sheet method, outlined above.

Edit: on my machine it appears fast enough for a small 32x32 pixel sprite, so maybe it will be for you too.

[Edited by - signal_ on December 15, 2010 5:04:50 PM]

#6CheddarCheese  Members

Posted 15 December 2010 - 01:00 PM

Thanks for all your information! I will try to link gfx shortly.

Well, I have been doing some researching, and it appears that using rotozoom in real time slows the computer down quite a bit. Now I have a feeling that my school computers defiantly won't be able to handle it. However, I will try it out first, I suppose.

Otherwise, could you give me a rough outline of how I would rotate the ship without using rotozoom? Code based, I mean.

See, my problem is that I don't only have one ship to rotate, there will be many different ships. This would require many different sprite sheets, and presumably a lot of code. I was trying to find the faster, more efficient method of doing this.

#7CheddarCheese  Members

Posted 21 December 2010 - 11:27 AM

Hi, sorry to have to bump this, but I still have no idea what to do.

What exactly am I supposed to do with this file to use SDL_gfx?

#8signal_  Members

Posted 22 December 2010 - 12:44 PM

Quote:
 Original post by CheddarCheeseThe link that signal_ gave me seems to have a download called: "SDL_gfx-2.0.22.tar.gz"What exactly am I supposed to do with this file to use SDL_gfx?

You're on windows right? If you look at the link one below the tar.gz file, it is a .zip file. You should be familiar with how to open zip files. In case you'd like to open a tar.gz file you can use something like 7zip on Windows.

So just download the zip file and unzip it. All the files and compilation directions, license, etc. will be bundled there.

#9nobodynews  Members

Posted 22 December 2010 - 02:23 PM

Quote:
 Original post by signal_You're on windows right? If you look at the link one below the tar.gz file, it is a .zip file.
Just for another perspective I can't find a zip file anywhere on that website either. But the tar.gz file is easily decompressed with 7zip (as are almost every compressed file format) so it isn't really necessary.
Quote:
 Otherwise, could you give me a rough outline of how I would rotate the ship without using rotozoom? Code based, I mean.
rotozoom will probably be fine for most use-cases if you use it the right way. When you start your level and first load your images you pre-rotate the image 360/X degrees where X is the number of rotations you want to perform on your image. So if X is 16 you would rotate your image by 22.5 degrees 16 times. When you want to draw your image just choose the closest pre-rotated image to the orientation you desire. So if you have a ship and it is supposed to be rotated rotation degrees away from 'normal' you would select the pre-rotated image using code somewhat like this:
// 'constants'int max_rotations = 16;float degrees_per_rotation = 360.0 / max_rotations;float rotation = 56.0; // for exampleint number_of_rotations = (int)(rotation / degrees_per_rotation);// Check which rotation is closest and wrap around// in case the angle of rotation is greater than 360.0 degreesif (rotation-number_of_rotations*degrees_per_rotation < degrees_per_rotation/2) {  rotation_image_array[number_of_rotations%max_rotations];} else {  rotation_image_array[(number_of_rotations+1)%max_rotations];}
If rotozoom uses radians just replace 360 with 2*PI (and the rotation should be converted as well).

#10nobodynews  Members

Posted 22 December 2010 - 02:34 PM

Quote:
 Original post by CheddarCheesehow I would rotate the ship without using rotozoom? Code based, I mean.
To answer this specific question as writen your options for rotating are to replicate what rotozoom does in your own code which probably won't be any faster, use rotozoom directly, or modify your program to use hardware acceleration (via OpenGL in your case most likely) to rorate the images for you.

#11signal_  Members

Posted 22 December 2010 - 04:47 PM

Quote:
 Original post by nobodynewsJust for another perspective I can't find a zip file anywhere on that website either.

I have javascript turned off in my firefox. When I opened the link I gave in IE, where I have scripts enabled, it redirects to a different page apparently. This page does not show the link for the zip file that is shown when scripts are disabled. So that accounts for the confusion.

Here is the direct link to the zip file on the site.

#12CheddarCheese  Members

Posted 25 December 2010 - 11:38 AM

Thank you very much for all your help.

I have one last question. To install different libraries (eg. ttf, mixer) on Dev C++, I require a 'linker', a 'library' folder and an 'include' folder. However, in the gfx file, none of these are visible. Now, I'm pretty sure there's a way to install it but which I'm oblivious, since all the other libraries I installed were off the same site. Does anyone know how to install gfx into Dev C++ using those files?

#13Kurasu1415  Members

Posted 25 December 2010 - 11:50 PM

There is a website I found a while back that is great for learning the basics of SDL. He has programs specific to using each library with instructions on how to install all of them.

http://www.lazyfoo.net/SDL_tutorials/

#14Gaticus  Members

Posted 26 December 2010 - 12:33 AM

I would urge you to try to convince your school to adopt a better IDE. VS2008 is free and is much more standard than Bloodshed. Another one is Eclipse.

For SDL programming, you don't even need an IDE. My inclination is to say that if your teacher knows what they are doing, it shouldn't matter much what editor you use. They should be able to inspect your code with any text editor. No IDE is required.

#15CheddarCheese  Members

Posted 26 December 2010 - 08:54 AM

Hi,

Thanks for your suggestions, but I have checked the Lazy Foo website and they seem to have a variety of instructions for libraries, however, gfx is not one of them. I can't use other library instructions to install gfx, since I still don't have the linker and the files are different.

As for the lack of IDE suggestion, I am still a student trying to figure out how everything works. I'm quite new to C++, and I'm trying to do all this at home without my teacher around. Plus, since we are supposed to be making a game, he wants full end results. Unfortunately, this requires me to use Dev.

#16scgames  Members

Posted 26 December 2010 - 09:56 AM

Quote:
 Original post by CheddarCheesePlus, since we are supposed to be making a game, he wants full end results. Unfortunately, this requires me to use Dev.
Why's that? Is it a project requirement that Dev-C++ be used? (You might have already mentioned this, but if so I must have missed it.)

#17CheddarCheese  Members

Posted 26 December 2010 - 10:12 AM

@ jyk: Well, our school computers seem to have Dev C++, and a very outdated version of Visual C++, and that's about it. My teacher decided that we use Dev.

C++ has a wide range of libraries, and lots of people are using separate libraries. So it order for me to install the libraries at school, I need to know how to install them to Dev C++.

#18Gaticus  Members

Posted 26 December 2010 - 11:37 AM

I didn't mean you should change your tools right now, but you should COMPLAIN to your school/teacher about having to use Dev C++. You have paid for them to train you. They are not doing you any favors by teaching you with obscure technology.

PS. google for 'how do I install SDL_gfx with Dev C++'

#19CheddarCheese  Members

Posted 27 December 2010 - 09:02 AM

I have already tried to google this topic, and came here after I drew a blank. I have found that there is a Devpak SDL_gfx that I can install, but it still seems to require additional steps to work.

Does anyone know of a step by step procedure? That would help immensely.

#20CheddarCheese  Members

Posted 30 December 2010 - 09:53 AM

If no one knows how to do so, I only need gfx for rotation. As I've heard, there's a way to rotate without rotozoom.

If I can't install gfx, is there anywhere that I can learn how to rotate without it?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.