3

My screen's resolution is 1920x1080. In order to have a fullscreen 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 positionned outside of the screen, like if my screen had a lower resolution than the window. It only shows a part of the window.

In order to see the image, I need to give image.x and image.y a value that is higher 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 is stuck in the very left-upper corner. This can give you an idea of where it is, approximatively, 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 it is so. how comes the positions x = 0 and y = 0 are outside of the screen?

4

0 回答 0