Full screen mode in SDL1.2 makes positions false

My screen resolution is 1920x1080. To have a full screen window, I call SDL_SetVideoMode(1920, 1080, 32, SDL_HWSURFACE | SDL_FULLSCREEN);

. However, when I try to add an image on this screen with positions x = 0 and y = 0, it is positioned off-screen, for example if my screen had a lower resolution than the window. It only displays part of the window.

To see the image, I need to give image.x

u a image.y

value greater than 0. For example, here is the result with image.x = 190

and image.y = 100

:

enter image description here

As you can see, the image gets stuck in the top left corner. This can give you an idea of ​​where it is, approximately, when image.x = 0

and image.y = 0

.

Here is my code:

int     main (int argc, char **argv)
{
    SDL_Surface *screen = NULL;
    SDL_Surface *image = NULL;
    SDL_Rect pos_image;

    SDL_Init(SDL_INIT_VIDEO);
    screen = SDL_SetVideoMode(1920, 1080, 32, SDL_SWSURFACE | SDL_FULLSCREEN);
    SDL_WM_SetCaption("SDL Test", NULL);
    image = SDL_LoadBMP("pack_images_sdz/image.bmp");
    SDL_SetColorKey(image, SDL_SRCCOLORKEY, SDL_MapRGB(image->format, 0, 0, 255));
    pos_image.x = 190;
    pos_image.y = 100;
    SDL_BlitSurface(image, NULL, screen, &pos_image);
    SDL_Flip(screen);
    pause();
    SDL_Quit();
    return EXIT_SUCCESS;
}

      

I would like to know why this is so. how do the positions x = 0 and y = 0 go off-screen?

+3


source to share





All Articles