• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Tolito

Double Screen Resolution

9 posts in this topic

Is there a way to use SDL_BlitSurface multiple times to SDL_Surface *screen, but, before doing SDL_Flip(screen);, doubling the resolution of it? My game is meant to look pixelated, so I know this will not increase the quality or anything. The rendering is small due to small tiles, though, so a way to double the scale of anything immediately before SDL_Flip(screen); would be helpful. I would increase the scale of all of the graphics, but that would take more space and some people may prefer a smaller screen resolution, so increasing the scale before flipping the surface sounds like the best option. I prefer to not use OpenGL nor SDL_gfx. Any input would be helpful! Thanks!
0

Share this post


Link to post
Share on other sites
I made a new surface be a scaled version of the screen, blitted that surface to the screen, and used SDL_Flip! Thanks!
0

Share this post


Link to post
Share on other sites

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,

                              original->format->Rmask,

                              original->format->Gmask,

                              original->format->Bmask,

                              original->format->Amask);

    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);

}
0

Share this post


Link to post
Share on other sites

 

 

A function for doubling the screen itself instead of doubling a duplicate of it [...]

 

Dependet on which Version you use:

  • SDL2    : SDL_SetWindowSize or in Fullscreen SDL_SetWindowDisplayMode
  • SDL1.2 : SDL_SetVideoMode 

The difference between them is that the first one really change the resoultion and the second on just set a new video mode to the resolution you want IT doesn't scale anything what on the screen is from what i know.

Edited by exOfde
1

Share this post


Link to post
Share on other sites
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;

That's what I was saying. The problem was probably not occurring because it only had to blit for one fourth of the size of the window. With that line of code enabled, however, it must do four times the blitting, which led to an entire system slowdown.

 

 

Instead of scaling and blitting a duplicate, how can I scale the screen itself and use SDL_Flip on that? For example, this:

scale(screen);
SDL_Flip(screen);

Instead of this:

SDL_Surface *scaled=scale(screen);
SDL_BlitSurface(scaled,NULL,screen,NULL);
SDL_Flip(screen);

I tried running the code with scaling going on in the background with no re-blitting. There was no lag. Blitting without scaling also results in no lag. With both scaling and blitting, however, the entire system slows down. Thanks again!

Edited by Tolito
0

Share this post


Link to post
Share on other sites

SDL1.2 does not take advantage of hardware acceleration, and, in your code above, you are manually zoom.  My suggesiton would be to use a multimedia API that uses the GFX hardware to do all the scaling, rotating, etc. that you need in hardware.  I know SFML does; SDL2.0 is supposed to, but I've never used it.

2

Share this post


Link to post
Share on other sites
Thanks for the response! This is almost finished, so switching to something other than SDL 1.2 at the last minute may be more work than necessary. Is there some kind of way to scale screen and then do SDL_Flip(screen); instead of making a duplicate that is a scaled version of screen and then blitting to screen, flipping screen afterwards? I tried running the scaling code in the background without re-blitting and there was no slowdown. Blitting the duplicated and scaled surface to screen before doing SDL_Flip(screen); is what causes the major slowdown to occur.
0

Share this post


Link to post
Share on other sites
You're going about this the wrong way. You can
  • reduce the screen resolution and use your graphics at their current size, or
  • scale your graphics up as part of the resource loading process rather than trying to scale the entire screen (or individual surfaces) on every frame, or
  • scale your graphics up in whatever you're using to create them so that they're the correct size relative to your desired resolution
Doing any kind of pixel manipulation is going to be very slow in SDL1.2 so offload as much of it as you can into one-time processes performed at startup.
1

Share this post


Link to post
Share on other sites

I added code to work with surfaces that are double their original scale and made them be scaled after being loaded. It took a while to implement, but the doubled resolution renders more quickly now. The original, doubled, and fullscreen resolutions are now all available to the user. Hopefully storing the scaled surfaces will not be a problem for the system requirements! Thanks for the input! I was hoping there was a way to render at double the resolution without having to scale the surfaces, but this will do.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0