diff options
author | Sven Gothel <[email protected]> | 2010-03-25 03:28:23 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-03-25 03:28:23 +0100 |
commit | 8b8e270788b50636e48ee17cc9e5fc8f29d44f5c (patch) | |
tree | 8b5f5096fc3c9131b4a331400cf2f73d3e30955e /src/jogl/classes/com/sun/opengl/util/texture/TextureData.java | |
parent | 7a087b9181b94c3d38f9480ba3ccd3b9e8062200 (diff) |
http://www.jogamp.org/bugzilla/show_bug.cgi?id=378
Test:
Added JUNIT Test Environment:
- tests: jogl.test.jar
- run: 'ant junit.run'
Currently only runs 1 test regarding this bug id.
Adding PATH (windows) or LD_LIBRARY_PATH (unix).
Test initialized AWTTextureData without a current GLContext
and then uses it to render ..
Solution:
Pending initialization of GL depending data,
offered in TextureData.glPostInit(),
specialized in AWTTextureData.
Diffstat (limited to 'src/jogl/classes/com/sun/opengl/util/texture/TextureData.java')
-rwxr-xr-x | src/jogl/classes/com/sun/opengl/util/texture/TextureData.java | 64 |
1 files changed, 54 insertions, 10 deletions
diff --git a/src/jogl/classes/com/sun/opengl/util/texture/TextureData.java b/src/jogl/classes/com/sun/opengl/util/texture/TextureData.java index 8ac4b9b84..81124b060 100755 --- a/src/jogl/classes/com/sun/opengl/util/texture/TextureData.java +++ b/src/jogl/classes/com/sun/opengl/util/texture/TextureData.java @@ -71,6 +71,10 @@ public class TextureData { protected int alignment; // 1, 2, or 4 bytes protected int estimatedMemorySize; + // specialization of this class might need GL dependent post initialization + protected Object glPostInitSync = new Object(); + protected volatile boolean glPostInitDone = false; + // These booleans are a concession to the AWTTextureData subclass protected boolean haveEXTABGR; protected boolean haveGL12; @@ -207,45 +211,71 @@ public class TextureData { } /** Used only by subclasses */ - protected TextureData() { - } + protected TextureData() { } /** Returns the width in pixels of the texture data. */ public int getWidth() { return width; } /** Returns the height in pixels of the texture data. */ public int getHeight() { return height; } /** Returns the border in pixels of the texture data. */ - public int getBorder() { return border; } + public int getBorder() { + glPostInitInt(); + return border; + } /** Returns the intended OpenGL pixel format of the texture data. */ public int getPixelFormat() { + glPostInitInt(); return pixelFormat; } /** Returns the intended OpenGL pixel type of the texture data. */ public int getPixelType() { + glPostInitInt(); return pixelType; } /** Returns the intended OpenGL internal format of the texture data. */ - public int getInternalFormat() { return internalFormat; } + public int getInternalFormat() { + glPostInitInt(); + return internalFormat; + } /** Returns whether mipmaps should be generated for the texture data. */ - public boolean getMipmap() { return mipmap; } + public boolean getMipmap() { + glPostInitInt(); + return mipmap; + } /** Indicates whether the texture data is in compressed form. */ - public boolean isDataCompressed() { return dataIsCompressed; } + public boolean isDataCompressed() { + glPostInitInt(); + return dataIsCompressed; + } /** Indicates whether the texture coordinates must be flipped vertically for proper display. */ - public boolean getMustFlipVertically() { return mustFlipVertically; } + public boolean getMustFlipVertically() { + glPostInitInt(); + return mustFlipVertically; + } /** Returns the texture data, or null if it is specified as a set of mipmaps. */ public Buffer getBuffer() { + glPostInitInt(); return buffer; } /** Returns all mipmap levels for the texture data, or null if it is specified as a single image. */ - public Buffer[] getMipmapData() { return mipmapData; } + public Buffer[] getMipmapData() { + glPostInitInt(); + return mipmapData; + } /** Returns the required byte alignment for the texture data. */ - public int getAlignment() { return alignment; } + public int getAlignment() { + glPostInitInt(); + return alignment; + } /** Returns the row length needed for correct GL_UNPACK_ROW_LENGTH specification. This is currently only supported for non-mipmapped, non-compressed textures. */ - public int getRowLength() { return rowLength; } + public int getRowLength() { + glPostInitInt(); + return rowLength; + } /** Sets the width in pixels of the texture data. */ public void setWidth(int width) { this.width = width; } @@ -303,6 +333,7 @@ public class TextureData { /** Flushes resources associated with this TextureData by calling Flusher.flush(). */ public void flush() { + glPostInitInt(); if (flusher != null) { flusher.flush(); flusher = null; @@ -333,6 +364,19 @@ public class TextureData { // Internals only below this point // + protected void glPostInit() { } + + protected final void glPostInitInt() { + if(glPostInitDone) return; + synchronized(glPostInitSync) { + if(!glPostInitDone) { + glPostInit(); + glPostInitDone = true; + } + glPostInitSync.notifyAll(); + } + } + protected static int estimatedMemorySize(Buffer buffer) { if (buffer == null) { return 0; |