diff options
author | Julien Gouesse <[email protected]> | 2014-08-15 21:09:04 +0200 |
---|---|---|
committer | Julien Gouesse <[email protected]> | 2014-08-15 21:09:04 +0200 |
commit | 6d8f3dca93f813ac76870109c801c21f7eeeb1df (patch) | |
tree | 5037916c9a73aea7302e9d5002fc32fe5be47ab4 | |
parent | 01459b2fee0fc51987ca329a1a3674c00ae2afe1 (diff) |
Drives the OpenGL-ES code path more robust, especially when dealing with the materials
-rw-r--r-- | ardor3d-jogl/src/main/java/com/ardor3d/renderer/jogl/JoglRenderer.java | 12 | ||||
-rw-r--r-- | ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglMaterialStateUtil.java | 36 |
2 files changed, 34 insertions, 14 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 e11ce4e..e25849c 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 @@ -1740,18 +1740,24 @@ public class JoglRenderer extends AbstractRenderer { if (stipplePattern != (short) 0xFFFF) { if (!lineRecord.isValid() || !lineRecord.stippled) { - gl.glEnable(GL2.GL_LINE_STIPPLE); + if (gl.isGL2()) { + gl.glEnable(GL2.GL_LINE_STIPPLE); + } lineRecord.stippled = true; } if (!lineRecord.isValid() || stippleFactor != lineRecord.stippleFactor || stipplePattern != lineRecord.stipplePattern) { - gl.getGL2().glLineStipple(stippleFactor, stipplePattern); + if (gl.isGL2()) { + gl.getGL2().glLineStipple(stippleFactor, stipplePattern); + } lineRecord.stippleFactor = stippleFactor; lineRecord.stipplePattern = stipplePattern; } } else if (!lineRecord.isValid() || lineRecord.stippled) { - gl.glDisable(GL2.GL_LINE_STIPPLE); + if (gl.isGL2()) { + gl.glDisable(GL2.GL_LINE_STIPPLE); + } lineRecord.stippled = false; } diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglMaterialStateUtil.java b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglMaterialStateUtil.java index 9fc3490..d9a6e58 100644 --- a/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglMaterialStateUtil.java +++ b/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/JoglMaterialStateUtil.java @@ -74,7 +74,10 @@ public abstract class JoglMaterialStateUtil { record.tempColorBuff.put(frontColor.getRed()).put(frontColor.getGreen()).put(frontColor.getBlue()) .put(frontColor.getAlpha()); record.tempColorBuff.flip(); - gl.getGL2().glMaterialfv(getGLMaterialFace(MaterialFace.FrontAndBack), glMat, record.tempColorBuff); + if (gl.isGL2()) { + gl.getGL2().glMaterialfv(getGLMaterialFace(MaterialFace.FrontAndBack), glMat, + record.tempColorBuff); + } record.setColor(MaterialFace.FrontAndBack, glMatColor, frontColor); } } @@ -85,7 +88,9 @@ public abstract class JoglMaterialStateUtil { record.tempColorBuff.put(frontColor.getRed()).put(frontColor.getGreen()).put(frontColor.getBlue()) .put(frontColor.getAlpha()); record.tempColorBuff.flip(); - gl.getGL2().glMaterialfv(getGLMaterialFace(MaterialFace.Front), glMat, record.tempColorBuff); + if (gl.isGL2()) { + gl.getGL2().glMaterialfv(getGLMaterialFace(MaterialFace.Front), glMat, record.tempColorBuff); + } record.setColor(MaterialFace.Front, glMatColor, frontColor); } } @@ -96,7 +101,9 @@ public abstract class JoglMaterialStateUtil { record.tempColorBuff.put(backColor.getRed()).put(backColor.getGreen()).put(backColor.getBlue()) .put(backColor.getAlpha()); record.tempColorBuff.flip(); - gl.getGL2().glMaterialfv(getGLMaterialFace(MaterialFace.Back), glMat, record.tempColorBuff); + if (gl.isGL2()) { + gl.getGL2().glMaterialfv(getGLMaterialFace(MaterialFace.Back), glMat, record.tempColorBuff); + } record.setColor(MaterialFace.Back, glMatColor, backColor); } } @@ -139,8 +146,9 @@ public abstract class JoglMaterialStateUtil { } else { final int glMat = getGLColorMaterial(colorMaterial); final int glFace = getGLMaterialFace(face); - - gl.getGL2().glColorMaterial(glFace, glMat); + if (gl.isGL2()) { + gl.getGL2().glColorMaterial(glFace, glMat); + } gl.glEnable(GLLightingFunc.GL_COLOR_MATERIAL); record.resetColorsForCM(face, colorMaterial); } @@ -156,20 +164,26 @@ public abstract class JoglMaterialStateUtil { if (frontShininess == backShininess) { // consolidate to one call if (!record.isValid() || frontShininess != record.frontShininess || record.backShininess != backShininess) { - gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.FrontAndBack), GLLightingFunc.GL_SHININESS, - frontShininess); + if (gl.isGL2()) { + gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.FrontAndBack), GLLightingFunc.GL_SHININESS, + frontShininess); + } record.backShininess = record.frontShininess = frontShininess; } } else { if (!record.isValid() || frontShininess != record.frontShininess) { - gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.Front), GLLightingFunc.GL_SHININESS, - frontShininess); + if (gl.isGL2()) { + gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.Front), GLLightingFunc.GL_SHININESS, + frontShininess); + } record.frontShininess = frontShininess; } if (!record.isValid() || backShininess != record.backShininess) { - gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.Back), GLLightingFunc.GL_SHININESS, - backShininess); + if (gl.isGL2()) { + gl.getGL2().glMaterialf(getGLMaterialFace(MaterialFace.Back), GLLightingFunc.GL_SHININESS, + backShininess); + } record.backShininess = backShininess; } } |