Demos (master): tools/dds: Better use of screen real estate.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Thu Jun 6 13:23:24 UTC 2013


Module: Demos
Branch: master
Commit: afa94e9728bab46a8f63cf34472304932f092346
URL:    http://cgit.freedesktop.org/mesa/demos/commit/?id=afa94e9728bab46a8f63cf34472304932f092346

Author: José Fonseca <jfonseca at vmware.com>
Date:   Thu Jun  6 14:22:41 2013 +0100

tools/dds: Better use of screen real estate.

Compressed textures can be quite big, so use as much of the drawable
surface to render them.

---

 src/tools/dds.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/tools/dds.c b/src/tools/dds.c
index 24a5dc3..a4a438c 100644
--- a/src/tools/dds.c
+++ b/src/tools/dds.c
@@ -306,7 +306,10 @@ reshape (int w, int h)
 
   glMatrixMode (GL_PROJECTION);
   glLoadIdentity ();
-  gluPerspective (45.0, w/(GLdouble)h, 0.1, 1000.0);
+  if (w <= h)
+    gluOrtho2D (-1.0, 1.0, -1.0*(GLfloat)h/(GLfloat)w, 1.0*(GLfloat)h/(GLfloat)w);
+  else
+    gluOrtho2D (-1.0*(GLfloat)w/(GLfloat)h, 1.0*(GLfloat)w/(GLfloat)h, -1.0, 1.0);
 
   glMatrixMode (GL_MODELVIEW);
   glLoadIdentity ();
@@ -324,7 +327,7 @@ display (void)
   glBindTexture (GL_TEXTURE_2D, texId);
 
   /* Draw textured quad */
-  glTranslatef (0.0, 0.0, -5.0);
+  glTranslatef (0.0, 0.0, 0.5);
   glBegin (GL_QUADS);
     glTexCoord2f (0.0f, 0.0f);
     glVertex3f (-1.0f, -1.0f, 0.0f);
@@ -362,8 +365,8 @@ main (int argc, char *argv[])
     }
 
   glutInit (&argc, argv);
-  glutInitDisplayMode (GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
-  glutInitWindowSize (640, 480);
+  glutInitDisplayMode (GLUT_RGBA | GLUT_DOUBLE);
+  glutInitWindowSize (512, 512);
   glutCreateWindow ("DDS Texture Demo");
 
   /* Initialize OpenGL extensions */




More information about the mesa-commit mailing list