diff options
author | Julien Gouesse <[email protected]> | 2014-10-10 19:53:00 +0200 |
---|---|---|
committer | Julien Gouesse <[email protected]> | 2014-10-10 19:53:00 +0200 |
commit | 3b07ca50790bd9c23a8d1e30377e21812230cb5a (patch) | |
tree | df7ee758e96df8fb15e25a8d500d84184226bd57 | |
parent | fc2b6c0d48e51c2c5fb9776c923afe7298a36e16 (diff) |
Caches the GLU instances
-rw-r--r-- | ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java | 7 | ||||
-rw-r--r-- | ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglTextureStateUtil.java | 14 |
2 files changed, 14 insertions, 7 deletions
diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java index 206c188..eeea5f8 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java @@ -117,6 +117,7 @@ public class JoglRenderer extends AbstractRenderer { private FloatBuffer _transformBuffer; private final Matrix4 _transformMatrix = new Matrix4(); + private GLU _glu; /** * Constructor instantiates a new <code>JoglRenderer</code> object. @@ -678,12 +679,14 @@ public class JoglRenderer extends AbstractRenderer { @Override public void checkCardError() throws Ardor3dException { final GL gl = GLContext.getCurrentGL(); - final GLU glu = new GLU(); + if (_glu == null) { + _glu = GLU.createGLU(gl); + } try { final int errorCode = gl.glGetError(); if (errorCode != GL.GL_NO_ERROR) { - throw new GLException(glu.gluErrorString(errorCode)); + throw new GLException(_glu.gluErrorString(errorCode)); } } catch (final GLException exception) { throw new Ardor3dException("Error in opengl: " + exception.getMessage(), exception); diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglTextureStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglTextureStateUtil.java index ecf09f9..a99f75e 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglTextureStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglTextureStateUtil.java @@ -68,6 +68,8 @@ import com.ardor3d.util.stat.StatType; public class JoglTextureStateUtil { private static final Logger logger = Logger.getLogger(JoglTextureStateUtil.class.getName()); + private static GLU _glu; + public final static void load(final Texture texture, final int unit) { if (texture == null) { return; @@ -130,7 +132,9 @@ public class JoglTextureStateUtil { final Texture.Type type = texture.getType(); final GL gl = GLContext.getCurrentGL(); - final GLU glu = GLU.createGLU(gl); + if (_glu == null) { + _glu = GLU.createGLU(gl); + } // bind our texture id to this unit. doTextureBind(texture, unit, false); @@ -193,12 +197,12 @@ public class JoglTextureStateUtil { final ByteBuffer scaledImage = BufferUtils.createByteBuffer((w + 4) * h * bpp); // ensure the buffer is ready for reading image.getData(0).rewind(); - final int error = glu.gluScaleImage(pixFormat, actualWidth, actualHeight, pixDataType, + final int error = _glu.gluScaleImage(pixFormat, actualWidth, actualHeight, pixDataType, image.getData(0), w, h, pixDataType, scaledImage); if (error != 0) { final int errorCode = gl.glGetError(); if (errorCode != GL.GL_NO_ERROR) { - throw new GLException(glu.gluErrorString(errorCode)); + throw new GLException(_glu.gluErrorString(errorCode)); } } @@ -329,7 +333,7 @@ public class JoglTextureStateUtil { // FIXME workaround for the bug 1045: https://jogamp.org/bugzilla/show_bug.cgi?id=1045 if (gl.isGL2() /* || gl.isGL2ES1() */) { // send to card - glu.gluBuild2DMipmaps(GL.GL_TEXTURE_2D, + _glu.gluBuild2DMipmaps(GL.GL_TEXTURE_2D, JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), image.getHeight(), JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), @@ -422,7 +426,7 @@ public class JoglTextureStateUtil { // ensure the buffer is ready for reading image.getData(face.ordinal()).rewind(); // send to card - glu.gluBuild2DMipmaps(getGLCubeMapFace(face), + _glu.gluBuild2DMipmaps(getGLCubeMapFace(face), JoglTextureUtil.getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), image.getWidth(), JoglTextureUtil.getGLPixelFormat(image.getDataFormat()), |