gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/gfx jni/GzzGL-jni.cxx libpaper/papermill.py...


From: Janne V. Kujala
Subject: [Gzz-commits] gzz/gfx jni/GzzGL-jni.cxx libpaper/papermill.py...
Date: Wed, 13 Nov 2002 17:48:56 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        02/11/13 17:48:56

Modified files:
        gfx/jni        : GzzGL-jni.cxx 
        gfx/libpaper   : papermill.py 
        gfx/libutil    : buildmipmaps.cxx 

Log message:
        Test for GL_SGIS_generate_mipmap and use Util::buildmipmaps where 
possible if not found; libpaper still does not work properly on G400: it is 
slow and messes up text vobs

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/jni/GzzGL-jni.cxx.diff?tr1=1.62&tr2=1.63&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/papermill.py.diff?tr1=1.60&tr2=1.61&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libutil/buildmipmaps.cxx.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: gzz/gfx/jni/GzzGL-jni.cxx
diff -u gzz/gfx/jni/GzzGL-jni.cxx:1.62 gzz/gfx/jni/GzzGL-jni.cxx:1.63
--- gzz/gfx/jni/GzzGL-jni.cxx:1.62      Wed Nov 13 06:21:53 2002
+++ gzz/gfx/jni/GzzGL-jni.cxx   Wed Nov 13 17:48:56 2002
@@ -10,6 +10,7 @@
 #include "libtext/Text.hxx"
 #include "libutil/Vec23.hxx"
 #include "libutil/Debug.hxx"
+#include "libutil/buildmipmaps.hxx"
 
 #include "libos/Os.hxx"
 
@@ -585,6 +586,18 @@
     return ret;
 }
 
+bool hasGenMipmaps() {
+    static int initialized;
+    static bool hasExtension;
+    // XXX: the test should probably be done elsewhere
+    if (!initialized) {
+       hasExtension = strstr((const char *)glGetString(GL_EXTENSIONS), 
+                             "GL_SGIS_generate_mipmap") != 0;
+       initialized = true;
+    }
+    return hasExtension;
+}
+
 JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_impl_1Texture_1loadNull2D
   (JNIEnv *env, jclass, jint id, jint level, jstring internalFormat_s,
     jint w, jint h, jint border, jstring format_s, jstring type_s) {
@@ -693,15 +706,30 @@
 
       glBindTexture(target, id);
 
+      int buildmipmaps = 0;
+
       if (!shade_all_levels) {
-         glTexParameteri(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
-         GLERR;
+         if (hasGenMipmaps()) {
+             glTexParameteri(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
+             GLERR;
+         } else {
+             buildmipmaps = 1;
+         }
       } 
        
       int level;
       for (level = 0; ; level++) {
          s->render(&p, w, h, (d==0?1:d), comp, value);
 
+         if (buildmipmaps) {
+             assert(d==0); // 3D buildmipmaps not implemented in libutil
+             Util::buildmipmaps(GL_TEXTURE_2D, 
+                                tokenFromJstring(env, internalFormat),
+                                w, h, 
+                                tokenFromJstring(env, format),
+                                GL_FLOAT,
+                                value);
+         } else 
          if (d == 0)
              glTexImage2D(GL_TEXTURE_2D, level,
                           tokenFromJstring(env, internalFormat),
Index: gzz/gfx/libpaper/papermill.py
diff -u gzz/gfx/libpaper/papermill.py:1.60 gzz/gfx/libpaper/papermill.py:1.61
--- gzz/gfx/libpaper/papermill.py:1.60  Mon Nov 11 15:27:50 2002
+++ gzz/gfx/libpaper/papermill.py       Wed Nov 13 17:48:56 2002
@@ -58,7 +58,6 @@
     print "NEED FIX - DOES _NOT_ WORK : Using OpenGL 1.1 texenv and blending"
     from gfx.libpaper.texcomb_GL1_1 import *
 
-
 # Check whether anisotropic filtering is supported
 if GL.hasExtension("GL_EXT_texture_filter_anisotropic"):
     maxaniso = 2.0
@@ -144,6 +143,11 @@
 
     def getOptimizedPaper(self, seed, w, passmask = [1, 1, 1, 1, 1, 1, 1]):
        pap = self.getPaper(seed, passmask)
+
+        if not GL.hasExtension("GL_SGIS_generate_mipmap"):
+            print "Warning: not returning optimized paper because"
+            print "GL_SGIS_generate_mipmap extension is required but not 
available"
+            return pap
 
        # Now, we render a region.
        v = pap.repeat._getSTVectors()
Index: gzz/gfx/libutil/buildmipmaps.cxx
diff -u gzz/gfx/libutil/buildmipmaps.cxx:1.2 
gzz/gfx/libutil/buildmipmaps.cxx:1.3
--- gzz/gfx/libutil/buildmipmaps.cxx:1.2        Wed Aug  7 04:09:21 2002
+++ gzz/gfx/libutil/buildmipmaps.cxx    Wed Nov 13 17:48:56 2002
@@ -52,7 +52,7 @@
       int level = 0;
       char *data = new char[w * h * comp * 4];
 
-      do {
+      while (1) {
        int xf = w / w2;
        int yf = h / h2;
        switch (type) {
@@ -77,9 +77,11 @@
        glTexImage2D(target, level, intformat, w2, h2, 0, format, type, data);
        level++;
        
+       if (w2 <= 1 && h2 <= 1) break;
+
        w2 = w2 + 1 >> 1;
        h2 = h2 + 1 >> 1;
-      } while (w2 > 1 || h2 > 1);
+      }
       
       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, level - 1);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]