use displayinfo to determine size
This commit is contained in:
parent
f3b1651349
commit
7b40814022
24
src/gss.d
24
src/gss.d
@ -5,25 +5,23 @@ import glamour.vao;
|
|||||||
import glamour.shader;
|
import glamour.shader;
|
||||||
import glamour.vbo;
|
import glamour.vbo;
|
||||||
import gl3n.linalg;
|
import gl3n.linalg;
|
||||||
static import logoobj;
|
|
||||||
static import logo;
|
static import logo;
|
||||||
|
|
||||||
enum int WIDTH = 600;
|
extern(C) void GetDisplaySize(int * width, int * height, int * num_monitors);
|
||||||
enum int HEIGHT = 450;
|
|
||||||
|
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
GLint position_idx;
|
GLint position_idx;
|
||||||
GLint view_idx;
|
GLint view_idx;
|
||||||
GLint color_idx;
|
GLint color_idx;
|
||||||
mat4 view_matrix;
|
mat4 view_matrix;
|
||||||
Shader program;
|
Shader program;
|
||||||
Shader program2;
|
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
logo.init();
|
logo.init();
|
||||||
// glClearColor (1.0, 0.7, 0.0, 0.0);
|
|
||||||
glClearColor (0.0, 0.0, 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 = `
|
immutable string shader_src = `
|
||||||
vertex:
|
vertex:
|
||||||
uniform mat4 view;
|
uniform mat4 view;
|
||||||
@ -51,8 +49,7 @@ void display(SDL_Window * window)
|
|||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
view_matrix.make_identity();
|
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);
|
view_matrix.scale(0.25, 0.25, 0.25);
|
||||||
|
|
||||||
program.bind();
|
program.bind();
|
||||||
@ -89,6 +86,10 @@ void display(SDL_Window * window)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
GetDisplaySize(&width, &height, null);
|
||||||
|
if (width > 1920 * 2)
|
||||||
|
width = 1920 * 2; /* restrict to two monitors */
|
||||||
|
|
||||||
DerelictSDL2.load();
|
DerelictSDL2.load();
|
||||||
|
|
||||||
DerelictGL3.load();
|
DerelictGL3.load();
|
||||||
@ -105,10 +106,9 @@ int main()
|
|||||||
SDL_Window * window = SDL_CreateWindow("Gentex ScreenSaver",
|
SDL_Window * window = SDL_CreateWindow("Gentex ScreenSaver",
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
WIDTH,
|
width,
|
||||||
HEIGHT,
|
height,
|
||||||
// SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS);
|
SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS);
|
||||||
SDL_WINDOW_OPENGL);
|
|
||||||
|
|
||||||
SDL_GLContext context = SDL_GL_CreateContext(window);
|
SDL_GLContext context = SDL_GL_CreateContext(window);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user