.. | .. |
---|
18 | 18 | import javax.imageio.ImageIO; |
---|
19 | 19 | import javax.imageio.ImageWriteParam; |
---|
20 | 20 | import javax.imageio.ImageWriter; |
---|
| 21 | +import javax.imageio.ImageReadParam; |
---|
| 22 | +import javax.imageio.ImageReader; |
---|
21 | 23 | import javax.imageio.plugins.jpeg.JPEGImageWriteParam; |
---|
| 24 | +import javax.imageio.stream.ImageInputStream; |
---|
22 | 25 | import javax.imageio.stream.ImageOutputStream; |
---|
23 | 26 | import javax.imageio.ImageWriteParam; |
---|
24 | 27 | |
---|
.. | .. |
---|
30 | 33 | import java.nio.*; |
---|
31 | 34 | |
---|
32 | 35 | import gleem.linalg.Mat4f; |
---|
| 36 | +import javax.imageio.ImageTypeSpecifier; |
---|
33 | 37 | |
---|
34 | 38 | class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
35 | 39 | { |
---|
.. | .. |
---|
44 | 48 | static boolean ABORTED = false; |
---|
45 | 49 | |
---|
46 | 50 | static int STEP = 1; |
---|
| 51 | + |
---|
| 52 | + private static BufferedImage CreateBim(byte[] bytes, int width, int height) |
---|
| 53 | + { |
---|
| 54 | + int[] pixels = new int[bytes.length/3]; |
---|
| 55 | + for (int i=pixels.length; --i>=0;) |
---|
| 56 | + { |
---|
| 57 | + int i3 = i*3; |
---|
| 58 | + pixels[i] = 0xFF; |
---|
| 59 | + pixels[i] <<= 8; |
---|
| 60 | + pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 61 | + pixels[i] <<= 8; |
---|
| 62 | + pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 63 | + pixels[i] <<= 8; |
---|
| 64 | + pixels[i] |= bytes[i3] & 0xFF; |
---|
| 65 | + } |
---|
| 66 | + /* |
---|
| 67 | + int r=0,g=0,b=0,a=0; |
---|
| 68 | + for (int i=0; i<width; i++) |
---|
| 69 | + for (int j=0; j<height; j++) |
---|
| 70 | + { |
---|
| 71 | + int index = j*width+i; |
---|
| 72 | + int p = pixels[index]; |
---|
| 73 | + a = ((p>>24) & 0xFF); |
---|
| 74 | + r = ((p>>16) & 0xFF); |
---|
| 75 | + g = ((p>>8) & 0xFF); |
---|
| 76 | + b = (p & 0xFF); |
---|
| 77 | + pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
| 78 | + } |
---|
| 79 | + /**/ |
---|
| 80 | + BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
| 81 | + rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 82 | + return rendImage; |
---|
| 83 | + } |
---|
47 | 84 | |
---|
48 | 85 | /*static*/ private boolean CULLFACE = false; // true; |
---|
49 | 86 | /*static*/ boolean NEAREST = false; // true; |
---|
.. | .. |
---|
60 | 97 | //boolean REDUCETEXTURE = true; |
---|
61 | 98 | boolean CACHETEXTURE = true; |
---|
62 | 99 | boolean CLEANCACHE = false; // true; |
---|
63 | | - boolean MIPMAP = false; // true; |
---|
| 100 | + boolean MIPMAP = false; // true; // never works... |
---|
64 | 101 | boolean COMPRESSTEXTURE = false; |
---|
65 | 102 | boolean KOMPACTTEXTURE = false; // true; |
---|
66 | 103 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
2405 | 2442 | return currentGL; |
---|
2406 | 2443 | } |
---|
2407 | 2444 | |
---|
| 2445 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2446 | + { |
---|
| 2447 | + Grafreed.Assert(texturedata != null); |
---|
| 2448 | + |
---|
| 2449 | + int width = texturedata.getWidth(); |
---|
| 2450 | + int height = texturedata.getHeight(); |
---|
| 2451 | + |
---|
| 2452 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2453 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2454 | + |
---|
| 2455 | + byte[] bytes = bytebuf.array(); |
---|
| 2456 | + |
---|
| 2457 | + return CreateBim(bytes, width, height); |
---|
| 2458 | + } |
---|
| 2459 | + |
---|
2408 | 2460 | /**/ |
---|
2409 | 2461 | class CacheTexture |
---|
2410 | 2462 | { |
---|
.. | .. |
---|
2413 | 2465 | |
---|
2414 | 2466 | int resolution; |
---|
2415 | 2467 | |
---|
2416 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2468 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2417 | 2469 | { |
---|
2418 | | - texture = tex; |
---|
| 2470 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2471 | + texturedata = texdata; |
---|
2419 | 2472 | resolution = res; |
---|
2420 | 2473 | } |
---|
2421 | 2474 | } |
---|
2422 | 2475 | /**/ |
---|
2423 | 2476 | |
---|
2424 | 2477 | // TEXTURE static Texture texture; |
---|
2425 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
2426 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
2427 | | - static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>(); |
---|
| 2478 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2479 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2480 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2481 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2482 | + |
---|
2428 | 2483 | int pigmentdepth = 0; |
---|
2429 | 2484 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2430 | 2485 | int bumpdepth = 0; |
---|
2431 | 2486 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2432 | 2487 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2433 | 2488 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2434 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2489 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2435 | 2490 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2436 | 2491 | |
---|
2437 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2492 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2438 | 2493 | { |
---|
2439 | 2494 | TextureData texturedata = null; |
---|
2440 | 2495 | |
---|
.. | .. |
---|
2453 | 2508 | if (bump) |
---|
2454 | 2509 | texturedata = ConvertBump(texturedata, false); |
---|
2455 | 2510 | |
---|
2456 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2457 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2511 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2512 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
2458 | 2513 | |
---|
2459 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
2460 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2514 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2515 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
2461 | 2516 | |
---|
2462 | | - return texture; |
---|
| 2517 | + return texturedata; |
---|
| 2518 | + } |
---|
| 2519 | + |
---|
| 2520 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2521 | + { |
---|
| 2522 | + TextureData texturedata = null; |
---|
| 2523 | + |
---|
| 2524 | + try |
---|
| 2525 | + { |
---|
| 2526 | + texturedata = |
---|
| 2527 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2528 | + bim, |
---|
| 2529 | + true); |
---|
| 2530 | + } catch (Exception e) |
---|
| 2531 | + { |
---|
| 2532 | + throw new javax.media.opengl.GLException(e); |
---|
| 2533 | + } |
---|
| 2534 | + |
---|
| 2535 | + if (bump) |
---|
| 2536 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2537 | + |
---|
| 2538 | + return texturedata; |
---|
2463 | 2539 | } |
---|
2464 | 2540 | |
---|
2465 | 2541 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
3532 | 3608 | |
---|
3533 | 3609 | System.out.println("LOADING TEXTURE : " + name); |
---|
3534 | 3610 | |
---|
| 3611 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3612 | + |
---|
3535 | 3613 | // |
---|
3536 | 3614 | if (false) // compressbit > 0) |
---|
3537 | 3615 | { |
---|
.. | .. |
---|
7930 | 8008 | String pigment = Object3D.GetPigment(tex); |
---|
7931 | 8009 | String bump = Object3D.GetBump(tex); |
---|
7932 | 8010 | |
---|
7933 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8011 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7934 | 8012 | { |
---|
7935 | 8013 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7936 | 8014 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7945 | 8023 | pigment = null; |
---|
7946 | 8024 | } |
---|
7947 | 8025 | |
---|
7948 | | - ReleaseTexture(bump, true); |
---|
7949 | | - ReleaseTexture(pigment, false); |
---|
| 8026 | + ReleaseTexture(tex, true); |
---|
| 8027 | + ReleaseTexture(tex, false); |
---|
7950 | 8028 | } |
---|
7951 | 8029 | |
---|
7952 | 8030 | public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7964 | 8042 | |
---|
7965 | 8043 | String pigment = Object3D.GetPigment(tex); |
---|
7966 | 8044 | |
---|
7967 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8045 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7968 | 8046 | { |
---|
7969 | 8047 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7970 | 8048 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7975 | 8053 | pigment = null; |
---|
7976 | 8054 | } |
---|
7977 | 8055 | |
---|
7978 | | - ReleaseTexture(pigment, false); |
---|
| 8056 | + ReleaseTexture(tex, false); |
---|
7979 | 8057 | } |
---|
7980 | 8058 | |
---|
7981 | 8059 | public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7993 | 8071 | |
---|
7994 | 8072 | String bump = Object3D.GetBump(tex); |
---|
7995 | 8073 | |
---|
7996 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8074 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7997 | 8075 | { |
---|
7998 | 8076 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7999 | 8077 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8004 | 8082 | bump = null; |
---|
8005 | 8083 | } |
---|
8006 | 8084 | |
---|
8007 | | - ReleaseTexture(bump, true); |
---|
| 8085 | + ReleaseTexture(tex, true); |
---|
8008 | 8086 | } |
---|
8009 | 8087 | |
---|
8010 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8088 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
8011 | 8089 | { |
---|
8012 | 8090 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8013 | 8091 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
8018 | 8096 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
8019 | 8097 | |
---|
8020 | 8098 | if (tex != null) |
---|
8021 | | - texture = textures.get(tex); |
---|
| 8099 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
8022 | 8100 | |
---|
8023 | 8101 | // //assert( texture != null ); |
---|
8024 | 8102 | // if (texture == null) |
---|
.. | .. |
---|
8112 | 8190 | |
---|
8113 | 8191 | /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8114 | 8192 | { |
---|
8115 | | - if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8116 | | - ambientOcclusion ) // || !textureon) |
---|
8117 | | - { |
---|
8118 | | - return; // false; |
---|
8119 | | - } |
---|
8120 | | - |
---|
8121 | | - if (tex == null) |
---|
8122 | | - { |
---|
8123 | | - BindTexture(null,false,resolution); |
---|
8124 | | - BindTexture(null,true,resolution); |
---|
8125 | | - return; |
---|
8126 | | - } |
---|
| 8193 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8194 | +// ambientOcclusion ) // || !textureon) |
---|
| 8195 | +// { |
---|
| 8196 | +// return; // false; |
---|
| 8197 | +// } |
---|
| 8198 | +// |
---|
| 8199 | +// if (tex == null) |
---|
| 8200 | +// { |
---|
| 8201 | +// BindTexture(null,false,resolution); |
---|
| 8202 | +// BindTexture(null,true,resolution); |
---|
| 8203 | +// return; |
---|
| 8204 | +// } |
---|
| 8205 | +// |
---|
| 8206 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8207 | +// String bump = Object3D.GetBump(tex); |
---|
| 8208 | +// |
---|
| 8209 | +// usedtextures.add(pigment); |
---|
| 8210 | +// usedtextures.add(bump); |
---|
| 8211 | +// |
---|
| 8212 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8213 | +// { |
---|
| 8214 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8215 | +// // System.out.println("; bump = " + bump); |
---|
| 8216 | +// } |
---|
| 8217 | +// |
---|
| 8218 | +// if (bump.equals("")) |
---|
| 8219 | +// { |
---|
| 8220 | +// bump = null; |
---|
| 8221 | +// } |
---|
| 8222 | +// if (pigment.equals("")) |
---|
| 8223 | +// { |
---|
| 8224 | +// pigment = null; |
---|
| 8225 | +// } |
---|
| 8226 | +// |
---|
| 8227 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8228 | +// BindTexture(pigment, false, resolution); |
---|
| 8229 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8230 | +// BindTexture(bump, true, resolution); |
---|
| 8231 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8232 | +// |
---|
| 8233 | +// return; // true; |
---|
8127 | 8234 | |
---|
8128 | | - String pigment = Object3D.GetPigment(tex); |
---|
8129 | | - String bump = Object3D.GetBump(tex); |
---|
8130 | | - |
---|
8131 | | - usedtextures.put(pigment, pigment); |
---|
8132 | | - usedtextures.put(bump, bump); |
---|
8133 | | - |
---|
8134 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8135 | | - { |
---|
8136 | | - // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8137 | | - // System.out.println("; bump = " + bump); |
---|
8138 | | - } |
---|
8139 | | - |
---|
8140 | | - if (bump.equals("")) |
---|
8141 | | - { |
---|
8142 | | - bump = null; |
---|
8143 | | - } |
---|
8144 | | - if (pigment.equals("")) |
---|
8145 | | - { |
---|
8146 | | - pigment = null; |
---|
8147 | | - } |
---|
8148 | | - |
---|
8149 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8150 | | - BindTexture(pigment, false, resolution); |
---|
8151 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8152 | | - BindTexture(bump, true, resolution); |
---|
8153 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8154 | | - |
---|
8155 | | - return; // true; |
---|
| 8235 | + BindPigmentTexture(tex, resolution); |
---|
| 8236 | + BindBumpTexture(tex, resolution); |
---|
8156 | 8237 | } |
---|
8157 | 8238 | |
---|
8158 | 8239 | /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8171 | 8252 | |
---|
8172 | 8253 | String pigment = Object3D.GetPigment(tex); |
---|
8173 | 8254 | |
---|
8174 | | - usedtextures.put(pigment, pigment); |
---|
| 8255 | + usedtextures.add(tex); |
---|
8175 | 8256 | |
---|
8176 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8257 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8177 | 8258 | { |
---|
8178 | 8259 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8179 | 8260 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8185 | 8266 | } |
---|
8186 | 8267 | |
---|
8187 | 8268 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8188 | | - BindTexture(pigment, false, resolution); |
---|
| 8269 | + BindTexture(tex, false, resolution); |
---|
8189 | 8270 | } |
---|
8190 | 8271 | |
---|
8191 | 8272 | /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8204 | 8285 | |
---|
8205 | 8286 | String bump = Object3D.GetBump(tex); |
---|
8206 | 8287 | |
---|
8207 | | - usedtextures.put(bump, bump); |
---|
| 8288 | + usedtextures.add(tex); |
---|
8208 | 8289 | |
---|
8209 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8290 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8210 | 8291 | { |
---|
8211 | 8292 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8212 | 8293 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8218 | 8299 | } |
---|
8219 | 8300 | |
---|
8220 | 8301 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8221 | | - BindTexture(bump, true, resolution); |
---|
| 8302 | + BindTexture(tex, true, resolution); |
---|
8222 | 8303 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8223 | 8304 | } |
---|
8224 | 8305 | |
---|
.. | .. |
---|
8242 | 8323 | return fileExists; |
---|
8243 | 8324 | } |
---|
8244 | 8325 | |
---|
8245 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8326 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8246 | 8327 | { |
---|
8247 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8328 | + CacheTexture texturecache = null; |
---|
8248 | 8329 | |
---|
8249 | 8330 | if (tex != null) |
---|
8250 | 8331 | { |
---|
8251 | | - String texname = tex; |
---|
| 8332 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8333 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
| 8334 | + |
---|
| 8335 | + if (texname.equals("") && texdata == null) |
---|
| 8336 | + { |
---|
| 8337 | + return null; |
---|
| 8338 | + } |
---|
8252 | 8339 | |
---|
8253 | 8340 | String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
8254 | 8341 | |
---|
.. | .. |
---|
8258 | 8345 | // else |
---|
8259 | 8346 | // if (!texname.startsWith("/")) |
---|
8260 | 8347 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8261 | | - if (!FileExists(tex)) |
---|
| 8348 | + if (!FileExists(texname)) |
---|
8262 | 8349 | { |
---|
8263 | 8350 | texname = fallbackTextureName; |
---|
8264 | 8351 | } |
---|
8265 | 8352 | |
---|
8266 | 8353 | if (CACHETEXTURE) |
---|
8267 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8268 | | - |
---|
8269 | | - TextureData texturedata = null; |
---|
8270 | | - |
---|
8271 | | - if (texture == null || texture.resolution < resolution) |
---|
8272 | 8354 | { |
---|
8273 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8355 | + if (texdata == null) |
---|
| 8356 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8357 | + else |
---|
| 8358 | + texturecache = bimtextures.get(texdata); |
---|
| 8359 | + } |
---|
| 8360 | + |
---|
| 8361 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8362 | + { |
---|
| 8363 | + TextureData texturedata = null; |
---|
| 8364 | + |
---|
| 8365 | + if (texdata != null && textureon) |
---|
| 8366 | + { |
---|
| 8367 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8368 | + |
---|
| 8369 | + try |
---|
| 8370 | + { |
---|
| 8371 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8372 | + } |
---|
| 8373 | + catch (Exception e) |
---|
| 8374 | + { |
---|
| 8375 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8376 | + } |
---|
| 8377 | + |
---|
| 8378 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8379 | + bimtextures.put(texdata, texturecache); |
---|
| 8380 | + |
---|
| 8381 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8382 | + |
---|
| 8383 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8384 | + //bim2 = bim; |
---|
| 8385 | + } |
---|
| 8386 | + else |
---|
| 8387 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8274 | 8388 | { |
---|
8275 | 8389 | assert(!bump); |
---|
8276 | 8390 | // if (bump) |
---|
.. | .. |
---|
8281 | 8395 | // } |
---|
8282 | 8396 | // else |
---|
8283 | 8397 | // { |
---|
8284 | | - texture = textures.get(tex); |
---|
8285 | | - if (texture == null) |
---|
| 8398 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8399 | + if (texturecache == null) |
---|
8286 | 8400 | { |
---|
8287 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8401 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8288 | 8402 | } |
---|
| 8403 | + else |
---|
| 8404 | + new Exception().printStackTrace(); |
---|
8289 | 8405 | // } |
---|
8290 | 8406 | } else |
---|
8291 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8407 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8292 | 8408 | { |
---|
8293 | 8409 | assert(bump); |
---|
8294 | | - texture = textures.get(tex); |
---|
8295 | | - if (texture == null) |
---|
8296 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8410 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8411 | + if (texturecache == null) |
---|
| 8412 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8413 | + else |
---|
| 8414 | + new Exception().printStackTrace(); |
---|
8297 | 8415 | } else |
---|
8298 | 8416 | { |
---|
8299 | 8417 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8301 | 8419 | // texture = GetResourceTexture("default.png"); |
---|
8302 | 8420 | //} else |
---|
8303 | 8421 | //{ |
---|
8304 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8422 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8305 | 8423 | { |
---|
8306 | | - texture = textures.get(tex); |
---|
8307 | | - if (texture == null) |
---|
8308 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8424 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8425 | + if (texturecache == null) |
---|
| 8426 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8427 | + else |
---|
| 8428 | + new Exception().printStackTrace(); |
---|
8309 | 8429 | } else |
---|
8310 | 8430 | { |
---|
8311 | 8431 | if (textureon) |
---|
.. | .. |
---|
8364 | 8484 | if (texturedata == null) |
---|
8365 | 8485 | throw new Exception(); |
---|
8366 | 8486 | |
---|
8367 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8487 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8368 | 8488 | //texture = GetTexture(tex, bump); |
---|
8369 | 8489 | } |
---|
8370 | 8490 | } |
---|
8371 | 8491 | //} |
---|
8372 | 8492 | } |
---|
8373 | 8493 | |
---|
8374 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8494 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8375 | 8495 | { |
---|
8376 | 8496 | //return false; |
---|
8377 | 8497 | |
---|
8378 | 8498 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8379 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8499 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8380 | 8500 | { |
---|
8381 | 8501 | // String ext = "_highres"; |
---|
8382 | 8502 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8393 | 8513 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8394 | 8514 | if (!cachefile.exists()) |
---|
8395 | 8515 | { |
---|
8396 | | - // cache to disk |
---|
8397 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8398 | | - //buffers[0]. |
---|
8399 | | - |
---|
8400 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8401 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8402 | | - |
---|
8403 | | - // squared size heuristic... |
---|
8404 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8516 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8405 | 8517 | { |
---|
8406 | | - for (int i=pixels.length; --i>=0;) |
---|
8407 | | - { |
---|
8408 | | - int i3 = i*3; |
---|
8409 | | - pixels[i] = 0xFF; |
---|
8410 | | - pixels[i] <<= 8; |
---|
8411 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8412 | | - pixels[i] <<= 8; |
---|
8413 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8414 | | - pixels[i] <<= 8; |
---|
8415 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8416 | | - } |
---|
8417 | | - |
---|
8418 | | - /* |
---|
8419 | | - int r=0,g=0,b=0,a=0; |
---|
8420 | | - for (int i=0; i<width; i++) |
---|
8421 | | - for (int j=0; j<height; j++) |
---|
8422 | | - { |
---|
8423 | | - int index = j*width+i; |
---|
8424 | | - int p = pixels[index]; |
---|
8425 | | - a = ((p>>24) & 0xFF); |
---|
8426 | | - r = ((p>>16) & 0xFF); |
---|
8427 | | - g = ((p>>8) & 0xFF); |
---|
8428 | | - b = (p & 0xFF); |
---|
8429 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8430 | | - } |
---|
8431 | | - /**/ |
---|
8432 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8433 | | - int height = width; |
---|
8434 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8435 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8518 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8519 | + |
---|
8436 | 8520 | ImageWriter writer = null; |
---|
8437 | 8521 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8438 | 8522 | if (iter.hasNext()) { |
---|
8439 | 8523 | writer = (ImageWriter)iter.next(); |
---|
8440 | 8524 | } |
---|
8441 | | - float compressionQuality = 0.9f; |
---|
| 8525 | + |
---|
| 8526 | + float compressionQuality = 0.85f; |
---|
8442 | 8527 | try |
---|
8443 | 8528 | { |
---|
8444 | 8529 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8455 | 8540 | } |
---|
8456 | 8541 | } |
---|
8457 | 8542 | } |
---|
8458 | | - |
---|
| 8543 | + |
---|
| 8544 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8545 | + |
---|
8459 | 8546 | //System.out.println("Texture = " + tex); |
---|
8460 | | - if (textures.containsKey(texname)) |
---|
| 8547 | + if (textures.containsKey(tex)) |
---|
8461 | 8548 | { |
---|
8462 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8549 | + CacheTexture thetex = textures.get(tex); |
---|
8463 | 8550 | thetex.texture.disable(); |
---|
8464 | 8551 | thetex.texture.dispose(); |
---|
8465 | | - textures.remove(texname); |
---|
| 8552 | + textures.remove(tex); |
---|
8466 | 8553 | } |
---|
8467 | 8554 | |
---|
8468 | | - texture.texturedata = texturedata; |
---|
8469 | | - textures.put(texname, texture); |
---|
| 8555 | + //texture.texturedata = texturedata; |
---|
| 8556 | + textures.put(tex, texturecache); |
---|
8470 | 8557 | |
---|
8471 | 8558 | // newtex = true; |
---|
8472 | 8559 | } |
---|
.. | .. |
---|
8482 | 8569 | } |
---|
8483 | 8570 | } |
---|
8484 | 8571 | |
---|
8485 | | - return texture; |
---|
| 8572 | + return texturecache; |
---|
8486 | 8573 | } |
---|
8487 | 8574 | |
---|
8488 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8575 | + static void EmbedTextures(cTexture tex) |
---|
| 8576 | + { |
---|
| 8577 | + if (tex.pigmentdata == null) |
---|
| 8578 | + { |
---|
| 8579 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8580 | + |
---|
| 8581 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8582 | + |
---|
| 8583 | + if (texturecache != null) |
---|
| 8584 | + { |
---|
| 8585 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8586 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8587 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8588 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8589 | + ; |
---|
| 8590 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8591 | + } |
---|
| 8592 | + } |
---|
| 8593 | + |
---|
| 8594 | + if (tex.bumpdata == null) |
---|
| 8595 | + { |
---|
| 8596 | + //String texname = Object3D.GetBump(tex); |
---|
| 8597 | + |
---|
| 8598 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8599 | + |
---|
| 8600 | + if (texturecache != null) |
---|
| 8601 | + { |
---|
| 8602 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8603 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8604 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8605 | + } |
---|
| 8606 | + } |
---|
| 8607 | + } |
---|
| 8608 | + |
---|
| 8609 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8489 | 8610 | { |
---|
8490 | 8611 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8491 | 8612 | |
---|
.. | .. |
---|
8503 | 8624 | return texture!=null?texture.texture:null; |
---|
8504 | 8625 | } |
---|
8505 | 8626 | |
---|
8506 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception |
---|
| 8627 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8507 | 8628 | { |
---|
8508 | 8629 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8509 | 8630 | |
---|
8510 | 8631 | return texture!=null?texture.texturedata:null; |
---|
8511 | 8632 | } |
---|
8512 | 8633 | |
---|
8513 | | - com.sun.opengl.util.texture.Texture BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8634 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8514 | 8635 | { |
---|
8515 | 8636 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8516 | 8637 | { |
---|
8517 | 8638 | return false; |
---|
8518 | 8639 | } |
---|
8519 | 8640 | |
---|
8520 | | - boolean newtex = false; |
---|
| 8641 | + //boolean newtex = false; |
---|
8521 | 8642 | |
---|
8522 | 8643 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8523 | 8644 | |
---|
8524 | 8645 | if (texture == null) |
---|
8525 | | - return texture; |
---|
| 8646 | + return false; |
---|
8526 | 8647 | /**/ |
---|
8527 | 8648 | |
---|
8528 | 8649 | if (textureon || tex.equals("DEFAULT_TEXTURE") || tex.equals("DEFAULT_TEXTURE_BUMP") || tex.equals("WHITE_NOISE")) // || tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8549 | 8670 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8550 | 8671 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8551 | 8672 | |
---|
8552 | | - return newtex; |
---|
| 8673 | + return true; // Warning: not used. |
---|
8553 | 8674 | } |
---|
8554 | 8675 | |
---|
| 8676 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8677 | + { |
---|
| 8678 | + try |
---|
| 8679 | + { |
---|
| 8680 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8681 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8682 | + ImageWriter writer = writers.next(); |
---|
| 8683 | + |
---|
| 8684 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8685 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8686 | + param.setCompressionQuality(quality); |
---|
| 8687 | + |
---|
| 8688 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8689 | + writer.setOutput(ios); |
---|
| 8690 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8691 | + |
---|
| 8692 | + byte[] data = baos.toByteArray(); |
---|
| 8693 | + writer.dispose(); |
---|
| 8694 | + return data; |
---|
| 8695 | + } |
---|
| 8696 | + catch (Exception e) |
---|
| 8697 | + { |
---|
| 8698 | + e.printStackTrace(); |
---|
| 8699 | + return null; |
---|
| 8700 | + } |
---|
| 8701 | + } |
---|
| 8702 | + |
---|
| 8703 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8704 | + { |
---|
| 8705 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8706 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8707 | + ImageReader reader = writers.next(); |
---|
| 8708 | + |
---|
| 8709 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8710 | + |
---|
| 8711 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8712 | + param.setDestination(bim); |
---|
| 8713 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8714 | + |
---|
| 8715 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8716 | + reader.setInput(ios); |
---|
| 8717 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8718 | + reader.dispose(); |
---|
| 8719 | + |
---|
| 8720 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8721 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8722 | +// byte[] bytes = data.getData(); |
---|
| 8723 | +// |
---|
| 8724 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8725 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8726 | +// { |
---|
| 8727 | +// int i3 = i*3; |
---|
| 8728 | +// pixels[i] = 0xFF; |
---|
| 8729 | +// pixels[i] <<= 8; |
---|
| 8730 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8731 | +// pixels[i] <<= 8; |
---|
| 8732 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8733 | +// pixels[i] <<= 8; |
---|
| 8734 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8735 | +// } |
---|
| 8736 | +// |
---|
| 8737 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8738 | + |
---|
| 8739 | + return bim; |
---|
| 8740 | + } |
---|
| 8741 | + |
---|
8555 | 8742 | ShadowBuffer shadowPBuf; |
---|
8556 | 8743 | AntialiasBuffer antialiasPBuf; |
---|
8557 | 8744 | int MAXSTACK; |
---|
.. | .. |
---|
11297 | 11484 | } |
---|
11298 | 11485 | } |
---|
11299 | 11486 | |
---|
11300 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11487 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11301 | 11488 | { |
---|
11302 | 11489 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11303 | 11490 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11305 | 11492 | |
---|
11306 | 11493 | boolean texon = textureon; |
---|
11307 | 11494 | |
---|
11308 | | - if (RENDERPROGRAM > 0) |
---|
11309 | | - { |
---|
11310 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11311 | | - textureon = false; |
---|
11312 | | - } |
---|
| 11495 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11496 | + textureon = false; |
---|
| 11497 | + |
---|
11313 | 11498 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11314 | 11499 | //System.out.println("ALLO"); |
---|
11315 | 11500 | gl.glColorMask(false, false, false, false); |
---|
11316 | 11501 | DrawObject(gl); |
---|
11317 | | - if (RENDERPROGRAM > 0) |
---|
11318 | | - { |
---|
11319 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11320 | | - textureon = texon; |
---|
11321 | | - } |
---|
| 11502 | + |
---|
| 11503 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11504 | + textureon = texon; |
---|
| 11505 | + |
---|
11322 | 11506 | gl.glColorMask(true, true, true, true); |
---|
11323 | 11507 | |
---|
11324 | 11508 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11325 | | - //gl.glDepthMask(false); |
---|
| 11509 | + gl.glDepthMask(false); |
---|
11326 | 11510 | } |
---|
11327 | 11511 | |
---|
11328 | 11512 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11662 | 11846 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11663 | 11847 | |
---|
11664 | 11848 | if (CLEANCACHE) |
---|
11665 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11849 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11666 | 11850 | { |
---|
11667 | | - String tex = e.nextElement(); |
---|
| 11851 | + cTexture tex = e.nextElement(); |
---|
11668 | 11852 | |
---|
11669 | 11853 | // System.out.println("Texture --------- " + tex); |
---|
11670 | 11854 | |
---|
11671 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11855 | + if (tex.equals("WHITE_NOISE:")) |
---|
11672 | 11856 | continue; |
---|
11673 | 11857 | |
---|
11674 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11858 | + if (!usedtextures.contains(tex)) |
---|
11675 | 11859 | { |
---|
| 11860 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11676 | 11861 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11677 | | - textures.get(tex).texture.dispose(); |
---|
11678 | | - textures.remove(tex); |
---|
| 11862 | + if (gettex != null) |
---|
| 11863 | + { |
---|
| 11864 | + gettex.texture.dispose(); |
---|
| 11865 | + texturepigment.remove(tex); |
---|
| 11866 | + } |
---|
| 11867 | + |
---|
| 11868 | + gettex = texturebump.get(tex); |
---|
| 11869 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11870 | + if (gettex != null) |
---|
| 11871 | + { |
---|
| 11872 | + gettex.texture.dispose(); |
---|
| 11873 | + texturebump.remove(tex); |
---|
| 11874 | + } |
---|
11679 | 11875 | } |
---|
11680 | 11876 | } |
---|
11681 | 11877 | } |
---|
.. | .. |
---|
14868 | 15064 | // break; |
---|
14869 | 15065 | case 'T': |
---|
14870 | 15066 | CACHETEXTURE ^= true; |
---|
14871 | | - textures.clear(); |
---|
| 15067 | + texturepigment.clear(); |
---|
| 15068 | + texturebump.clear(); |
---|
14872 | 15069 | // repaint(); |
---|
14873 | 15070 | break; |
---|
14874 | 15071 | case 'Y': |
---|