Skip to content

Commit

Permalink
Add window flags
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktm committed Nov 20, 2015
1 parent 2ebc833 commit 129b5a2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
9 changes: 8 additions & 1 deletion include/simple2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#define S2D_WARN 2
#define S2D_ERROR 3

#define S2D_RESIZABLE SDL_WINDOW_RESIZABLE
#define S2D_BORDERLESS SDL_WINDOW_BORDERLESS
#define S2D_FULLSCREEN SDL_WINDOW_FULLSCREEN_DESKTOP
#define S2D_HIGHDPI SDL_WINDOW_ALLOW_HIGHDPI

// If ARM, assume GLES
#ifdef __arm__
#define GLES true
Expand Down Expand Up @@ -183,7 +188,9 @@ void print_gl_context();
/*
* Create the window
*/
Window* S2D_CreateWindow(char *title, int width, int height, Update, Render);
Window* S2D_CreateWindow(
char *title, int width, int height, Update, Render, int flags
);

/*
* Show the window
Expand Down
7 changes: 2 additions & 5 deletions src/simple2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ void S2D_FreeMusic(Music music) {
* Create a window
*/
Window* S2D_CreateWindow(char *title, int width, int height,
Update update, Render render) {
Update update, Render render, int flags) {

// Allocate window and set default values
Window *window = (Window*)malloc(sizeof(Window));
Expand Down Expand Up @@ -492,14 +492,11 @@ Window* S2D_CreateWindow(char *title, int width, int height,
}

// Create SDL window
// TODO: Add `SDL_WINDOW_FULLSCREEN_DESKTOP` option to flags, or...
// Call `SDL_SetWindowFullscreen` in update loop
// TODO: Add SDL_WINDOW_ALLOW_HIGHDPI flag
window->sdl = SDL_CreateWindow(
window->title, // title
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, // window position
window->width, window->height, // window size
SDL_WINDOW_OPENGL // flags
SDL_WINDOW_OPENGL | flags // flags
);

if (!window->sdl) S2D_Error("SDL_CreateWindow", SDL_GetError());
Expand Down
2 changes: 1 addition & 1 deletion tests/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void on_key(const char *key) {
int main(int argc, char const *argv[]) {

window = S2D_CreateWindow(
"Audio", 200, 150, NULL, NULL
"Audio", 200, 150, NULL, NULL, 0
);

window->on_key = on_key;
Expand Down
2 changes: 1 addition & 1 deletion tests/testcard.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ int main(int argc, char const *argv[]) {

S2D_Diagnostics(true);

window = S2D_CreateWindow("Simple 2D – Testcard", 600, 500, update, render);
window = S2D_CreateWindow("Simple 2D – Testcard", 600, 500, update, render, 0);

window->on_key = on_key;
window->on_key_down = on_key_down;
Expand Down

0 comments on commit 129b5a2

Please sign in to comment.