Commits

Michele Bini committed 5733049

Add a --quality option; disable z-buffer.

  • Participants
  • Parent commits 49a9b22

Comments (0)

Files changed (1)

 use strict;
 no integer;
 
+my $quality = 8;
+
 # Functional interface
 
 # Objects:
   my $textures = glGenTextures(1);
   die "Could not generate textures" unless $textures->[0];
   glBindTexture(GL_TEXTURE_2D, $textures->[0]);
-  glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-  glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+  glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ($quality > 5) ? GL_LINEAR : GL_NEAREST);
+  glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ($quality > 5) ? GL_LINEAR : GL_NEAREST); # && last for GL_NEAREST_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_NEAREST, GL_LINEAR;
+  glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 1);
   glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
   glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
   #vec(substr($d, int(rand(length($d))), 1), 0, 8) ^= int(rand(0x100)) for (0..5000);
 "verbose!" => \$verbose,
 "nometa!" => \$nometa,
 "texdim=s" => \$texdim,
+"quality=n" => \$quality,
 "screensize=s" => sub {
   ($screenw, $screenh) = ($1, $2)
   if $_[1] =~ /([0-9]+)x([0-9]+)/
 }
 
 sub setview {
-  setviewport();
   glEnable(GL_TEXTURE_2D);
+
+  if ($crosshair) {
+    glEnable(GL_LINE_SMOOTH) if $quality > 7;
+  }
+
+  # Disable zbuffer
+  glDisable(GL_DEPTH_TEST);
+  glDepthFunc(GL_NEVER);
+
+  setviewport();
+
   glClearColor(0.0, 0.0, 0.2, 0.0);
   glClearDepth(1.0);
-  glDepthFunc(GL_LESS);
-  glEnable(GL_DEPTH_TEST);
-  glShadeModel(GL_SMOOTH);
   setperspective();
 }
 
 	 SDL_KEYDOWN() => sub { $keyboard->keydown($event->key_sym) },
 	 SDL_VIDEORESIZE() => sub { my $e = shift; return if $noscreenresize; $app->resize($screenw = $e->resize_w, $screenh = $e->resize_h); setview() }
 	 );
+
 while (!$done) {
   warn "Frame $frame" if $debug;
   warn "Redrawing!" if $debug > 1;
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   my $time = int(time);
   if ($crosshair && ($time & 1)) {
-    glEnable(GL_LINE_SMOOTH);
     glLoadIdentity();
     # my $w = deg2rad(0.2);
     glLineWidth(1);
     glRotate($tilt,-1.0,0.0,0.0) if $tilt;
     glRotate($rotation,0.0,0.0,1.0) if $rotation;
   }
-  glLineWidth(1); # not sure why this happens
+  if (1) {
+    glColor(1,0,1,1);
+    glBegin(GL_TRIANGLES);
+    glVertex(+0.0,+10.0,-10.0);
+    glVertex(+0.0,+0.0,-10.0);
+    glVertex(+10.0,+0.0,-10.0);
+    glEnd();
+    glColor(1,1,1,1);
+  }
+  glLineWidth(1.0);
   $photo->gldraw;
   #glTranslate(0,0,-6);
   #glBegin(GL_QUADS);
   #glEnd();
   #glColor(1,1,0);
   #glTranslate(-1.5,0.0,0);
-  glColor(1,0,1,1);
-  glBegin(GL_TRIANGLES);
-  glVertex(+0.0,+10.0,-10.0);
-  glVertex(+0.0,+0.0,-10.0);
-  glVertex(+10.0,+0.0,-10.0);
-  glEnd();
-  glColor(1,1,1,1);
   #glTranslate(3.0,0.0,0.0);
   #glBegin(GL_QUADS);
   #glVertex(-1.0,+1.0,+0.0);