commit b5edff414afb811521ed70a23abb524809b07248
parent 60da1bb73eded7f9dd5b24c043c7574b263dd061
Author: Brian Swetland <swetland@frotz.net>
Date: Fri, 18 Jan 2013 16:10:57 -0800
test4: adjust ortho projection based on window dimensions
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/test4.c b/test4.c
@@ -50,6 +50,8 @@ GLfloat texcoords[] = {
};
int scene_init(struct ctxt *c) {
+ float aspect;
+
if (!(texdata = load_png_gray("texture.sdf.png", &texw, &texh, 1)))
return -1;
if (!(vert_src = load_file("test4.vs", 0)))
@@ -57,8 +59,8 @@ int scene_init(struct ctxt *c) {
if (!(frag_src = load_file("test4.fs", 0)))
return -1;
- mtx_identity(MVP);
- mtx_ortho(MVP, -1.333, 1.333, -1, 1, 1, -1);
+ aspect = ((float)c->width) / ((float)c->height);
+ mtx_ortho(MVP, -aspect, aspect, -1, 1, 1, -1);
glViewport(0, 0, c->width, c->height);
glClearColor(0, 0, 0, 0);