gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz gfx/demo/opengl/texperf.py gfx/jni/GzzGL-jn...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz gfx/demo/opengl/texperf.py gfx/jni/GzzGL-jn...
Date: Mon, 23 Sep 2002 10:38:31 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        02/09/23 10:38:31

Modified files:
        gfx/demo/opengl: texperf.py 
        gfx/jni        : GzzGL-jni.cxx 
        gzz/gfx/gl     : GL.java GLSpans.java 

Log message:
        Use compressed textures if we have them

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/opengl/texperf.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/jni/GzzGL-jni.cxx.diff?tr1=1.29&tr2=1.30&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/GL.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/GLSpans.java.diff?tr1=1.5&tr2=1.6&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/opengl/texperf.py
diff -c gzz/gfx/demo/opengl/texperf.py:1.5 gzz/gfx/demo/opengl/texperf.py:1.6
*** gzz/gfx/demo/opengl/texperf.py:1.5  Mon Sep 23 08:45:25 2002
--- gzz/gfx/demo/opengl/texperf.py      Mon Sep 23 10:38:31 2002
***************
*** 14,23 ****
  #    Therefore, we'll be using that for quite a lot of things...
  
  forms = ("R3_G3_B2",)
  # sizes = (512,1024,)
  baselevels =(0,1,2,3,4,5)
  
! sizes = (512,)
  size = sizes[0]
  
  form = forms[0]
--- 14,27 ----
  #    Therefore, we'll be using that for quite a lot of things...
  
  forms = ("R3_G3_B2",)
+ # forms = ("COMPRESSED_RGB_S3TC_DXT1_EXT",)
  # sizes = (512,1024,)
  baselevels =(0,1,2,3,4,5)
+ downsamples = (0,1,2,3)
  
! ntex = 25
! 
! sizes = (1024,)
  size = sizes[0]
  
  form = forms[0]
***************
*** 32,45 ****
      global tex, texes
      tex = GL.createTexture()
      tex.loadNull2D(0, form, size, size, 0, "RGB", "UNSIGNED_BYTE")
!     tex.loadSubImage(0, img, 50, 50)
      # tex.shade(size, size, 0, 4, form, "RGBA", "waves", [])
      # tex.shade(size, size, 0, 4, form, "RGBA", "waves", [])
  
!     texes = [ GL.createTexture() for i in range(0, 50) ]
!     for t in texes:
!       tex.downsampleInto(t, "TEXTURE_2D", 0, form, "RGB")
! 
  
  def printTex(id):
      for i in range(0,1):
--- 36,46 ----
      global tex, texes
      tex = GL.createTexture()
      tex.loadNull2D(0, form, size, size, 0, "RGB", "UNSIGNED_BYTE")
!     tex.loadSubImage(0, img, 0, 0)
      # tex.shade(size, size, 0, 4, form, "RGBA", "waves", [])
      # tex.shade(size, size, 0, 4, form, "RGBA", "waves", [])
  
!     texes = [ GL.createTexture() for i in range(0, ntex) ]
  
  def printTex(id):
      for i in range(0,1):
***************
*** 65,72 ****
      def time(self):
        if not globals().has_key("texes"):
            maketex()
!       for s in sizes:
          for baselevel in baselevels:
            times = []
            for nt in range(0,len(texes)):
                vs = w.createVobScene()
--- 66,83 ----
      def time(self):
        if not globals().has_key("texes"):
            maketex()
!       for downsample in downsamples:
          for baselevel in baselevels:
+           for t in texes:
+               tex.downsampleInto(t, "TEXTURE_2D", downsample, form, "RGB")
+               GL.call("""
+                   BindTexture TEXTURE_2D %s
+                       TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
+                       TexParameter TEXTURE_2D TEXTURE_MIN_FILTER 
LINEAR_MIPMAP_LINEAR
+                       TexParameter TEXTURE_2D TEXTURE_BASE_LEVEL %s
+                   BindTexture TEXTURE_2D 0
+               """ % ( t.getTexId(), baselevel ))
+ 
            times = []
            for nt in range(0,len(texes)):
                vs = w.createVobScene()
