From 7b408140225eb001ce31df3449de2abed91bfce3 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 24 Nov 2013 22:05:32 -0500 Subject: [PATCH] use displayinfo to determine size --- src/gss.d | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/gss.d b/src/gss.d index 027c3bb..fe89631 100644 --- a/src/gss.d +++ b/src/gss.d @@ -5,25 +5,23 @@ import glamour.vao; import glamour.shader; import glamour.vbo; import gl3n.linalg; -static import logoobj; static import logo; -enum int WIDTH = 600; -enum int HEIGHT = 450; +extern(C) void GetDisplaySize(int * width, int * height, int * num_monitors); +int width; +int height; GLint position_idx; GLint view_idx; GLint color_idx; mat4 view_matrix; Shader program; -Shader program2; void init() { logo.init(); -// glClearColor (1.0, 0.7, 0.0, 0.0); glClearColor (0.0, 0.0, 0.0, 0.0); - glViewport(0, 0, WIDTH, HEIGHT); + glViewport(0, 0, width, height); immutable string shader_src = ` vertex: uniform mat4 view; @@ -51,8 +49,7 @@ void display(SDL_Window * window) glClear(GL_COLOR_BUFFER_BIT); view_matrix.make_identity(); -// view_matrix.rotatez(SDL_GetTicks() / 500.0); - view_matrix.scale(HEIGHT / cast(float)WIDTH, 1.0, 1.0); + view_matrix.scale(height / cast(float)width, 1.0, 1.0); view_matrix.scale(0.25, 0.25, 0.25); program.bind(); @@ -89,6 +86,10 @@ void display(SDL_Window * window) int main() { + GetDisplaySize(&width, &height, null); + if (width > 1920 * 2) + width = 1920 * 2; /* restrict to two monitors */ + DerelictSDL2.load(); DerelictGL3.load(); @@ -105,10 +106,9 @@ int main() SDL_Window * window = SDL_CreateWindow("Gentex ScreenSaver", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - WIDTH, - HEIGHT, -// SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS); - SDL_WINDOW_OPENGL); + width, + height, + SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS); SDL_GLContext context = SDL_GL_CreateContext(window);