diff options
-rw-r--r-- | src/classes/jogl/javax/media/j3d/JoglContext.java | 3 | ||||
-rw-r--r-- | src/classes/jogl/javax/media/j3d/JoglPipeline.java | 55 | ||||
-rw-r--r-- | src/classes/share/javax/media/j3d/TextureRetained.java | 40 | ||||
-rw-r--r-- | src/native/ogl/Attributes.c | 58 | ||||
-rw-r--r-- | src/native/ogl/Canvas3D.c | 3 | ||||
-rw-r--r-- | src/native/ogl/gldefs.h | 3 |
6 files changed, 28 insertions, 134 deletions
diff --git a/src/classes/jogl/javax/media/j3d/JoglContext.java b/src/classes/jogl/javax/media/j3d/JoglContext.java index 211507b..90923f6 100644 --- a/src/classes/jogl/javax/media/j3d/JoglContext.java +++ b/src/classes/jogl/javax/media/j3d/JoglContext.java @@ -28,7 +28,6 @@ class JoglContext implements Context { private int currentTextureUnit; private int currentCombinerUnit; private boolean hasMultisample; - private boolean hasTextureNonPowerOfTwo; // Needed for vertex attribute implementation private JoglShaderObject shaderProgram; @@ -169,8 +168,6 @@ 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 7b6b6b7..8e2c842 100644 --- a/src/classes/jogl/javax/media/j3d/JoglPipeline.java +++ b/src/classes/jogl/javax/media/j3d/JoglPipeline.java @@ -5781,13 +5781,6 @@ 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 - if (!(((JoglContext) ctx).getHasTextureNonPowerOfTwo()) && - (!isPowerOfTwo(width) || !isPowerOfTwo(height) || !isPowerOfTwo(depth))) { - // disable texture by setting width, height and depth to 0 - width = height = depth = 0; - } - switch (textureFormat) { case Texture.INTENSITY: internalFormat = GL.GL_INTENSITY; @@ -5950,24 +5943,6 @@ class JoglPipeline extends Pipeline { pixelStore = true; gl.glPixelStorei(GL.GL_UNPACK_ROW_LENGTH, tilew); } - - // 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 - 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); - texWidth = tmp[0]; - gl.glGetTexLevelParameteriv(GL.GL_TEXTURE_2D, 0, GL.GL_TEXTURE_HEIGHT, tmp, 0); - texHeight = tmp[0]; - gl.glGetTexLevelParameteriv(GL.GL_TEXTURE_2D, 0, GL.GL_TEXTURE_DEPTH, tmp, 0); - texDepth = tmp[0]; - if ((texWidth == 0) && (texHeight == 0) && (texDepth == 0)) { - // disable the sub-image by setting it's width, height and depth to 0 - width = height = depth = 0; - } - } switch (textureFormat) { case Texture.INTENSITY: @@ -6333,13 +6308,6 @@ 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 - if (!(((JoglContext) ctx).getHasTextureNonPowerOfTwo()) && - (!isPowerOfTwo(width) || !isPowerOfTwo(height))) { - // disable texture by setting width and height to 0 - width = height = 0; - } - switch (textureFormat) { case Texture.INTENSITY: internalFormat = GL.GL_INTENSITY; @@ -6494,22 +6462,6 @@ class JoglPipeline extends Pipeline { gl.glPixelStorei(GL.GL_UNPACK_ROW_LENGTH, tilew); } - // 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 - 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); - texWidth = tmp[0]; - gl.glGetTexLevelParameteriv(GL.GL_TEXTURE_2D, 0, GL.GL_TEXTURE_HEIGHT, tmp, 0); - texHeight = tmp[0]; - if ((texWidth == 0) && (texHeight == 0)) { - // disable the sub-image by setting it's width and height to 0 - width = height = 0; - } - } - switch (textureFormat) { case Texture.INTENSITY: internalFormat = GL.GL_INTENSITY; @@ -6659,11 +6611,6 @@ class JoglPipeline extends Pipeline { } - - private static boolean isPowerOfTwo(int val) { - return ((val & (val - 1)) == 0); - } - void updateTextureFilterModes(Context ctx, int target, int minFilter, @@ -8296,7 +8243,6 @@ class JoglPipeline extends Pipeline { if (!VirtualUniverse.mc.enforcePowerOfTwo && gl.isExtensionAvailable("GL_ARB_texture_non_power_of_two")) { cv.textureExtendedFeatures |= Canvas3D.TEXTURE_NON_POWER_OF_TWO; - ctx.setHasTextureNonPowerOfTwo(true); } } @@ -8489,7 +8435,6 @@ class JoglPipeline extends Pipeline { if (gl20) { if(!VirtualUniverse.mc.enforcePowerOfTwo) { cv.textureExtendedFeatures |= Canvas3D.TEXTURE_NON_POWER_OF_TWO; - ctx.setHasTextureNonPowerOfTwo(true); } } diff --git a/src/classes/share/javax/media/j3d/TextureRetained.java b/src/classes/share/javax/media/j3d/TextureRetained.java index 6ed41eb..7fa241e 100644 --- a/src/classes/share/javax/media/j3d/TextureRetained.java +++ b/src/classes/share/javax/media/j3d/TextureRetained.java @@ -68,7 +68,7 @@ abstract class TextureRetained extends NodeComponentRetained { int format = Texture.RGB; // Texture format int width = 1; // Width in pixels (2**n) int height = 1; // Height in pixels (2**m) - + private boolean widthOrHeightIsNPOT = false; // true if width or height is non power of two ImageComponentRetained images[][]; // Array of images (one for each mipmap level) boolean imagesLoaded = false; // TRUE if all mipmap levels are loaded int mipmapLevels; // Number of MIPMAP levels needed @@ -166,17 +166,24 @@ abstract class TextureRetained extends NodeComponentRetained { // need to synchronize access from multiple rendering threads Object resourceLock = new Object(); - + private static boolean isPowerOfTwo(int val) { + return ((val & (val - 1)) == 0); + } + void initialize(int format, int width, int widLevels, int height, int heiLevels, int mipmapMode, int boundaryWidth) { - + this.mipmapMode = mipmapMode; this.format = format; this.width = width; this.height = height; this.boundaryWidth = boundaryWidth; + if(!isPowerOfTwo(width) || !isPowerOfTwo(height)) { + this.widthOrHeightIsNPOT = true; + } + // determine the maximum number of mipmap levels that can be // defined from the specified dimension @@ -1094,17 +1101,26 @@ abstract class TextureRetained extends NodeComponentRetained { } } - + private boolean isEnabled(Canvas3D cv) { + if(widthOrHeightIsNPOT && + (((cv.textureExtendedFeatures & Canvas3D.TEXTURE_NON_POWER_OF_TWO ) == 0) || + VirtualUniverse.mc.enforcePowerOfTwo)) { + return false; + } + return enable; + } + + // bind a named texture to a texturing target - void bindTexture(Canvas3D cv) { + synchronized(resourceLock) { if (objectId == -1) { objectId = getTextureId(); } cv.addTextureResource(objectId, this); } - bindTexture(cv.ctx, objectId, enable); + bindTexture(cv.ctx, objectId, isEnabled(cv)); } @@ -1362,7 +1378,7 @@ abstract class TextureRetained extends NodeComponentRetained { y = info.y, width = info.width, height = info.height; - + //The x and y here specifies the subregion of the imageData of //the associated RenderedImage. @@ -1375,7 +1391,7 @@ abstract class TextureRetained extends NodeComponentRetained { int xoffset = x; int yoffset = y; - // TODO Check this logic : If !yUp adjust yoffset --- Chien + // TODO Check this logic : If !yUp adjust yoffset if (!image.yUp) { yoffset = image.height - yoffset - height; } @@ -1646,12 +1662,12 @@ abstract class TextureRetained extends NodeComponentRetained { // if texture is not enabled, don't bother downloading the // the texture state - if (enable == false) { + if (!isEnabled(cv)) { return; } bindTexture(cv); - + // reload all levels of texture image // update texture parameters such as boundary modes, filtering @@ -1689,11 +1705,11 @@ abstract class TextureRetained extends NodeComponentRetained { //System.out.println("Texture/updateNative: " + this + "object= " + objectId + " enable= " + enable); bindTexture(cv); - + // if texture is not enabled, don't bother downloading the // the texture state - if (enable == false) { + if (!isEnabled(cv)) { return; } diff --git a/src/native/ogl/Attributes.c b/src/native/ogl/Attributes.c index d54708d..921b949 100644 --- a/src/native/ogl/Attributes.c +++ b/src/native/ogl/Attributes.c @@ -2182,22 +2182,6 @@ void updateTextureAnisotropicFilter( degree); } -static int -isPowerOfTwo(int size) -{ - int i; - if (size == 0) { - return 1; - } else { - for (i = 0; i < 32; i++) { - if (size == (1 << i)) { - return 1; - } - } - return 0; - } -} - /* * common function to define 2D texture image for different target */ @@ -2227,13 +2211,6 @@ void updateTexture2DImage( imageObjPtr = (void *)(*(table->GetDirectBufferAddress))(env, data); } - /* check if we are trying to draw NPOT on a system that doesn't support it */ - if ((!ctxProperties->textureNonPowerOfTwoAvailable) && - (!isPowerOfTwo(width) || !isPowerOfTwo(height))) { - /* disable texture by setting width and height to 0 */ - width = height = 0; - } - switch (textureFormat) { case INTENSITY: internalFormat = GL_INTENSITY; @@ -2404,19 +2381,6 @@ void updateTexture2DSubImage( pixelStore = JNI_TRUE; glPixelStorei(GL_UNPACK_ROW_LENGTH, tilew); } - /* 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 - */ - if (!ctxProperties->textureNonPowerOfTwoAvailable) { - int texWidth, texHeight; - glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &texWidth); - glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &texHeight); - if ((texWidth == 0) && (texHeight == 0)) { - /* disable the sub-image by setting it's width and height to 0 */ - width = height = 0; - } - } switch (textureFormat) { case INTENSITY: @@ -2901,13 +2865,6 @@ void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DImage( else { imageObjPtr = (void *)(*(table->GetDirectBufferAddress))(env, data); } - - /* check if we are trying to draw NPOT on a system that doesn't support it */ - if ((!ctxProperties->textureNonPowerOfTwoAvailable) && - (!isPowerOfTwo(width) || !isPowerOfTwo(height) || !isPowerOfTwo(depth))) { - /* disable texture by setting width, height and depth to 0 */ - width = height = depth = 0; - } switch (textureFormat) { case INTENSITY: @@ -3084,21 +3041,6 @@ void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DSubImage( glPixelStorei(GL_UNPACK_ROW_LENGTH, tilew); } - /* 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 - */ - if (!ctxProperties->textureNonPowerOfTwoAvailable) { - int texWidth, texHeight, texDepth; - glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &texWidth); - glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &texHeight); - glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_DEPTH, &texDepth); - if ((texWidth == 0) && (texHeight == 0) && (texDepth == 0)) { - /* disable the sub-image by setting it's width, height and depth to 0 */ - width = height = depth = 0; - } - } - switch (textureFormat) { case INTENSITY: internalFormat = GL_INTENSITY; diff --git a/src/native/ogl/Canvas3D.c b/src/native/ogl/Canvas3D.c index 9c17ce4..00b281e 100644 --- a/src/native/ogl/Canvas3D.c +++ b/src/native/ogl/Canvas3D.c @@ -379,7 +379,6 @@ checkTextureExtensions( 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; } @@ -652,7 +651,6 @@ getPropertiesFromCurrentContext( /* look for OpenGL 2.0 features */ if (ctxInfo->gl20) { if (!getJavaBoolEnv(env, "enforcePowerOfTwo")) { - ctxInfo->textureNonPowerOfTwoAvailable = JNI_TRUE; ctxInfo->textureExtMask |= javax_media_j3d_Canvas3D_TEXTURE_NON_POWER_OF_TWO; } @@ -2662,7 +2660,6 @@ initializeCtxInfo(JNIEnv *env , GraphicsContextPropertiesInfo* ctxInfo) ctxInfo->textureColorTableSize = 0; ctxInfo->textureLodAvailable = JNI_FALSE; ctxInfo->textureLodBiasAvailable = JNI_FALSE; - ctxInfo->textureNonPowerOfTwoAvailable = JNI_FALSE; /* extension mask */ ctxInfo->extMask = 0; diff --git a/src/native/ogl/gldefs.h b/src/native/ogl/gldefs.h index 40ed49d..1edaeff 100644 --- a/src/native/ogl/gldefs.h +++ b/src/native/ogl/gldefs.h @@ -549,9 +549,6 @@ struct GraphicsContextPropertiesInfoRec { /* GL_SGIX_texture_lod_bias */ jboolean textureLodBiasAvailable; - /* GL_ARB_texture_non_power_of_two */ - jboolean textureNonPowerOfTwoAvailable; - /* extension mask */ jint extMask; jint textureExtMask; |