Normand Briere
2019-07-22 c570e1e38f2ff8622a71f81436654bad01cfdd5b
CameraPane.java
....@@ -45,6 +45,39 @@
4545
4646 static int STEP = 1;
4747
48
+ private static BufferedImage CreateBim(byte[] bytes, int width, int height)
49
+ {
50
+ int[] pixels = new int[bytes.length/3];
51
+ for (int i=pixels.length; --i>=0;)
52
+ {
53
+ int i3 = i*3;
54
+ pixels[i] = 0xFF;
55
+ pixels[i] <<= 8;
56
+ pixels[i] |= bytes[i3+2] & 0xFF;
57
+ pixels[i] <<= 8;
58
+ pixels[i] |= bytes[i3+1] & 0xFF;
59
+ pixels[i] <<= 8;
60
+ pixels[i] |= bytes[i3] & 0xFF;
61
+ }
62
+ /*
63
+ int r=0,g=0,b=0,a=0;
64
+ for (int i=0; i<width; i++)
65
+ for (int j=0; j<height; j++)
66
+ {
67
+ int index = j*width+i;
68
+ int p = pixels[index];
69
+ a = ((p>>24) & 0xFF);
70
+ r = ((p>>16) & 0xFF);
71
+ g = ((p>>8) & 0xFF);
72
+ b = (p & 0xFF);
73
+ pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
74
+ }
75
+ /**/
76
+ BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
77
+ rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
78
+ return rendImage;
79
+ }
80
+
4881 /*static*/ private boolean CULLFACE = false; // true;
4982 /*static*/ boolean NEAREST = false; // true;
5083 /*static*/ boolean WIREFRAME = false; // true;
....@@ -60,7 +93,7 @@
6093 //boolean REDUCETEXTURE = true;
6194 boolean CACHETEXTURE = true;
6295 boolean CLEANCACHE = false; // true;
63
- boolean MIPMAP = false; // true;
96
+ boolean MIPMAP = true; // false; // true;
6497 boolean COMPRESSTEXTURE = false;
6598 boolean KOMPACTTEXTURE = false; // true;
6699 boolean RESIZETEXTURE = false;
....@@ -2405,6 +2438,21 @@
24052438 return currentGL;
24062439 }
24072440
2441
+ static private BufferedImage CreateBim(TextureData texturedata)
2442
+ {
2443
+ Grafreed.Assert(texturedata != null);
2444
+
2445
+ int width = texturedata.getWidth();
2446
+ int height = texturedata.getHeight();
2447
+
2448
+ Buffer buffer = texturedata.getBuffer();
2449
+ ByteBuffer bytebuf = (ByteBuffer)buffer;
2450
+
2451
+ byte[] bytes = bytebuf.array();
2452
+
2453
+ return CreateBim(bytes, width, height);
2454
+ }
2455
+
24082456 /**/
24092457 class CacheTexture
24102458 {
....@@ -2413,28 +2461,31 @@
24132461
24142462 int resolution;
24152463
2416
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2464
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
24172465 {
2418
- texture = tex;
2466
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2467
+ texturedata = texdata;
24192468 resolution = res;
24202469 }
24212470 }
24222471 /**/
24232472
24242473 // 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>();
2474
+ static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>();
2475
+ static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>();
2476
+ static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>();
2477
+ static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>();
2478
+
24282479 int pigmentdepth = 0;
24292480 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24302481 int bumpdepth = 0;
24312482 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
24322483 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
24332484 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
2434
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2485
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
24352486 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
24362487
2437
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2488
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
24382489 {
24392490 TextureData texturedata = null;
24402491
....@@ -2453,13 +2504,34 @@
24532504 if (bump)
24542505 texturedata = ConvertBump(texturedata, false);
24552506
2456
- com.sun.opengl.util.texture.Texture texture =
2457
- com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2507
+// com.sun.opengl.util.texture.Texture texture =
2508
+// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
24582509
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);
2510
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2511
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
24612512
2462
- return texture;
2513
+ return texturedata;
2514
+ }
2515
+
2516
+ com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump)
2517
+ {
2518
+ TextureData texturedata = null;
2519
+
2520
+ try
2521
+ {
2522
+ texturedata =
2523
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2524
+ bim,
2525
+ true);
2526
+ } catch (Exception e)
2527
+ {
2528
+ throw new javax.media.opengl.GLException(e);
2529
+ }
2530
+
2531
+ if (bump)
2532
+ texturedata = ConvertBump(texturedata, false);
2533
+
2534
+ return texturedata;
24632535 }
24642536
24652537 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -3532,6 +3604,8 @@
35323604
35333605 System.out.println("LOADING TEXTURE : " + name);
35343606
3607
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3608
+
35353609 //
35363610 if (false) // compressbit > 0)
35373611 {
....@@ -7945,8 +8019,8 @@
79458019 pigment = null;
79468020 }
79478021
7948
- ReleaseTexture(bump, true);
7949
- ReleaseTexture(pigment, false);
8022
+ ReleaseTexture(tex, true);
8023
+ ReleaseTexture(tex, false);
79508024 }
79518025
79528026 public void ReleasePigmentTexture(cTexture tex) // INTERFACE
....@@ -7975,7 +8049,7 @@
79758049 pigment = null;
79768050 }
79778051
7978
- ReleaseTexture(pigment, false);
8052
+ ReleaseTexture(tex, false);
79798053 }
79808054
79818055 public void ReleaseBumpTexture(cTexture tex) // INTERFACE
....@@ -8004,10 +8078,10 @@
80048078 bump = null;
80058079 }
80068080
8007
- ReleaseTexture(bump, true);
8081
+ ReleaseTexture(tex, true);
80088082 }
80098083
8010
- void ReleaseTexture(String tex, boolean bump)
8084
+ void ReleaseTexture(cTexture tex, boolean bump)
80118085 {
80128086 if (// DrawMode() != 0 || /*tex == null ||*/
80138087 ambientOcclusion ) // || !textureon)
....@@ -8018,7 +8092,7 @@
80188092 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80198093
80208094 if (tex != null)
8021
- texture = textures.get(tex);
8095
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
80228096
80238097 // //assert( texture != null );
80248098 // if (texture == null)
....@@ -8112,47 +8186,50 @@
81128186
81138187 /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
81148188 {
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
- }
8189
+// if (// DrawMode() != 0 || /*tex == null ||*/
8190
+// ambientOcclusion ) // || !textureon)
8191
+// {
8192
+// return; // false;
8193
+// }
8194
+//
8195
+// if (tex == null)
8196
+// {
8197
+// BindTexture(null,false,resolution);
8198
+// BindTexture(null,true,resolution);
8199
+// return;
8200
+// }
8201
+//
8202
+// String pigment = Object3D.GetPigment(tex);
8203
+// String bump = Object3D.GetBump(tex);
8204
+//
8205
+// usedtextures.add(pigment);
8206
+// usedtextures.add(bump);
8207
+//
8208
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8209
+// {
8210
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8211
+// // System.out.println("; bump = " + bump);
8212
+// }
8213
+//
8214
+// if (bump.equals(""))
8215
+// {
8216
+// bump = null;
8217
+// }
8218
+// if (pigment.equals(""))
8219
+// {
8220
+// pigment = null;
8221
+// }
8222
+//
8223
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8224
+// BindTexture(pigment, false, resolution);
8225
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8226
+// BindTexture(bump, true, resolution);
8227
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8228
+//
8229
+// return; // true;
81278230
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;
8231
+ BindPigmentTexture(tex, resolution);
8232
+ BindBumpTexture(tex, resolution);
81568233 }
81578234
81588235 /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8171,7 +8248,7 @@
81718248
81728249 String pigment = Object3D.GetPigment(tex);
81738250
8174
- usedtextures.put(pigment, pigment);
8251
+ usedtextures.add(tex);
81758252
81768253 //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81778254 {
....@@ -8185,7 +8262,7 @@
81858262 }
81868263
81878264 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8188
- BindTexture(pigment, false, resolution);
8265
+ BindTexture(tex, false, resolution);
81898266 }
81908267
81918268 /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8204,7 +8281,7 @@
82048281
82058282 String bump = Object3D.GetBump(tex);
82068283
8207
- usedtextures.put(bump, bump);
8284
+ usedtextures.add(tex);
82088285
82098286 //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
82108287 {
....@@ -8218,7 +8295,7 @@
82188295 }
82198296
82208297 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8221
- BindTexture(bump, true, resolution);
8298
+ BindTexture(tex, true, resolution);
82228299 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
82238300 }
82248301
....@@ -8242,13 +8319,19 @@
82428319 return fileExists;
82438320 }
82448321
8245
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
8322
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
82468323 {
8247
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8324
+ CacheTexture texturecache = null;
82488325
82498326 if (tex != null)
82508327 {
8251
- String texname = tex;
8328
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8329
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
8330
+
8331
+ if (texname.equals("") && texdata == null)
8332
+ {
8333
+ return null;
8334
+ }
82528335
82538336 String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
82548337
....@@ -8258,19 +8341,34 @@
82588341 // else
82598342 // if (!texname.startsWith("/"))
82608343 // texname = "/Users/nbriere/Textures/" + texname;
8261
- if (!FileExists(tex))
8344
+ if (!FileExists(texname))
82628345 {
82638346 texname = fallbackTextureName;
82648347 }
82658348
82668349 if (CACHETEXTURE)
8267
- texture = textures.get(texname); // TEXTURE CACHE
8268
-
8269
- TextureData texturedata = null;
8270
-
8271
- if (texture == null || texture.resolution < resolution)
82728350 {
8273
- if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
8351
+ if (texdata == null)
8352
+ texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex);
8353
+ else
8354
+ texturecache = bimtextures.get(texdata);
8355
+ }
8356
+
8357
+ if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution)
8358
+ {
8359
+ TextureData texturedata = null;
8360
+
8361
+ if (texdata != null)
8362
+ {
8363
+ BufferedImage bim = //new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8364
+
8365
+ CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8366
+
8367
+ texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8368
+ bimtextures.put(texdata, texturecache);
8369
+ }
8370
+ else
8371
+ if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
82748372 {
82758373 assert(!bump);
82768374 // if (bump)
....@@ -8281,19 +8379,23 @@
82818379 // }
82828380 // else
82838381 // {
8284
- texture = textures.get(tex);
8285
- if (texture == null)
8382
+ // texturecache = textures.get(texname); // suspicious
8383
+ if (texturecache == null)
82868384 {
8287
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8385
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
82888386 }
8387
+ else
8388
+ new Exception().printStackTrace();
82898389 // }
82908390 } else
8291
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8391
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
82928392 {
82938393 assert(bump);
8294
- texture = textures.get(tex);
8295
- if (texture == null)
8296
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8394
+ // texturecache = textures.get(texname); // suspicious
8395
+ if (texturecache == null)
8396
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8397
+ else
8398
+ new Exception().printStackTrace();
82978399 } else
82988400 {
82998401 //if (tex.equals("IMMORTAL"))
....@@ -8301,11 +8403,13 @@
83018403 // texture = GetResourceTexture("default.png");
83028404 //} else
83038405 //{
8304
- if (tex.equals("WHITE_NOISE"))
8406
+ if (texname.endsWith("WHITE_NOISE"))
83058407 {
8306
- texture = textures.get(tex);
8307
- if (texture == null)
8308
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8408
+ // texturecache = textures.get(texname); // suspicious
8409
+ if (texturecache == null)
8410
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8411
+ else
8412
+ new Exception().printStackTrace();
83098413 } else
83108414 {
83118415 if (textureon)
....@@ -8364,19 +8468,19 @@
83648468 if (texturedata == null)
83658469 throw new Exception();
83668470
8367
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8471
+ texturecache = new CacheTexture(texturedata,resolution);
83688472 //texture = GetTexture(tex, bump);
83698473 }
83708474 }
83718475 //}
83728476 }
83738477
8374
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8478
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
83758479 {
83768480 //return false;
83778481
83788482 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8379
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8483
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
83808484 {
83818485 // String ext = "_highres";
83828486 // if (REDUCETEXTURE)
....@@ -8393,52 +8497,17 @@
83938497 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
83948498 if (!cachefile.exists())
83958499 {
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))
8500
+ //if (texturedata.getWidth() == texturedata.getHeight())
84058501 {
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);
8502
+ BufferedImage rendImage = CreateBim(texturedata);
8503
+
84368504 ImageWriter writer = null;
84378505 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
84388506 if (iter.hasNext()) {
84398507 writer = (ImageWriter)iter.next();
84408508 }
8441
- float compressionQuality = 0.9f;
8509
+
8510
+ float compressionQuality = 0.85f;
84428511 try
84438512 {
84448513 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8455,18 +8524,20 @@
84558524 }
84568525 }
84578526 }
8458
-
8527
+
8528
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8529
+
84598530 //System.out.println("Texture = " + tex);
8460
- if (textures.containsKey(texname))
8531
+ if (textures.containsKey(tex))
84618532 {
8462
- CacheTexture thetex = textures.get(texname);
8533
+ CacheTexture thetex = textures.get(tex);
84638534 thetex.texture.disable();
84648535 thetex.texture.dispose();
8465
- textures.remove(texname);
8536
+ textures.remove(tex);
84668537 }
84678538
8468
- texture.texturedata = texturedata;
8469
- textures.put(texname, texture);
8539
+ //texture.texturedata = texturedata;
8540
+ textures.put(tex, texturecache);
84708541
84718542 // newtex = true;
84728543 }
....@@ -8482,10 +8553,41 @@
84828553 }
84838554 }
84848555
8485
- return texture;
8556
+ return texturecache;
84868557 }
84878558
8488
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
8559
+ static void EmbedTextures(cTexture tex)
8560
+ {
8561
+ if (tex.pigmentdata == null)
8562
+ {
8563
+ String texname = Object3D.GetPigment(tex);
8564
+
8565
+ CacheTexture texturecache = texturepigment.get(tex);
8566
+
8567
+ if (texturecache != null)
8568
+ {
8569
+ tex.pigmentdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array();
8570
+ tex.pw = texturecache.texturedata.getWidth();
8571
+ tex.ph = texturecache.texturedata.getHeight();
8572
+ }
8573
+ }
8574
+
8575
+ if (tex.bumpdata == null)
8576
+ {
8577
+ String texname = Object3D.GetBump(tex);
8578
+
8579
+ CacheTexture texturecache = texturebump.get(tex);
8580
+
8581
+ if (texturecache != null)
8582
+ {
8583
+ tex.bumpdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array();
8584
+ tex.bw = texturecache.texturedata.getWidth();
8585
+ tex.bh = texturecache.texturedata.getHeight();
8586
+ }
8587
+ }
8588
+ }
8589
+
8590
+ com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception
84898591 {
84908592 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
84918593
....@@ -8503,14 +8605,14 @@
85038605 return texture!=null?texture.texture:null;
85048606 }
85058607
8506
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
8608
+ public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception
85078609 {
85088610 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
85098611
85108612 return texture!=null?texture.texturedata:null;
85118613 }
85128614
8513
- boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
8615
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
85148616 {
85158617 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
85168618 {
....@@ -11662,20 +11764,32 @@
1166211764 ReleaseTextures(DEFAULT_TEXTURES);
1166311765
1166411766 if (CLEANCACHE)
11665
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11767
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1166611768 {
11667
- String tex = e.nextElement();
11769
+ cTexture tex = e.nextElement();
1166811770
1166911771 // System.out.println("Texture --------- " + tex);
1167011772
11671
- if (tex.equals("WHITE_NOISE"))
11773
+ if (tex.equals("WHITE_NOISE:"))
1167211774 continue;
1167311775
11674
- if (!usedtextures.containsKey(tex))
11776
+ if (!usedtextures.contains(tex))
1167511777 {
11778
+ CacheTexture gettex = texturepigment.get(tex);
1167611779 // System.out.println("DISPOSE +++++++++++++++ " + tex);
11677
- textures.get(tex).texture.dispose();
11678
- textures.remove(tex);
11780
+ if (gettex != null)
11781
+ {
11782
+ gettex.texture.dispose();
11783
+ texturepigment.remove(tex);
11784
+ }
11785
+
11786
+ gettex = texturebump.get(tex);
11787
+ // System.out.println("DISPOSE +++++++++++++++ " + tex);
11788
+ if (gettex != null)
11789
+ {
11790
+ gettex.texture.dispose();
11791
+ texturebump.remove(tex);
11792
+ }
1167911793 }
1168011794 }
1168111795 }
....@@ -14868,7 +14982,8 @@
1486814982 // break;
1486914983 case 'T':
1487014984 CACHETEXTURE ^= true;
14871
- textures.clear();
14985
+ texturepigment.clear();
14986
+ texturebump.clear();
1487214987 // repaint();
1487314988 break;
1487414989 case 'Y':