aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChien Yang <[email protected]>2007-02-28 23:35:03 +0000
committerChien Yang <[email protected]>2007-02-28 23:35:03 +0000
commit1856fc92c798ef83af1fc8695eaf060122dd18ca (patch)
tree98e8833661feb365a90b8a316060060fde753087
parent537cac28344a39da93b0b2d4900d215bc56cbead (diff)
1) OGL and JOGL only : Fix to Issue 415 : Need ability to disable NPOT textures for raster/background
2) Minor fix on when to call setHasMultiSample(). At present this method is not called, but getHasMultiSample() is used. git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@781 ba19aa83-45c5-6ac9-afd3-db810772062c
-rw-r--r--src/classes/jogl/javax/media/j3d/JoglContext.java3
-rw-r--r--src/classes/jogl/javax/media/j3d/JoglPipeline.java36
-rw-r--r--src/classes/share/javax/media/j3d/Canvas3D.java8
-rw-r--r--src/classes/share/javax/media/j3d/Texture.java38
-rw-r--r--src/classes/share/javax/media/j3d/Texture3D.java23
-rw-r--r--src/native/ogl/Canvas3D.c16
6 files changed, 40 insertions, 84 deletions
diff --git a/src/classes/jogl/javax/media/j3d/JoglContext.java b/src/classes/jogl/javax/media/j3d/JoglContext.java
index 90923f6..211507b 100644
--- a/src/classes/jogl/javax/media/j3d/JoglContext.java
+++ b/src/classes/jogl/javax/media/j3d/JoglContext.java
@@ -28,6 +28,7 @@ class JoglContext implements Context {
private int currentTextureUnit;
private int currentCombinerUnit;
private boolean hasMultisample;
+ private boolean hasTextureNonPowerOfTwo;
// Needed for vertex attribute implementation
private JoglShaderObject shaderProgram;
@@ -168,6 +169,8 @@ class JoglContext implements Context {
void setCurrentCombinerUnit(int val) { currentCombinerUnit = val; }
boolean getHasMultisample() { return hasMultisample; }
void setHasMultisample(boolean val){ hasMultisample = val; }
+ boolean getHasTextureNonPowerOfTwo() { return hasTextureNonPowerOfTwo; }
+ void setHasTextureNonPowerOfTwo(boolean val){ hasTextureNonPowerOfTwo = val; }
// Helpers for vertex attribute methods
void initCgVertexAttributeImpl() {
diff --git a/src/classes/jogl/javax/media/j3d/JoglPipeline.java b/src/classes/jogl/javax/media/j3d/JoglPipeline.java
index 8a16114..7b6b6b7 100644
--- a/src/classes/jogl/javax/media/j3d/JoglPipeline.java
+++ b/src/classes/jogl/javax/media/j3d/JoglPipeline.java
@@ -5781,12 +5781,8 @@ class JoglPipeline extends Pipeline {
int type = GL.GL_UNSIGNED_INT_8_8_8_8;
boolean forceAlphaToOne = false;
- // check if we are trying to draw NPOT on a system that doesn't support it
- boolean textureNonPowerOfTwoAvailable =
- gl.isExtensionAvailable("GL_ARB_texture_non_power_of_two") ||
- gl.isExtensionAvailable("GL_VERSION_2_0");
-
- if (!textureNonPowerOfTwoAvailable &&
+ // check if we are trying to draw NPOT on a system that doesn't support it
+ if (!(((JoglContext) ctx).getHasTextureNonPowerOfTwo()) &&
(!isPowerOfTwo(width) || !isPowerOfTwo(height) || !isPowerOfTwo(depth))) {
// disable texture by setting width, height and depth to 0
width = height = depth = 0;
@@ -5958,11 +5954,7 @@ class JoglPipeline extends Pipeline {
// if NPOT textures are not supported, check if h=w=0, if so we have been
// disabled due to a NPOT texture being sent to a context that doesn't
// support it: disable the glTexSubImage as well
- boolean textureNonPowerOfTwoAvailable =
- gl.isExtensionAvailable("GL_ARB_texture_non_power_of_two") ||
- gl.isExtensionAvailable("GL_VERSION_2_0");
-
- if (!textureNonPowerOfTwoAvailable) {
+ if (!(((JoglContext) ctx).getHasTextureNonPowerOfTwo())) {
int[] tmp = new int[1];
int texWidth, texHeight, texDepth;
gl.glGetTexLevelParameteriv(GL.GL_TEXTURE_2D, 0, GL.GL_TEXTURE_WIDTH, tmp, 0);
@@ -6342,11 +6334,7 @@ class JoglPipeline extends Pipeline {
boolean forceAlphaToOne = false;
// check if we are trying to draw NPOT on a system that doesn't support it
- boolean textureNonPowerOfTwoAvailable =
- gl.isExtensionAvailable("GL_ARB_texture_non_power_of_two") ||
- gl.isExtensionAvailable("GL_VERSION_2_0");
-
- if (!textureNonPowerOfTwoAvailable &&
+ if (!(((JoglContext) ctx).getHasTextureNonPowerOfTwo()) &&
(!isPowerOfTwo(width) || !isPowerOfTwo(height))) {
// disable texture by setting width and height to 0
width = height = 0;
@@ -6509,11 +6497,7 @@ class JoglPipeline extends Pipeline {
// if NPOT textures are not supported, check if h=w=0, if so we have been
// disabled due to a NPOT texture being sent to a context that doesn't
// support it: disable the glTexSubImage as well
- boolean textureNonPowerOfTwoAvailable =
- gl.isExtensionAvailable("GL_ARB_texture_non_power_of_two") ||
- gl.isExtensionAvailable("GL_VERSION_2_0");
-
- if (!textureNonPowerOfTwoAvailable) {
+ if (!(((JoglContext) ctx).getHasTextureNonPowerOfTwo())) {
int[] tmp = new int[1];
int texWidth, texHeight;
gl.glGetTexLevelParameteriv(GL.GL_TEXTURE_2D, 0, GL.GL_TEXTURE_WIDTH, tmp, 0);
@@ -8309,8 +8293,10 @@ class JoglPipeline extends Pipeline {
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_LOD_OFFSET;
}
- if (gl.isExtensionAvailable("GL_ARB_texture_non_power_of_two")) {
+ if (!VirtualUniverse.mc.enforcePowerOfTwo &&
+ gl.isExtensionAvailable("GL_ARB_texture_non_power_of_two")) {
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_NON_POWER_OF_TWO;
+ ctx.setHasTextureNonPowerOfTwo(true);
}
}
@@ -8501,7 +8487,10 @@ class JoglPipeline extends Pipeline {
// look for OpenGL 2.0 features
if (gl20) {
- cv.textureExtendedFeatures |= Canvas3D.TEXTURE_NON_POWER_OF_TWO;
+ if(!VirtualUniverse.mc.enforcePowerOfTwo) {
+ cv.textureExtendedFeatures |= Canvas3D.TEXTURE_NON_POWER_OF_TWO;
+ ctx.setHasTextureNonPowerOfTwo(true);
+ }
}
// Setup GL_EXT_abgr
@@ -8516,6 +8505,7 @@ class JoglPipeline extends Pipeline {
// FIXME: this is not correct for the Windows platform yet
if (gl13) {
cv.extensionsSupported |= Canvas3D.MULTISAMPLE;
+ ctx.setHasMultisample(true);
}
if ((cv.extensionsSupported & Canvas3D.MULTISAMPLE) != 0 &&
diff --git a/src/classes/share/javax/media/j3d/Canvas3D.java b/src/classes/share/javax/media/j3d/Canvas3D.java
index 547c62f..8981551 100644
--- a/src/classes/share/javax/media/j3d/Canvas3D.java
+++ b/src/classes/share/javax/media/j3d/Canvas3D.java
@@ -3723,12 +3723,8 @@ public class Canvas3D extends Canvas {
(textureExtendedFeatures & TEXTURE_LOD_OFFSET) != 0));
keys.add("textureNonPowerOfTwoAvailable");
- if (VirtualUniverse.mc.enforcePowerOfTwo) {
- values.add(Boolean.FALSE);
- } else {
- values.add(new Boolean(
- (textureExtendedFeatures & TEXTURE_NON_POWER_OF_TWO) != 0));
- }
+ values.add(new Boolean(
+ (textureExtendedFeatures & TEXTURE_NON_POWER_OF_TWO) != 0));
keys.add("textureCoordSetsMax");
values.add(new Integer(maxTexCoordSets));
diff --git a/src/classes/share/javax/media/j3d/Texture.java b/src/classes/share/javax/media/j3d/Texture.java
index 883d33a..5d7bc2c 100644
--- a/src/classes/share/javax/media/j3d/Texture.java
+++ b/src/classes/share/javax/media/j3d/Texture.java
@@ -642,20 +642,10 @@ public abstract class Texture extends NodeComponent {
}
int widthLevels;
- int heightLevels;
-
- if (VirtualUniverse.mc.enforcePowerOfTwo) {
- widthLevels = getPowerOf2(width);
- if (widthLevels == -1)
- throw new IllegalArgumentException(J3dI18N.getString("Texture2"));
-
- heightLevels = getPowerOf2(height);
- if (heightLevels == -1)
- throw new IllegalArgumentException(J3dI18N.getString("Texture3"));
- } else {
- widthLevels = getLevelsNPOT(width);
- heightLevels = getLevelsNPOT(height);
- }
+ int heightLevels;
+
+ widthLevels = getLevelsNPOT(width);
+ heightLevels = getLevelsNPOT(height);
((TextureRetained)this.retained).initialize(format, width, widthLevels,
height, heightLevels, mipMapMode, 0);
@@ -716,21 +706,11 @@ public abstract class Texture extends NodeComponent {
throw new IllegalArgumentException(J3dI18N.getString("Texture47"));
}
- int widthLevels;
- int heightLevels;
-
- if (VirtualUniverse.mc.enforcePowerOfTwo) {
- widthLevels = getPowerOf2(width);
- if (widthLevels == -1)
- throw new IllegalArgumentException(J3dI18N.getString("Texture2"));
-
- heightLevels = getPowerOf2(height);
- if (heightLevels == -1)
- throw new IllegalArgumentException(J3dI18N.getString("Texture3"));
- } else {
- widthLevels = getLevelsNPOT(width);
- heightLevels = getLevelsNPOT(height);
- }
+ int widthLevels;
+ int heightLevels;
+
+ widthLevels = getLevelsNPOT(width);
+ heightLevels = getLevelsNPOT(height);
if (boundaryWidth < 0 || boundaryWidth > 1)
throw new IllegalArgumentException(J3dI18N.getString("Texture30"));
diff --git a/src/classes/share/javax/media/j3d/Texture3D.java b/src/classes/share/javax/media/j3d/Texture3D.java
index 73e5a51..fec5886 100644
--- a/src/classes/share/javax/media/j3d/Texture3D.java
+++ b/src/classes/share/javax/media/j3d/Texture3D.java
@@ -78,15 +78,9 @@ public class Texture3D extends Texture {
super(mipmapMode, format, width, height);
int depthLevels = -1;
- if (VirtualUniverse.mc.enforcePowerOfTwo) {
- depthLevels = getPowerOf2(depth);
- if (depthLevels == -1)
- throw new IllegalArgumentException(J3dI18N.getString("Texture3D1"));
-
- } else {
- depthLevels = getLevelsNPOT(depth);
- }
-
+
+ depthLevels = getLevelsNPOT(depth);
+
// TODO : Need to verify whether this is a bug. Why depthLevels isn't
// use to determine maxMipMapLevels ? See also Texture.java
@@ -131,16 +125,7 @@ public class Texture3D extends Texture {
super(mipmapMode, format, width, height, boundaryWidth);
int depthLevels = -1;
- if (VirtualUniverse.mc.enforcePowerOfTwo) {
- depthLevels = getPowerOf2(depth);
-
- if (depthLevels == -1)
- throw new IllegalArgumentException(J3dI18N.getString("Texture3D1"));
- }
- else {
- depthLevels = getLevelsNPOT(depth);
-
- }
+ depthLevels = getLevelsNPOT(depth);
// TODO : Need to verify whether this is a bug. Why depthLevels isn't
// use to determine maxMipMapLevels ? See also Texture.java
diff --git a/src/native/ogl/Canvas3D.c b/src/native/ogl/Canvas3D.c
index 345da07..f1dac23 100644
--- a/src/native/ogl/Canvas3D.c
+++ b/src/native/ogl/Canvas3D.c
@@ -376,9 +376,9 @@ checkTextureExtensions(
ctxInfo->textureExtMask |=
javax_media_j3d_Canvas3D_TEXTURE_LOD_OFFSET;
}
-
- if (isExtensionSupported(tmpExtensionStr,
- "GL_ARB_texture_non_power_of_two")) {
+
+ if (isExtensionSupported(tmpExtensionStr, "GL_ARB_texture_non_power_of_two") &&
+ !getJavaBoolEnv(env, "enforcePowerOfTwo")) {
ctxInfo->textureNonPowerOfTwoAvailable = JNI_TRUE;
ctxInfo->textureExtMask |=
javax_media_j3d_Canvas3D_TEXTURE_NON_POWER_OF_TWO;
@@ -650,10 +650,12 @@ getPropertiesFromCurrentContext(
/* look for OpenGL 2.0 features */
- if (ctxInfo->gl20) {
- ctxInfo->textureNonPowerOfTwoAvailable = JNI_TRUE;
- ctxInfo->textureExtMask |=
- javax_media_j3d_Canvas3D_TEXTURE_NON_POWER_OF_TWO;
+ if (ctxInfo->gl20) {
+ if (!getJavaBoolEnv(env, "enforcePowerOfTwo")) {
+ ctxInfo->textureNonPowerOfTwoAvailable = JNI_TRUE;
+ ctxInfo->textureExtMask |=
+ javax_media_j3d_Canvas3D_TEXTURE_NON_POWER_OF_TWO;
+ }
}
/* check extensions for remaining of 1.1 and 1.2 */