Page 1 of 2

image resizing?

Posted: Fri Jun 05, 2009 6:22 pm
by h0ts0up
I'm uber nub when it comes to game dev and even more nub when it comes to programming. I just started dabbling with SDL and recently learned that there is no function for resizing images. I drew an image of a meadow and what not as a background and applied it to a surface and found that it was a portion of the image rather than the entire image. When you're making your sprites and maps, are you making the images to scale, or are you using a different library where you resize it to fit?

Re: image resizing?

Posted: Fri Jun 05, 2009 7:41 pm
by dandymcgee
h0ts0up wrote: When you're making your sprites and maps, are you making the images to scale, or are you using a different library where you resize it to fit?
Generally sprites are drawn to size from the start, and maps are made up of tiles (a bunch of fragments of a larger image stored as rectangles to save memory when you use them more than once). Images not made up of tiles (title screens, backgrounds, etc.) are generally drawn to size as well. Of course these observations apply directly to 2D games (where the majority of my experience lies), 3D is a whole different ball game. ;)

Re: image resizing?

Posted: Fri Jun 05, 2009 8:33 pm
by h0ts0up
thanks, my goal by the end of this summer is to write my own 2d sidescroller. So, your expertise was just what I was looking for. :)

Re: image resizing?

Posted: Sat Jun 06, 2009 2:06 am
by PixelP
if you really want to resize an image i guess you can use sdl_gfx, but im not sure.
i would use sfml for that though. sfml has some nice image manipulation functions.
http://www.sfml-dev.org/documentation/1 ... Sprite.htm

Re: image resizing?

Posted: Wed Jun 10, 2009 12:50 am
by Ginto8
PixelP wrote:if you really want to resize an image i guess you can use sdl_gfx, but im not sure.
i would use sfml for that though. sfml has some nice image manipulation functions.
http://www.sfml-dev.org/documentation/1 ... Sprite.htm
or you could use OpenGL, which uses texture mapping. This mapping makes resizing (in any direction) a breeze. Or you could be hardcore in SDL and do some badass and insanely difficult pixel manipulation. :lol: I prefer the prior, but it's your choice. :mrgreen:

Re: image resizing?

Posted: Wed Jun 10, 2009 3:36 am
by eatcomics
Ginto8 wrote:badass
A child of your age should not be speaking such discrepancies!!!! :lol:

Re: image resizing?

Posted: Mon Jun 15, 2009 1:39 pm
by short
Rather then make a new post, I will ask in here: What about background files? They are drawn to scale at the beginning, but what about different resolutions? On my computer I use a 1440 x 900 resolution, and a 1440 x 900 file,but my friends laptop won't go that large, and therefore fails to load the file. Is my only choice to have a different background file for every possible resolution?


edit: I am using straight SDL for this project, the next game I think I will try and start learning open GL.

Re: image resizing?

Posted: Mon Jun 15, 2009 7:56 pm
by dandymcgee
short0014 wrote:Rather then make a new post, I will ask in here: What about background files? They are drawn to scale at the beginning, but what about different resolutions? On my computer I use a 1440 x 900 resolution, and a 1440 x 900 file,but my friends laptop won't go that large, and therefore fails to load the file. Is my only choice to have a different background file for every possible resolution?


edit: I am using straight SDL for this project, the next game I think I will try and start learning open GL.
When you initialize the SDL window, you specify the resolution. This eliminates the need to make sure the image fits a user's desktop resolution (unless of course you try to make the window re-sizable).

Re: image resizing?

Posted: Mon Jun 15, 2009 8:22 pm
by short
I did that, but on my friends laptop it wouldn't initialize without me replacing the file with a new background file that was smaller then 1440 x 900.

Here's my init code:

Code: Select all

//set up the screen.
	 if(fullscreen == true)
	 {
		  screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE | SDL_FULLSCREEN);
	 }
	 else
	 {
		  screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE);
	 }

	 if(screen == NULL)
	 {
		  myLog->writeToFile(" screen = null, in init(bool fullscreen) \n");
		  return false;
	 }
edit: What I guess I want to ask is, how do I deal with different resolutions on different computers. For example: my friends laptop can't handle 1440 x 900 resolution, but mine can. Is there a simple way of doing this?

Re: image resizing?

Posted: Mon Jun 15, 2009 9:09 pm
by dandymcgee
short0014 wrote: edit: What I guess I want to ask is, how do I deal with different resolutions on different computers. For example: my friends laptop can't handle 1440 x 900 resolution, but mine can. Is there a simple way of doing this?
Why do you need such a large window? I usually run 640x480 res in fullscreen mode when devving with SDL, but most if not all modern displays should support 1024x768 just fine. I don't see the need to go any bigger than that.

Re: image resizing?

Posted: Mon Jun 15, 2009 10:10 pm
by short
It was more of a "how would one do this" theoretical question, tbh. ;)

Re: image resizing?

Posted: Tue Jun 16, 2009 12:00 pm
by dandymcgee
short0014 wrote:It was more of a "how would one do this" theoretical question, tbh. ;)
Either draw one for each possible resolution, or scale it with some sort of API function or pixel manipulation (OpenGL handles this quite easily).

Re: image resizing?

Posted: Thu Jul 09, 2009 8:42 am
by derbon
SDL is a BAD IDEA

Re: image resizing?

Posted: Fri Jul 10, 2009 3:05 am
by eatcomics
You're a bad idea!... Y u b hatin on da SDLs son???

Re: image resizing?

Posted: Fri Jul 10, 2009 6:29 am
by Sanshin77
derbon wrote:SDL is a BAD IDEA
What's a better idea then, and why?