***************
*** 83,92 ****
                        printTex(texid)
                    putnoc(vs, getDListNocoords("""
                        BindTexture TEXTURE_2D %s
!                       TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
!                       TexParameter TEXTURE_2D TEXTURE_MIN_FILTER 
LINEAR_MIPMAP_LINEAR
!                       TexParameter TEXTURE_2D TEXTURE_BASE_LEVEL %s
!                   """ % (texes[i].getTexId(), baselevel)))
                    vs.put(quad(), "T"+str(i), 50-i, 100+2*i, 100+2*i, 100, 100)
                niters = 30
                t = w.timeRender(vs, niters) / niters
--- 94,100 ----
                        printTex(texid)
                    putnoc(vs, getDListNocoords("""
                        BindTexture TEXTURE_2D %s
!                   """ % (texes[i].getTexId())))
                    vs.put(quad(), "T"+str(i), 50-i, 100+2*i, 100+2*i, 100, 100)
                niters = 30
                t = w.timeRender(vs, niters) / niters
***************
*** 95,101 ****
                if t > 0.3:
                    break
            print times
!           f = open("tmp/t_%s_%s_%s" % (form, size, baselevel), "w")
            for t in times:
                f.write(t)
            f.write("\n")
--- 103,109 ----
                if t > 0.3:
                    break
            print times
!           f = open("tmp/t_%s_%s_%s" % (form, size / (2**downsample), 
baselevel), "w")
            for t in times:
                f.write(t)
            f.write("\n")
Index: gzz/gfx/jni/GzzGL-jni.cxx
diff -c gzz/gfx/jni/GzzGL-jni.cxx:1.29 gzz/gfx/jni/GzzGL-jni.cxx:1.30
*** gzz/gfx/jni/GzzGL-jni.cxx:1.29      Mon Sep 23 07:15:42 2002
--- gzz/gfx/jni/GzzGL-jni.cxx   Mon Sep 23 10:38:31 2002
***************
*** 699,704 ****
--- 699,717 ----
        DBG(dbg) << "Deleted display list\n";
    }
  
+ JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_impl_1DisplayList_1call
+   (JNIEnv *, jclass, jint l, jint w) {
+       setWindow(w);
+       glCallList(l);
+       releaseWindow();
+ }
+ 
+ JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_impl_1DisplayList_1call0
+   (JNIEnv *, jclass, jint l) {
+       glCallList(l);
+ }
+ 
+ 
  // ByteVector
  //
  JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GL_createByteVectorImpl
Index: gzz/gzz/gfx/gl/GL.java
diff -c gzz/gzz/gfx/gl/GL.java:1.4 gzz/gzz/gfx/gl/GL.java:1.5
*** gzz/gzz/gfx/gl/GL.java:1.4  Mon Sep 23 07:15:42 2002
--- gzz/gzz/gfx/gl/GL.java      Mon Sep 23 10:38:31 2002
***************
*** 23,28 ****
--- 23,31 ----
  package gzz.gfx.gl;
  import java.awt.Rectangle;
  import java.awt.Dimension;
