/[gzz]/gzz/gzz/gfx/gl/GLSpans.java
ViewVC logotype

Diff of /gzz/gzz/gfx/gl/GLSpans.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by tjl, Mon Sep 23 08:24:25 2002 UTC revision 1.6 by tjl, Mon Sep 23 14:38:31 2002 UTC
# Line 11  import java.awt.Dimension; Line 11  import java.awt.Dimension;
11  /** Manage image and page spans for OpenGL.  /** Manage image and page spans for OpenGL.
12   */   */
13  public class GLSpans {  public class GLSpans {
14        public static boolean dbg = false;
15        private static void pa(String s) { System.err.println(s); }
16        /** The format to use for monochrome spans.
17         */
18        public static String monochromeFormat;
19        /** The format to use for color spans.
20         */
21        public static String colorFormat;
22    
23        /** Determine which texture formats are supported.
24         */
25        private static void init() {
26            // If we have S3TC compression, we really need to make use of it.
27            if(GL.hasExtension("GL_EXT_texture_compression_s3tc")) {
28                monochromeFormat = "COMPRESSED_RGB_S3TC_DXT1_EXT";
29                colorFormat = "COMPRESSED_RGB_S3TC_DXT1_EXT";
30            } else {
31                // Otherwise, pick as small formats as possible: these are BIG images.
32                monochromeFormat = "LUMINANCE4";
33                colorFormat = "R3_G3_B2";
34            }
35            if(dbg) pa("GLSpans using monochrome and color formats "+monochromeFormat+
36                        ", "+colorFormat+", respectively");
37        }
38    
39      /** A rectangle in a texture.      /** A rectangle in a texture.
40       * XXX Make data members final       * XXX Make data members final
41       */       */
# Line 31  public class GLSpans { Line 56  public class GLSpans {
56    
57      static class LoadedTexRect {      static class LoadedTexRect {
58          LoadedTexRect(String file) {          LoadedTexRect(String file) {
59                if(monochromeFormat == null) init();
60              GL.Image img = GL.createImage(file);              GL.Image img = GL.createImage(file);
61              this.w = img.getSize(0);              this.w = img.getSize(0);
62              this.h = img.getSize(1);              this.h = img.getSize(1);
63              int overw = 1; while(overw < w) overw *= 2;              int overw = 1; while(overw < w) overw *= 2;
64              int overh = 1; while(overh < h) overh *= 2;              int overh = 1; while(overh < h) overh *= 2;
65              tex = GL.createTexture();              tex = GL.createTexture();
66              tex.loadNull2D(0, "R3_G3_B2", overw, overh, 0, "RGB", "FLOAT");              tex.loadNull2D(0, colorFormat, overw, overh, 0, "RGB", "FLOAT");
67              tex.loadSubImage(0, img, 0, 0);              tex.loadSubImage(0, img, 0, 0);
68              // tex.shade(overw, overh, 0, 1, "LUMINANCE4", "LUMINANCE", "noise", new String[] {});              // tex.shade(overw, overh, 0, 1, "LUMINANCE4", "LUMINANCE", "noise", new String[] {});
69              rect = new Rect();              rect = new Rect();

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26