Mesa (master): progs/glsl: handle window resizes in texaaline.c

Brian Paul brianp at kemper.freedesktop.org
Wed Aug 26 18:02:23 UTC 2009


Module: Mesa
Branch: master
Commit: 2bcf787de1884dff34749d308eb245da457ef649
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2bcf787de1884dff34749d308eb245da457ef649

Author: Brian Paul <brianp at vmware.com>
Date:   Wed Aug 26 11:56:19 2009 -0600

progs/glsl: handle window resizes in texaaline.c

---

 progs/glsl/texaaline.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/progs/glsl/texaaline.c b/progs/glsl/texaaline.c
index 2481c0f..7a5ac40 100644
--- a/progs/glsl/texaaline.c
+++ b/progs/glsl/texaaline.c
@@ -103,6 +103,8 @@ static float Sin(float a)
 static void
 Redisplay(void)
 {
+   float cx = 0.5 * WinWidth, cy = 0.5 * WinHeight;
+   float len = 0.5 * WinWidth - 20.0;
    int i;
 
    glClear(GL_COLOR_BUFFER_BIT);
@@ -114,20 +116,20 @@ Redisplay(void)
 
    for (i = 0; i < 360; i+=5) {
       float v0[2], v1[2];
-      v0[0] = 150 + 40 * Cos(i);
-      v0[1] = 150 + 40 * Sin(i);
-      v1[0] = 150 + 130 * Cos(i);
-      v1[1] = 150 + 130 * Sin(i);
+      v0[0] = cx + 40 * Cos(i);
+      v0[1] = cy + 40 * Sin(i);
+      v1[0] = cx + len * Cos(i);
+      v1[1] = cy + len * Sin(i);
       QuadLine(v0, v1, Width);
    }
 
    {
       float v0[2], v1[2], x;
       for (x = 0; x < 1.0; x += 0.2) {
-         v0[0] = 150 + x;
-         v0[1] = 150 + x * 40 - 20;
-         v1[0] = 150 + x + 5.0;
-         v1[1] = 150 + x * 40 - 20;
+         v0[0] = cx + x;
+         v0[1] = cy + x * 40 - 20;
+         v1[0] = cx + x + 5.0;
+         v1[1] = cy + x * 40 - 20;
          QuadLine(v0, v1, Width);
       }
    }
@@ -142,6 +144,8 @@ Redisplay(void)
 static void
 Reshape(int width, int height)
 {
+   WinWidth = width;
+   WinHeight = height;
    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();




More information about the mesa-commit mailing list