+ import java.util.Set;
+ import java.util.HashSet;
+ import java.util.StringTokenizer;
  import gzz.client.GraphicsAPI;
  
  /** The interface to the native OpenGL library.
***************
*** 399,404 ****
--- 402,408 ----
            impl_Texture_downsampleInto(getId(), into.getId(), target, 
levelFrom,
                    internalFormat, transferformat);
        }
+ 
      }
  
      /** Create a new OpenGL texture object.
***************
*** 493,498 ****
--- 497,508 ----
                                                    w.getId()); }
        public void compileCallGL(String s) 
                        { GL.compileCallGL(getId(), s); }
+       /** Call the display list in the given window.
+        */
+       public void call(Window w) { GL.impl_DisplayList_call(getId(), 
w.getId()); }
+       /** Call the display list in the default context.
+        */
+       public void call() { GL.impl_DisplayList_call0(getId()); }
      }
      static public DisplayList createDisplayList() {
        return new DisplayList(createDisplayListImpl());
***************
*** 507,512 ****
--- 517,524 ----
      static private native void endCompile(int id, int wid);
      static private native void compileCallGL(int id, String s);
      static private native void deleteDisplayList(int id);
+     static private native void impl_DisplayList_call(int id, int winid);
+     static private native void impl_DisplayList_call0(int id);
  
  //---------- ByteVector
      static public class ByteVector extends NonRenderableJavaObject {
***************
*** 542,547 ****
--- 554,569 ----
  
  //----------Misc
  
+     public static void call(String s) {
+       DisplayList dl = createDisplayList(s);
+       dl.call();
+     }
+ 
+     public static void call(String s, Window w) {
+       DisplayList dl = createDisplayList(s);
+       dl.call(w);
+     }
+ 
      public static void render(
                Window win, int[] codes, float[] pts1, float[] pts2,
                int numpts, float fract, boolean standardcoords,
***************
*** 587,592 ****
--- 609,629 ----
      public static native float[] getGLFloat(String name);
      public static native float[] getGLTexParameterFloat(String target, int 
tex, String name);
      public static native float[] getGLTexLevelParameterFloat(String target, 
int tex, int level, String name);
+ 
+     private static Set extensions = null;
+     /** Return a boolean showing whether the given extension is supported
+      * by the current OpenGL environment.
+      */
+     public static boolean hasExtension(String name) {
+       if(extensions == null) {
+           extensions = new HashSet();
+           String s = getGLString("EXTENSIONS");
+           StringTokenizer st = new StringTokenizer(s);
+           while (st.hasMoreTokens()) 
+               extensions.add(st.nextToken());
+       }
+       return extensions.contains(name);
+     }
  
      /** Get the OpenGL token string corresponding to the given integer value.
       * This is useful for producing human-readable output from the result of 
getGLFloats.
Index: gzz/gzz/gfx/gl/GLSpans.java
diff -c gzz/gzz/gfx/gl/GLSpans.java:1.5 gzz/gzz/gfx/gl/GLSpans.java:1.6
*** gzz/gzz/gfx/gl/GLSpans.java:1.5     Mon Sep 23 04:24:25 2002
--- gzz/gzz/gfx/gl/GLSpans.java Mon Sep 23 10:38:31 2002
***************
*** 11,16 ****
--- 11,41 ----
  /** Manage image and page spans for OpenGL.
   */
  public class GLSpans {
+     public static boolean dbg = false;
+     private static void pa(String s) { System.err.println(s); }
+     /** The format to use for monochrome spans.
+      */
+     public static String monochromeFormat;
+     /** The format to use for color spans.
+      */
+     public static String colorFormat;
+ 
+     /** Determine which texture formats are supported.
+      */
+     private static void init() {
+       // If we have S3TC compression, we really need to make use of it. 
+       if(GL.hasExtension("GL_EXT_texture_compression_s3tc")) {
+           monochromeFormat = "COMPRESSED_RGB_S3TC_DXT1_EXT";
+           colorFormat = "COMPRESSED_RGB_S3TC_DXT1_EXT";
+       } else {
+           // Otherwise, pick as small formats as possible: these are BIG 
images.
+           monochromeFormat = "LUMINANCE4";
+           colorFormat = "R3_G3_B2";
+       }
+       if(dbg) pa("GLSpans using monochrome and color formats 
"+monochromeFormat+
+                   ", "+colorFormat+", respectively");
+     }
+ 
      /** A rectangle in a texture.
       * XXX Make data members final
       */
***************
*** 31,43 ****
  
      static class LoadedTexRect {
        LoadedTexRect(String file) {
            GL.Image img = GL.createImage(file);
            this.w = img.getSize(0);
            this.h = img.getSize(1);
            int overw = 1; while(overw < w) overw *= 2;
            int overh = 1; while(overh < h) overh *= 2;
            tex = GL.createTexture();
!           tex.loadNull2D(0, "R3_G3_B2", overw, overh, 0, "RGB", "FLOAT");
            tex.loadSubImage(0, img, 0, 0);
            // tex.shade(overw, overh, 0, 1, "LUMINANCE4", "LUMINANCE", 
"noise", new String[] {});
            rect = new Rect();
--- 56,69 ----
  
      static class LoadedTexRect {
        LoadedTexRect(String file) {
+           if(monochromeFormat == null) init();
            GL.Image img = GL.createImage(file);
            this.w = img.getSize(0);
            this.h = img.getSize(1);
            int overw = 1; while(overw < w) overw *= 2;
            int overh = 1; while(overh < h) overh *= 2;
            tex = GL.createTexture();
!           tex.loadNull2D(0, colorFormat, overw, overh, 0, "RGB", "FLOAT");
            tex.loadSubImage(0, img, 0, 0);
            // tex.shade(overw, overh, 0, 1, "LUMINANCE4", "LUMINANCE", 
"noise", new String[] {});
            rect = new Rect();




reply via email to

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