http://www.jwz.org/xscreensaver/xscreensaver-5.13.tar.gz
[xscreensaver] / hacks / glx / flipscreen3d.c
index 12107e269e16b3e5ac8d5952d9a40df2c8fdf46a..6d5844a99fe5753227dfcbb5081440aa8d5414ec 100644 (file)
 
 #ifdef USE_GL
 
+/* Should be in <GL/glext.h> */
+# ifndef  GL_TEXTURE_MAX_ANISOTROPY_EXT
+#  define GL_TEXTURE_MAX_ANISOTROPY_EXT     0x84FE
+# endif
+# ifndef  GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
+#  define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
+# endif
+
+#define DEF_ROTATE "True"
 static int rotate;
 
 #define QW 12
@@ -50,7 +59,7 @@ static XrmOptionDescRec opts[] = {
 
 
 static argtype vars[] = {
-  {&rotate, "rotate", "Rotate", "True", t_Bool},
+  {&rotate, "rotate", "Rotate", DEF_ROTATE, t_Bool},
 };
 
 
@@ -99,16 +108,14 @@ typedef struct {
   Bool waiting_for_image_p;
   Bool first_image_p;
 
+  GLfloat anisotropic;
+
 } Screenflip;
 
 static Screenflip *screenflip = NULL;
 
 #include "grab-ximage.h"
 
-#ifndef M_PI
-#define M_PI 3.14159265
-#endif
-
 static const GLfloat viewer[] = {0.0, 0.0, 15.0};
 
 
@@ -134,7 +141,9 @@ screenflip_handle_event (ModeInfo *mi, XEvent *event)
     }
   else if (event->xany.type == ButtonPress &&
            (event->xbutton.button == Button4 ||
-            event->xbutton.button == Button5))
+            event->xbutton.button == Button5 ||
+            event->xbutton.button == Button6 ||
+            event->xbutton.button == Button7))
     {
       gltrackball_mousewheel (c->trackball, event->xbutton.button, 10,
                               !!event->xbutton.state);
@@ -405,6 +414,10 @@ image_loaded_cb (const char *filename, XRectangle *geometry,
   glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
                    (c->mipmap_p ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR));
 
+  if (c->anisotropic >= 1.0)
+    glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 
+                     c->anisotropic);
+
   c->waiting_for_image_p = False;
   c->first_image_p = False;
 }
@@ -457,8 +470,6 @@ ENTRYPOINT void init_screenflip(ModeInfo *mi)
  c->show_colors[0] = c->show_colors[1] = 
    c->show_colors[2] = c->show_colors[3] = 1;
 
- glClearColor(0.0,0.0,0.0,0.0);
-
  if (! MI_IS_WIREFRAME(mi))
    {
      glShadeModel(GL_SMOOTH);
@@ -469,6 +480,12 @@ ENTRYPOINT void init_screenflip(ModeInfo *mi)
      glDisable(GL_LIGHTING);
    }
 
+ if (strstr ((char *) glGetString(GL_EXTENSIONS),
+             "GL_EXT_texture_filter_anisotropic"))
+   glGetFloatv (GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &c->anisotropic);
+ else
+   c->anisotropic = 0.0;
+
  glGenTextures(1, &c->texid);
 
  c->first_image_p = True;