Quantcast
Channel: Tópicos
Viewing all articles
Browse latest Browse all 11336

SDL2 - Dúvidas

$
0
0
Tentei assim mas o resultado é o mesmo: #include <stdio.h> #include "SDL2/SDL.h" #include <stdbool.h> const int screenWidth = 1024; const int screenHeight = 768; bool sdl_Init(SDL_Window* pWindow, SDL_Surface* pSurface); bool sdl_LoadMedia(SDL_Surface* pSurface, char* pfilepath); void sdl_Close(SDL_Window* pWindow, SDL_Surface* pSurface); int main(int argc, char** argv){ SDL_Window* gWindow = NULL; SDL_Surface* gScreenSurface = NULL; SDL_Surface* gXOut = NULL; SDL_Event evt; bool quit = false; if( !sdl_Init(gWindow, gScreenSurface) ){ printf("Failed to initialise!\n"); }else{ if( !sdl_LoadMedia(gXOut, "Devil_May_Cry_III.bmp") ){ printf("Failed to load media!\n"); }else{ while(!quit){ while(SDL_PollEvent (&evt) != 0){ if(evt.type == SDL_QUIT) quit = true; } SDL_BlitSurface(gXOut, NULL, gScreenSurface, NULL); SDL_UpdateWindowSurface(gWindow); SDL_Delay(30);// <---aqui } } } sdl_Close(gWindow, gXOut); return 0; } /*********************** **Function definitions** ************************/ bool sdl_Init(SDL_Window* pWindow, SDL_Surface* pSurface){ bool success = true; if(SDL_Init(SDL_INIT_VIDEO) < 0){ printf("SDL could not initialize! SDL_Error: %s!\n", SDL_GetError()); success = false; }else{ pWindow = SDL_CreateWindow( "WindowZed fun", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, screenWidth, screenHeight, SDL_WINDOW_SHOWN ); if(pWindow == NULL){ printf("Window Could not be created! SDL Error: %s!\n", SDL_GetError()); success = false; }else{ pSurface = SDL_GetWindowSurface(pWindow); } } return success; } bool sdl_LoadMedia(SDL_Surface* pSurface, char* pfilepath){ bool success = true; pSurface = SDL_LoadBMP(pfilepath); if(pSurface == NULL){ printf("Unable to load %s. SDL Error: %s!\n", pfilepath, SDL_GetError()); success = false; } return success; } void sdl_Close(SDL_Window* pWindow, SDL_Surface* pSurface){ SDL_FreeSurface(pSurface); pSurface = NULL; SDL_DestroyWindow(pWindow); pWindow = NULL; SDL_Quit(); }

Viewing all articles
Browse latest Browse all 11336

Trending Articles