Using the SDL_gfx library?
#1 Members - Reputation: 116
Posted 14 December 2010 - 02:11 PM
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.
#2 Members - Reputation: 109
Posted 14 December 2010 - 04:06 PM
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
#3 Moderators - Reputation: 5027
Posted 14 December 2010 - 09:30 PM
I don't know how easy this is to do in Dev-C++, but it should be possible.
#4 Members - Reputation: 116
Posted 15 December 2010 - 06:55 AM
@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]
#5 Members - Reputation: 362
Posted 15 December 2010 - 11:04 AM
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]
#6 Members - Reputation: 116
Posted 15 December 2010 - 01:00 PM
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.
#8 Members - Reputation: 362
Posted 22 December 2010 - 12:44 PM
Quote:
Original post by CheddarCheese
The 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.
#9 Members - Reputation: 1349
Posted 22 December 2010 - 02:23 PM
Quote: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.
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.
Quote: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:
Otherwise, could you give me a rough outline of how I would rotate the ship without using rotozoom? Code based, I mean.
// 'constants'If rotozoom uses radians just replace 360 with 2*PI (and the rotation should be converted as well).
int max_rotations = 16;
float degrees_per_rotation = 360.0 / max_rotations;
float rotation = 56.0; // for example
int 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 degrees
if (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];
}
#10 Members - Reputation: 1349
Posted 22 December 2010 - 02:34 PM
Quote: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.
Original post by CheddarCheese
how I would rotate the ship without using rotozoom? Code based, I mean.
#11 Members - Reputation: 362
Posted 22 December 2010 - 04:47 PM
Quote:
Original post by nobodynews
Just 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.
#12 Members - Reputation: 116
Posted 25 December 2010 - 11:38 AM
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?
#14 Members - Reputation: 116
Posted 26 December 2010 - 12:33 AM
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.
#15 Members - Reputation: 116
Posted 26 December 2010 - 08:54 AM
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.
#16 Members - Reputation: 1900
Posted 26 December 2010 - 09:56 AM
Quote: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.)
Original post by CheddarCheese
Plus, since we are supposed to be making a game, he wants full end results. Unfortunately, this requires me to use Dev.
#17 Members - Reputation: 116
Posted 26 December 2010 - 10:12 AM
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++.
#18 Members - Reputation: 116
Posted 26 December 2010 - 11:37 AM
PS. google for 'how do I install SDL_gfx with Dev C++'
#19 Members - Reputation: 116
Posted 27 December 2010 - 09:02 AM
Does anyone know of a step by step procedure? That would help immensely.






