• Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at \$59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.

Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!

### #ActualTolito

Posted 19 December 2013 - 09:35 PM

It works well on something that I made that is a lower resolution, but the processor or something gets loud when trying to use this method with anything of a larger resolution, the processor gets loud and the entire computer slows down. I know it isn't the scaling code, since using the same smaller resolution with the scaled screen does not do this. When I comment out the function for doubling the actual viewing resolution of the screen, those glitches are eliminated, although only the upper-left-hand corner of the screen can be seen due to having not updated the window dimensions. The scaling isn't slow, nor is the blitting, but trying to blit the surface after scaling it is probably double the work for the processor. Doesn't SDL have some kind of display option for doubling the resolution? Are there any user-made functions online for this? A function for doubling the screen itself instead of doubling a duplicate of it, then blitting that would work better. SDL seems to edit the scaling in real time when in fullscreen, but that may be the hardware. Can anyone shed some light on this? Thanks!

Here is the code for the function:

void zoom_surface(SDL_Surface *original, float aspect, float zoom, unsigned int xloc, unsigned int yloc, unsigned int new_screen_w, unsigned int new_screen_h) {

SDL_Surface *scaled;

Uint8 *targ, bpp;

int x, y;

bpp = original->format->BytesPerPixel;

scaled =

SDL_CreateRGBSurface (original->flags, original->w * aspect * zoom,

original->h * zoom,

original->format->BitsPerPixel,

if (bpp == 1)

SDL_SetPalette (scaled, SDL_LOGPAL, original->format->palette->colors,

0, original->format->palette->ncolors);

targ = ((Uint8 *) scaled->pixels);

for (y = 0; y < scaled->h; y++) {

for (x = 0; x < scaled->w; x++) {

#if 1

switch (bpp) {

case 1:

*((Uint8 *) (targ)) =

*((Uint8 *) (original->pixels)+((int)(y/zoom))*original->w+(int)(x/(aspect*zoom)));

targ++;

break;

case 4:

*((Uint32 *) (targ)) =

*((Uint32 *) (original->pixels)+((int)(y/zoom))*original->w+(int)(x/(aspect*zoom)));

targ += 4;

break;

}

#else

memcpy(targ,original->pixels+(int)(y/zoom)*original->pitch+

(int)(x/(aspect*zoom))*bpp,bpp);

targ+=bpp;

#endif

}

targ += scaled->pitch - scaled->w*bpp;

}

if(new_screen_w && new_screen_h && (stored_res_x!=new_screen_w || stored_res_y!=new_screen_h) ) screen=SDL_SetVideoMode( new_screen_w, new_screen_h, 32, SDL_SWSURFACE ),stored_res_x=new_screen_w,stored_res_y=new_screen_h;

SDL_Rect dest={xloc,yloc};

SDL_BlitSurface(scaled,NULL,screen,&dest);

SDL_FreeSurface(scaled);

}

### #1Tolito

Posted 19 December 2013 - 09:29 PM

It works well on something that I made that is a lower resolution, but the processor or something gets loud when trying to use this method with anything of a larger resolution, the processor gets loud and the entire computer slows down. I know it isn't the scaling code, since using the same smaller resolution with the scaled screen does not do this. When I comment out the function for doubling the actual viewing resolution of the screen, those glitches are eliminated, although only the upper-left-hand corner of the screen can be seen due to having not updated the window dimensions. The scaling isn't slow, nor is the blitting, but trying to blit the surface after scaling it is probably double the work for the processor. Doesn't SDL have some kind of display option for doubling the resolution? Are there any user-made functions online for this? A function for doubling the screen itself instead of doubling a duplicate of it, then blitting that would work better. SDL seems to edit the scaling in real time when in fullscreen, but that may be the hardware. Can anyone shed some light on this? Thanks!

PARTNERS