2016-09-17 2 views
-1
#include <iostream> 
#include <SDL2/sdl.h> 

int main(int argc, char * argv[]) { 
    // insert code here... 
    std::cout << "Hello, World!\n"; 
    SDL_Init(SDL_INIT_VIDEO); 
    SDL_Window *window = SDL_CreateWindow("Fen", 640, 480, 640, 480, SDL_WINDOW_SHOWN); 
    std::cout << SDL_GetError(); 
    SDL_Delay(3000); 
    return 0; 
} 

Warum habe ich kein Fenster geöffnet? Es ist seltsam .... Der Build ist in Ordnung, aber kein FensterWas? SDL öffnet kein Fenster?

Für Informationen geöffnet, ich bin ein Mac

Antwort

0

Eigentlich Fenster erstellt wurde, verwendet wird. Sie können das Cmd-Anwendungssymbol in OS X Dock sehen.

Das eigentliche Problem, dass Sie keine positive Rückmeldung bekommen können, ist, dass dieses Fenster leer ist und nichts anzeigt. Die folgenden Codes füllen es weiß.

SDL_Init(SDL_INIT_VIDEO); 
SDL_Window *window = SDL_CreateWindow("Fen", 640, 480, 640, 480, SDL_WINDOW_SHOWN); 

auto screenSurface = SDL_GetWindowSurface(window); 

//Fill the surface white 
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF)); 

//Update the surface 
SDL_UpdateWindowSurface(window); 

SDL_Delay(3000); 

//Destroy window 
SDL_DestroyWindow(window); 

//Quit SDL subsystems 
SDL_Quit();