Last active
August 29, 2015 14:03
-
-
Save phrohdoh/04494a229f08db4421af to your computer and use it in GitHub Desktop.
This file contains 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
public class Game | |
{ | |
Sdl2Graphics window; | |
public static void Main(string[] args) | |
{ | |
window = new Sdl2Graphics(new Size(450, 450)); | |
} | |
} |
This file contains 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
public class Sdl2Graphics | |
{ | |
Size size; | |
IntPtr context, window; | |
public Sdl2Graphics(Size windowSize) | |
{ | |
size = windowSize; | |
SDL.SDL_Init(SDL.SDL_INIT_VIDEO | SDL.SDL_INIT_AUDIO); | |
SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_DOUBLEBUFFER, 1); | |
SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_RED_SIZE, 8); | |
SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_GREEN_SIZE, 8); | |
SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_BLUE_SIZE, 8); | |
SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_ALPHA_SIZE, 0); | |
window = SDL.SDL_CreateWindow | |
( | |
"SDL2 TestGame", | |
SDL.SDL_WINDOWPOS_CENTERED, SDL.SDL_WINDOWPOS_CENTERED, | |
size.Width, size.Height, | |
SDL.SDL_WindowFlags.SDL_WINDOW_SHOWN | |
); | |
SDL.SDL_ShowCursor(1); | |
context = SDL.SDL_GL_CreateContext(window); | |
SDL.SDL_GL_MakeCurrent(window, context); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment