Rendering images in C++/SDL


richiz

Member
Joined
Jan 4, 2011
Messages
338
What would be the optimal image size for the pandora to process images?


I've heard (a long time ago, may even be a myth - before i even knew how to program) that certain sized images take more time to process than larger images.


I ask because I thought I was clever when I found a text to image function in Python only to discover that text display is more processor heavy than actual pictures. What a joke.


I wanted to do 64x64. I ask as I have a sprite artist now and I want to get him to knock them up as soon as possible.
 
What would be the optimal image size for the pandora to process images?


I've heard (a long time ago, may even be a myth - before i even knew how to program) that certain sized images take more time to process than larger images.


I ask because I thought I was clever when I found a text to image function in Python only to discover that text display is more processor heavy than actual pictures. What a joke.


I wanted to do 64x64. I ask as I have a sprite artist now and I want to get him to knock them up as soon as possible.
While not particularly fast SDL_TTF is a font rendering function for SDL. As long as you avoid alpha blending though it is adequate for most tasks.
 
A bit offtopic, but still: If you do text to image (using a truetype font, not character map image), remember to cache the resulting image. Do not re-render the same text to image over and over again every frame. Only render text when the text changes, otherwise use your previously cached image version. If only a part of your text changes (like the number in "FPS: 60"), render it in two parts and cache the non-changing part. This will save up a good amount of cycles. If your text is always the same size, consider pre-rendering the letters to a character map, then just rendering from that (only monospace fonts).
 
Thanks, I'm not going to render text for anything but story boarding now.


Hate it!
 
Regarding image size, you are talking about power of two sizes like 64,128,256, etc.


I think it's down to memory alignment.


There may some performance benefits to storing images at power of two resolution and it may reduce fragmenting RAM available. but SDL_image will let you load at any resolution and I guess without profiling you may not see any/much difference in performance.


Regarding text, in Penjin I create a Glyph sheet, and only create each Glyph when needed from there it's cached. The next time that character is requested the character is blitted directly from the cache and only recreated if the font size, colour or rendering mode changes.
 
Last edited by a moderator:
speedwise the panda si fast enough unles syou're rendering every pixel each frame, everything at the right size for the screen (either original image that size, or rendered form some format or another), then it's just blitting around parts of each surface.


oh and avoid alpha blending unless you really need it, if you just need either 0/100% transparency colourkeying is fast and simple in comparison to the alpha


edit: and make sure you convert the loaded images to your screen format before use, speeds things up a bit more aswell
 
Last edited by a moderator:
Back
Top