C ++ - SDL not working

I tried to follow this tutorial on the basics of displaying images using SDL. But when I run the program, it returns a blank screen. The image is in the correct directories, but it does not appear in the program. Am I doing something wrong? I would really like the SDL to work.

EDIT

Here is my code:

#include <SDL/SDL.h>

using namespace std;

int main(int argc, char *argv[])
{
    SDL_Surface *hello;
    SDL_Surface *screen;
    SDL_Init(SDL_INIT_EVERYTHING);
    screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);
    hello = SDL_LoadBMP("hello.bmp");
    SDL_BlitSurface(hello, NULL, screen, NULL);
    SDL_Flip(screen);
    SDL_Delay(2000);
    SDL_FreeSurface(hello);
    SDL_Quit();
    return 0;
}
+3
source share
5 answers

I thought I said that I fixed it a few months ago, it seems not. I recompiled it again, and it worked, very weird.

+1
source

SDL_GetError(), , SDL_LoadBMP() .

+2

SDL_Flip(screen) SDL_UpdateRect(screen,0,0,0,0)

+1

, hello.bmp BMP.

0

: "hello = SDL_LoadBMP("hello.bmp");" "/hello.bmp" "hello.bmp". , , ( "/" ) , , , , , .

Windows "/hello.bmp", "c://hello.bmp". Mac. (

EDIT: , , , , .

0

Source: https://habr.com/ru/post/1749059/


All Articles