Created
August 4, 2015 18:13
-
-
Save JohannesMP/9a9b5263c127103f1861 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
solution "SDL2_Test" | |
configurations { "debug", "release" } | |
location("make/" .. os.get() .. "/") | |
targetdir("bin/" .. os.get() .. "/%{cfg.buildcfg}/") | |
objdir("obj/" .. os.get() .. "/%{cfg.buildcfg}/") | |
project "sdl2_test" | |
kind "WindowedApp" | |
language "C" | |
files { "sdl2_test.c" } | |
filter "configurations:Debug" | |
defines { "DEBUG" } | |
flags { "Symbols" } | |
filter "configurations:Release" | |
defines { "NDEBUG" } | |
optimize "On" | |
configuration "macosx" | |
links {"OpenGL.framework","CoreFoundation.framework","SDL2.framework"} | |
configuration {"macosx", "gmake"} | |
buildoptions {"-F /Library/Frameworks", "-F ~/Library/Frameworks"} | |
linkoptions {"-F /Library/Frameworks", "-F ~/Library/Frameworks"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "SDL2/SDL.h" | |
#include <stdio.h> | |
int main(int argc, char* argv[]) { | |
SDL_Window *window; // Declare a pointer | |
SDL_Init(SDL_INIT_VIDEO); // Initialize SDL2 | |
// Create an application window with the following settings: | |
window = SDL_CreateWindow( | |
"An SDL2 window", // window title | |
SDL_WINDOWPOS_UNDEFINED, // initial x position | |
SDL_WINDOWPOS_UNDEFINED, // initial y position | |
640, // width, in pixels | |
480, // height, in pixels | |
SDL_WINDOW_OPENGL // flags - see below | |
); | |
// Check that the window was successfully made | |
if (window == NULL) { | |
// In the event that the window could not be made... | |
printf("Could not create window: %s\n", SDL_GetError()); | |
return 1; | |
} | |
// The window is open: enter program loop (see SDL_PollEvent) | |
SDL_Delay(3000); // Pause execution for 3000 milliseconds, for example | |
// Close and destroy the window | |
SDL_DestroyWindow(window); | |
// Clean up | |
SDL_Quit(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment