Skip to content

Instantly share code, notes, and snippets.

@clooth
Created September 18, 2013 20:50
Show Gist options
  • Save clooth/6615495 to your computer and use it in GitHub Desktop.
Save clooth/6615495 to your computer and use it in GitHub Desktop.
#include <SDL2/SDL.h>
#include <stdio.h>
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
int main(int argc, char* args[])
{
// Main rendering window
SDL_Window* window = NULL;
// Surface contained by the window
SDL_Surface* screenSurface = NULL;
// Initialize SDL
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
printf("SDL could not initialize: SDL_error: %s\n", SDL_GetError());
}
else
{
// Create main window
window = SDL_CreateWindow("Void", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
if (window == NULL) {
printf("Window could not be created! SDL_Error: %s\n", SDL_GetError());
}
else
{
// Get window surface
screenSurface = SDL_GetWindowSurface(window);
// Fill it with white
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));
// Update the surface
SDL_UpdateWindowSurface(window);
// Wait two seconds
SDL_Delay(2000);
}
}
// Destroy our window
SDL_DestroyWindow(window);
// Quit SDL subsystems
SDL_Quit();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment