aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/classes/share/javax/media/j3d/Canvas3D.java4
-rw-r--r--src/classes/share/javax/media/j3d/FreeListManager.java9
-rw-r--r--src/classes/share/javax/media/j3d/J3DGraphics2DImpl.java5
-rw-r--r--src/classes/share/javax/media/j3d/JoglPipeline.java12
-rw-r--r--src/classes/share/javax/media/j3d/MasterControl.java49
-rw-r--r--src/classes/share/javax/media/j3d/NoopPipeline.java4
-rw-r--r--src/classes/share/javax/media/j3d/Pipeline.java1
-rw-r--r--src/classes/share/javax/media/j3d/Texture3DRetained.java20
-rw-r--r--src/classes/share/javax/media/j3d/TextureRetained.java18
9 files changed, 29 insertions, 93 deletions
diff --git a/src/classes/share/javax/media/j3d/Canvas3D.java b/src/classes/share/javax/media/j3d/Canvas3D.java
index e7b9ec8..44a6c02 100644
--- a/src/classes/share/javax/media/j3d/Canvas3D.java
+++ b/src/classes/share/javax/media/j3d/Canvas3D.java
@@ -4884,6 +4884,10 @@ void swapBuffers(Context ctx, Drawable drawable) {
Pipeline.getPipeline().freeTexture(ctx, id);
}
+ static int generateTexID(Context ctx) {
+ return Pipeline.getPipeline().generateTexID(ctx);
+ }
+
void texturemapping(Context ctx,
int px, int py,
int xmin, int ymin, int xmax, int ymax,
diff --git a/src/classes/share/javax/media/j3d/FreeListManager.java b/src/classes/share/javax/media/j3d/FreeListManager.java
index e92ea7b..83e2c66 100644
--- a/src/classes/share/javax/media/j3d/FreeListManager.java
+++ b/src/classes/share/javax/media/j3d/FreeListManager.java
@@ -33,10 +33,8 @@ class FreeListManager {
// constants that represent the freelists managed by the Manager
static final int DISPLAYLIST = 0;
- static final int TEXTURE2D = 1;
- static final int TEXTURE3D = 2;
- private static int maxFreeListNum = 2;
+ private static int maxFreeListNum = 0;
// what list we are going to shrink next
private static int currlist = 0;
@@ -44,12 +42,9 @@ class FreeListManager {
static MemoryFreeList[] freelist = null;
static void createFreeLists() {
- maxFreeListNum = 2;
+ maxFreeListNum = 0;
freelist = new MemoryFreeList[maxFreeListNum+1];
freelist[DISPLAYLIST] = new IntegerFreeList();
- freelist[TEXTURE2D] = new IntegerFreeList();
- freelist[TEXTURE3D] = new IntegerFreeList();
-
}
// see if the current list can be shrunk
diff --git a/src/classes/share/javax/media/j3d/J3DGraphics2DImpl.java b/src/classes/share/javax/media/j3d/J3DGraphics2DImpl.java
index 189e79c..bd4a9b4 100644
--- a/src/classes/share/javax/media/j3d/J3DGraphics2DImpl.java
+++ b/src/classes/share/javax/media/j3d/J3DGraphics2DImpl.java
@@ -941,7 +941,6 @@ final class J3DGraphics2DImpl extends J3DGraphics2D {
if (objectId != -1) {
Canvas3D.freeTexture(canvas3d.ctx, objectId);
- VirtualUniverse.mc.freeTexture2DId(objectId);
objectId = -1;
}
@@ -1052,7 +1051,7 @@ final class J3DGraphics2DImpl extends J3DGraphics2D {
if (!initTexMap) {
if (objectId == -1) {
- objectId = VirtualUniverse.mc.getTexture2DId();
+ objectId = Canvas3D.generateTexID(canvas3d.ctx);
}
texWidth = getGreaterPowerOf2(w);
texHeight = getGreaterPowerOf2(h);
@@ -1065,7 +1064,7 @@ final class J3DGraphics2DImpl extends J3DGraphics2D {
// Fail to get the texture surface, most likely
// there is not enough texture memory
initTexMap = false;
- VirtualUniverse.mc.freeTexture2DId(objectId);
+ Canvas3D.freeTexture(canvas3d.ctx, objectId);
objectId = -1;
// TODO : Need to find a better way to report no resource problem --- Chien.
System.err.println("J3DGraphics2DImpl.copyDataToCanvas() : Fail to get texture resources ...");
diff --git a/src/classes/share/javax/media/j3d/JoglPipeline.java b/src/classes/share/javax/media/j3d/JoglPipeline.java
index e3d7415..714c013 100644
--- a/src/classes/share/javax/media/j3d/JoglPipeline.java
+++ b/src/classes/share/javax/media/j3d/JoglPipeline.java
@@ -7223,6 +7223,18 @@ void swapBuffers(Canvas3D cv, Context ctx, Drawable drawable) {
}
}
+ int generateTexID(Context ctx) {
+ if (VERBOSE) System.err.println("JoglPipeline.generateTexID()");
+
+ GL gl = context(ctx).getGL();
+ int[] tmp = new int[] { -1 };
+ gl.glGenTextures(1, tmp, 0);
+
+ if (tmp[0] < 1)
+ return -1;
+
+ return tmp[0];
+ }
void texturemapping(Context ctx,
int px, int py,
diff --git a/src/classes/share/javax/media/j3d/MasterControl.java b/src/classes/share/javax/media/j3d/MasterControl.java
index 9e5e8c6..18b0c2a 100644
--- a/src/classes/share/javax/media/j3d/MasterControl.java
+++ b/src/classes/share/javax/media/j3d/MasterControl.java
@@ -311,12 +311,6 @@ class MasterControl {
*/
static long systemStartTime = 0L;
- // This is a counter for texture id's, valid id starts from 1
- private int textureIdCount = 0;
-
- // This is lock for both 2D/3D textureIds;
- private Object textureIdLock = new Object();
-
// This is a time stamp used when context is created
private long contextTimeStamp = 0;
@@ -924,49 +918,6 @@ private static String getProperty(final String prop) {
FreeListManager.freeObject(FreeListManager.DISPLAYLIST, id);
}
- /**
- * This returns the a unused textureId
- */
- int getTexture2DId() {
- // MasterControl has to handle the ID itself. 2D and 3D ideas must
- // never be the same, so the counter has to be in the MasterControl
- MemoryFreeList textureIds =
- FreeListManager.getFreeList(FreeListManager.TEXTURE2D);
- int id;
-
- synchronized (textureIdLock) {
- if (textureIds.size() > 0) {
- id = ((Integer)FreeListManager.
- getObject(FreeListManager.TEXTURE2D)).intValue();
- } else {
- id = (++textureIdCount);
- }
- return id;
- }
- }
-
- int getTexture3DId() {
- // MasterControl has to handle the ID itself. 2D and 3D ideas must
- // never be the same, so the counter has to be in the MasterControl
- MemoryFreeList textureIds =
- FreeListManager.getFreeList(FreeListManager.TEXTURE3D);
- synchronized (textureIdLock) {
- if (textureIds.size > 0) {
- return ((Integer)FreeListManager.
- getObject(FreeListManager.TEXTURE3D)).intValue();
- }
- else return (++textureIdCount);
- }
- }
-
- void freeTexture2DId(int id) {
- FreeListManager.freeObject(FreeListManager.TEXTURE2D, new Integer(id));
- }
-
- void freeTexture3DId(int id) {
- FreeListManager.freeObject(FreeListManager.TEXTURE3D, new Integer(id));
- }
-
int getCanvasId() {
int i;
diff --git a/src/classes/share/javax/media/j3d/NoopPipeline.java b/src/classes/share/javax/media/j3d/NoopPipeline.java
index 7fa9659..4c0011c 100644
--- a/src/classes/share/javax/media/j3d/NoopPipeline.java
+++ b/src/classes/share/javax/media/j3d/NoopPipeline.java
@@ -1161,6 +1161,10 @@ void swapBuffers(Canvas3D cv, Context ctx, Drawable drawable) {}
void freeTexture(Context ctx, int id) {
}
+ int generateTexID(Context ctx) {
+ return 0;
+ }
+
void texturemapping(Context ctx,
int px, int py,
int xmin, int ymin, int xmax, int ymax,
diff --git a/src/classes/share/javax/media/j3d/Pipeline.java b/src/classes/share/javax/media/j3d/Pipeline.java
index 5caaf1e..baa2c12 100644
--- a/src/classes/share/javax/media/j3d/Pipeline.java
+++ b/src/classes/share/javax/media/j3d/Pipeline.java
@@ -1106,6 +1106,7 @@ public Pipeline run() {
abstract void freeDisplayList(Context ctx, int id);
abstract void freeTexture(Context ctx, int id);
+ abstract int generateTexID(Context ctx);
abstract void texturemapping(Context ctx,
int px, int py,
int xmin, int ymin, int xmax, int ymax,
diff --git a/src/classes/share/javax/media/j3d/Texture3DRetained.java b/src/classes/share/javax/media/j3d/Texture3DRetained.java
index c8840f9..616ff9e 100644
--- a/src/classes/share/javax/media/j3d/Texture3DRetained.java
+++ b/src/classes/share/javax/media/j3d/Texture3DRetained.java
@@ -146,26 +146,6 @@ class Texture3DRetained extends TextureRetained {
imageDataType, imageData, useAutoMipMapGeneration(cv));
}
-
- // get an ID for Texture3D
-
- int getTextureId() {
- return (VirtualUniverse.mc.getTexture3DId());
- }
-
-
- // get a Texture3D Id
-
- void freeTextureId(int id) {
- synchronized (resourceLock) {
- if (objectId == id) {
- objectId = -1;
- VirtualUniverse.mc.freeTexture3DId(id);
- }
- }
- }
-
-
// load level 0 image with null data pointer, just to enable
// mipmapping when level 0 is not the base level
diff --git a/src/classes/share/javax/media/j3d/TextureRetained.java b/src/classes/share/javax/media/j3d/TextureRetained.java
index e24f8a1..688a2ca 100644
--- a/src/classes/share/javax/media/j3d/TextureRetained.java
+++ b/src/classes/share/javax/media/j3d/TextureRetained.java
@@ -1102,20 +1102,11 @@ abstract class TextureRetained extends NodeComponentRetained {
lodOffsetX, lodOffsetY, lodOffsetZ);
}
-
- // get an ID for Texture 2D
- int getTextureId() {
- return (VirtualUniverse.mc.getTexture2DId());
- }
-
-
// free a Texture2D id
void freeTextureId(int id) {
synchronized (resourceLock) {
- if (objectId == id) {
- objectId = -1;
- VirtualUniverse.mc.freeTexture2DId(id);
- }
+ if (objectId == id)
+ objectId = -1;
}
}
@@ -1132,9 +1123,8 @@ abstract class TextureRetained extends NodeComponentRetained {
void bindTexture(Canvas3D cv) {
synchronized(resourceLock) {
- if (objectId == -1) {
- objectId = getTextureId();
- }
+ if (objectId == -1)
+ objectId = Canvas3D.generateTexID(cv.ctx);
cv.addTextureResource(objectId, this);
}
bindTexture(cv.ctx, objectId, isEnabled(cv));