fixed compilation issues in deprecated OGLESShaderRenderer, IGLESShaderRenderer, and JoglRenderer caused by earlier commit

experimental
iwgeric 10 years ago
parent f9d8a88bba
commit 4baceb6a08
  1. 10
      jme3-android/src/main/java/com/jme3/renderer/android/OGLESShaderRenderer.java
  2. 118
      jme3-ios/src/main/java/com/jme3/renderer/ios/IGLESShaderRenderer.java
  3. 162
      jme3-jogl/src/main/java/com/jme3/renderer/jogl/JoglRenderer.java

@ -652,7 +652,7 @@ public class OGLESShaderRenderer implements Renderer {
objManager.deleteUnused(this); objManager.deleteUnused(this);
} }
/*********************************************************************\ /*********************************************************************\
|* Shaders *| |* Shaders *|
\*********************************************************************/ \*********************************************************************/
@ -910,7 +910,7 @@ public class OGLESShaderRenderer implements Renderer {
source.clearUpdateNeeded(); source.clearUpdateNeeded();
} else { } else {
logger.log(Level.WARNING, "Bad compile of:\n{0}", logger.log(Level.WARNING, "Bad compile of:\n{0}",
new Object[]{ShaderDebug.formatShaderSource(source.getDefines(), source.getSource(),stringBuf.toString())}); new Object[]{ShaderDebug.formatShaderSource(stringBuf.toString() + source.getDefines() + source.getSource())});
if (infoLog != null) { if (infoLog != null) {
throw new RendererException("compile error in: " + source + "\n" + infoLog); throw new RendererException("compile error in: " + source + "\n" + infoLog);
} else { } else {
@ -2113,7 +2113,7 @@ public class OGLESShaderRenderer implements Renderer {
vb.isNormalized(), vb.isNormalized(),
vb.getStride(), vb.getStride(),
0); 0);
RendererUtil.checkGLError(); RendererUtil.checkGLError();
attribs[loc] = vb; attribs[loc] = vb;
@ -2559,8 +2559,8 @@ public class OGLESShaderRenderer implements Renderer {
public void setLinearizeSrgbImages(boolean linearize) { public void setLinearizeSrgbImages(boolean linearize) {
//TODO once opglES3.0 is supported maybe.... //TODO once opglES3.0 is supported maybe....
} }
public void readFrameBufferWithFormat(FrameBuffer fb, ByteBuffer byteBuf, Image.Format format) { public void readFrameBufferWithFormat(FrameBuffer fb, ByteBuffer byteBuf, Image.Format format) {
throw new UnsupportedOperationException("Not supported yet. URA will make that work seamlessly"); throw new UnsupportedOperationException("Not supported yet. URA will make that work seamlessly");
} }
} }

@ -34,7 +34,7 @@ import jme3tools.shader.ShaderDebug;
/** /**
* The <code>Renderer</code> is responsible for taking rendering commands and * The <code>Renderer</code> is responsible for taking rendering commands and
* executing them on the underlying video hardware. * executing them on the underlying video hardware.
* *
* @author Kirill Vainer * @author Kirill Vainer
*/ */
public class IGLESShaderRenderer implements Renderer { public class IGLESShaderRenderer implements Renderer {
@ -51,7 +51,7 @@ public class IGLESShaderRenderer implements Renderer {
private final int maxFBOAttachs = 1; // Only 1 color attachment on ES private final int maxFBOAttachs = 1; // Only 1 color attachment on ES
private final int maxMRTFBOAttachs = 1; // FIXME for now, not sure if > 1 is needed for ES private final int maxMRTFBOAttachs = 1; // FIXME for now, not sure if > 1 is needed for ES
private final int[] intBuf1 = new int[1]; private final int[] intBuf1 = new int[1];
private final int[] intBuf16 = new int[16]; private final int[] intBuf16 = new int[16];
@ -150,7 +150,7 @@ public class IGLESShaderRenderer implements Renderer {
/** /**
* Sets the background (aka clear) color. * Sets the background (aka clear) color.
* *
* @param color The background color to set * @param color The background color to set
*/ */
public void setBackgroundColor(ColorRGBA color) { public void setBackgroundColor(ColorRGBA color) {
@ -322,7 +322,7 @@ public class IGLESShaderRenderer implements Renderer {
/** /**
* Set the range of the depth values for objects. All rendered * Set the range of the depth values for objects. All rendered
* objects will have their depth clamped to this range. * objects will have their depth clamped to this range.
* *
* @param start The range start * @param start The range start
* @param end The range end * @param end The range end
*/ */
@ -344,9 +344,9 @@ public class IGLESShaderRenderer implements Renderer {
} }
/** /**
* Set the world matrix to use. Does nothing if the Renderer is * Set the world matrix to use. Does nothing if the Renderer is
* shader based. * shader based.
* *
* @param worldMatrix World matrix to use. * @param worldMatrix World matrix to use.
*/ */
public void setWorldMatrix(Matrix4f worldMatrix) { public void setWorldMatrix(Matrix4f worldMatrix) {
@ -354,9 +354,9 @@ public class IGLESShaderRenderer implements Renderer {
} }
/** /**
* Sets the view and projection matrices to use. Does nothing if the Renderer * Sets the view and projection matrices to use. Does nothing if the Renderer
* is shader based. * is shader based.
* *
* @param viewMatrix The view matrix to use. * @param viewMatrix The view matrix to use.
* @param projMatrix The projection matrix to use. * @param projMatrix The projection matrix to use.
*/ */
@ -366,7 +366,7 @@ public class IGLESShaderRenderer implements Renderer {
/** /**
* Set the viewport location and resolution on the screen. * Set the viewport location and resolution on the screen.
* *
* @param x The x coordinate of the viewport * @param x The x coordinate of the viewport
* @param y The y coordinate of the viewport * @param y The y coordinate of the viewport
* @param width Width of the viewport * @param width Width of the viewport
@ -389,7 +389,7 @@ public class IGLESShaderRenderer implements Renderer {
* Specifies a clipping rectangle. * Specifies a clipping rectangle.
* For all future rendering commands, no pixels will be allowed * For all future rendering commands, no pixels will be allowed
* to be rendered outside of the clip rectangle. * to be rendered outside of the clip rectangle.
* *
* @param x The x coordinate of the clip rect * @param x The x coordinate of the clip rect
* @param y The y coordinate of the clip rect * @param y The y coordinate of the clip rect
* @param width Width of the clip rect * @param width Width of the clip rect
@ -413,7 +413,7 @@ public class IGLESShaderRenderer implements Renderer {
} }
/** /**
* Clears the clipping rectangle set with * Clears the clipping rectangle set with
* {@link #setClipRect(int, int, int, int) }. * {@link #setClipRect(int, int, int, int) }.
*/ */
public void clearClipRect() { public void clearClipRect() {
@ -433,9 +433,9 @@ public class IGLESShaderRenderer implements Renderer {
/** /**
* Set lighting state. * Set lighting state.
* Does nothing if the renderer is shader based. * Does nothing if the renderer is shader based.
* The lights should be provided in world space. * The lights should be provided in world space.
* Specify <code>null</code> to disable lighting. * Specify <code>null</code> to disable lighting.
* *
* @param lights The light list to set. * @param lights The light list to set.
*/ */
public void setLighting(LightList lights) { public void setLighting(LightList lights) {
@ -445,9 +445,9 @@ public class IGLESShaderRenderer implements Renderer {
/** /**
* Sets the shader to use for rendering. * Sets the shader to use for rendering.
* If the shader has not been uploaded yet, it is compiled * If the shader has not been uploaded yet, it is compiled
* and linked. If it has been uploaded, then the * and linked. If it has been uploaded, then the
* uniform data is updated and the shader is set. * uniform data is updated and the shader is set.
* *
* @param shader The shader to use for rendering. * @param shader The shader to use for rendering.
*/ */
public void setShader(Shader shader) { public void setShader(Shader shader) {
@ -472,7 +472,7 @@ public class IGLESShaderRenderer implements Renderer {
/** /**
* Deletes a shader. This method also deletes * Deletes a shader. This method also deletes
* the attached shader sources. * the attached shader sources.
* *
* @param shader Shader to delete. * @param shader Shader to delete.
*/ */
public void deleteShader(Shader shader) { public void deleteShader(Shader shader) {
@ -500,7 +500,7 @@ public class IGLESShaderRenderer implements Renderer {
/** /**
* Deletes the provided shader source. * Deletes the provided shader source.
* *
* @param source The ShaderSource to delete. * @param source The ShaderSource to delete.
*/ */
public void deleteShaderSource(ShaderSource source) { public void deleteShaderSource(ShaderSource source) {
@ -668,12 +668,12 @@ public class IGLESShaderRenderer implements Renderer {
checkFrameBufferStatus(fb); checkFrameBufferStatus(fb);
} }
} }
/** /**
* Set the framebuffer that will be set instead of the main framebuffer * Set the framebuffer that will be set instead of the main framebuffer
* when a call to setFrameBuffer(null) is made. * when a call to setFrameBuffer(null) is made.
* *
* @param fb * @param fb
*/ */
public void setMainFrameBufferOverride(FrameBuffer fb) { public void setMainFrameBufferOverride(FrameBuffer fb) {
logger.log(Level.FINE, "IGLESShaderRenderer setMainFrameBufferOverride"); logger.log(Level.FINE, "IGLESShaderRenderer setMainFrameBufferOverride");
@ -682,11 +682,11 @@ public class IGLESShaderRenderer implements Renderer {
/** /**
* Reads the pixels currently stored in the specified framebuffer * Reads the pixels currently stored in the specified framebuffer
* into the given ByteBuffer object. * into the given ByteBuffer object.
* Only color pixels are transferred, the format is BGRA with 8 bits * Only color pixels are transferred, the format is BGRA with 8 bits
* per component. The given byte buffer should have at least * per component. The given byte buffer should have at least
* fb.getWidth() * fb.getHeight() * 4 bytes remaining. * fb.getWidth() * fb.getHeight() * 4 bytes remaining.
* *
* @param fb The framebuffer to read from * @param fb The framebuffer to read from
* @param byteBuf The bytebuffer to transfer color data to * @param byteBuf The bytebuffer to transfer color data to
*/ */
@ -820,7 +820,7 @@ public class IGLESShaderRenderer implements Renderer {
/** /**
* Uploads a vertex buffer to the GPU. * Uploads a vertex buffer to the GPU.
* *
* @param vb The vertex buffer to upload * @param vb The vertex buffer to upload
*/ */
public void updateBufferData(VertexBuffer vb) { public void updateBufferData(VertexBuffer vb) {
@ -865,7 +865,7 @@ public class IGLESShaderRenderer implements Renderer {
if (created || vb.hasDataSizeChanged()) { if (created || vb.hasDataSizeChanged()) {
// upload data based on format // upload data based on format
int size = vb.getData().limit() * vb.getFormat().getComponentSize(); int size = vb.getData().limit() * vb.getFormat().getComponentSize();
switch (vb.getFormat()) { switch (vb.getFormat()) {
case Byte: case Byte:
case UnsignedByte: case UnsignedByte:
@ -891,7 +891,7 @@ public class IGLESShaderRenderer implements Renderer {
} }
} else { } else {
int size = vb.getData().limit() * vb.getFormat().getComponentSize(); int size = vb.getData().limit() * vb.getFormat().getComponentSize();
switch (vb.getFormat()) { switch (vb.getFormat()) {
case Byte: case Byte:
case UnsignedByte: case UnsignedByte:
@ -984,8 +984,8 @@ public class IGLESShaderRenderer implements Renderer {
* The state of the native objects is reset in such way, that using * The state of the native objects is reset in such way, that using
* them again will cause the renderer to reupload them. * them again will cause the renderer to reupload them.
* Call this method when you know the GL context is going to shutdown. * Call this method when you know the GL context is going to shutdown.
* *
* @see NativeObject#resetObject() * @see NativeObject#resetObject()
*/ */
public void resetGLObjects() { public void resetGLObjects() {
logger.log(Level.FINE, "IGLESShaderRenderer resetGLObjects"); logger.log(Level.FINE, "IGLESShaderRenderer resetGLObjects");
@ -999,20 +999,20 @@ public class IGLESShaderRenderer implements Renderer {
/** /**
* Deletes all previously used {@link NativeObject Native Objects} on this Renderer, and * Deletes all previously used {@link NativeObject Native Objects} on this Renderer, and
* then resets the native objects. * then resets the native objects.
* *
* @see #resetGLObjects() * @see #resetGLObjects()
* @see NativeObject#deleteObject(java.lang.Object) * @see NativeObject#deleteObject(java.lang.Object)
*/ */
public void cleanup() { public void cleanup() {
logger.log(Level.FINE, "IGLESShaderRenderer cleanup"); logger.log(Level.FINE, "IGLESShaderRenderer cleanup");
objManager.deleteAllObjects(this); objManager.deleteAllObjects(this);
statistics.clearMemory(); statistics.clearMemory();
} }
/** /**
* Sets the alpha to coverage state. * Sets the alpha to coverage state.
* <p> * <p>
* When alpha coverage and multi-sampling is enabled, * When alpha coverage and multi-sampling is enabled,
* each pixel will contain alpha coverage in all * each pixel will contain alpha coverage in all
* of its subsamples, which is then combined when * of its subsamples, which is then combined when
* other future alpha-blended objects are rendered. * other future alpha-blended objects are rendered.
@ -1032,15 +1032,15 @@ public class IGLESShaderRenderer implements Renderer {
JmeIosGLES.checkGLError(); JmeIosGLES.checkGLError();
} }
} }
/* ------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------ */
public void initialize() { public void initialize() {
Level store = logger.getLevel(); Level store = logger.getLevel();
logger.setLevel(Level.FINE); logger.setLevel(Level.FINE);
logger.log(Level.FINE, "Vendor: {0}", JmeIosGLES.glGetString(JmeIosGLES.GL_VENDOR)); logger.log(Level.FINE, "Vendor: {0}", JmeIosGLES.glGetString(JmeIosGLES.GL_VENDOR));
logger.log(Level.FINE, "Renderer: {0}", JmeIosGLES.glGetString(JmeIosGLES.GL_RENDERER)); logger.log(Level.FINE, "Renderer: {0}", JmeIosGLES.glGetString(JmeIosGLES.GL_RENDERER));
logger.log(Level.FINE, "Version: {0}", JmeIosGLES.glGetString(JmeIosGLES.GL_VERSION)); logger.log(Level.FINE, "Version: {0}", JmeIosGLES.glGetString(JmeIosGLES.GL_VERSION));
@ -1238,11 +1238,11 @@ public class IGLESShaderRenderer implements Renderer {
uintIndexSupport = extensions.contains("GL_OES_element_index_uint"); uintIndexSupport = extensions.contains("GL_OES_element_index_uint");
logger.log(Level.FINE, "Support for UInt index: {0}", uintIndexSupport); logger.log(Level.FINE, "Support for UInt index: {0}", uintIndexSupport);
} }
/* ------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------ */
private int extractVersion(String prefixStr, String versionStr) { private int extractVersion(String prefixStr, String versionStr) {
if (versionStr != null) { if (versionStr != null) {
int spaceIdx = versionStr.indexOf(" ", prefixStr.length()); int spaceIdx = versionStr.indexOf(" ", prefixStr.length());
@ -1263,7 +1263,7 @@ public class IGLESShaderRenderer implements Renderer {
JmeIosGLES.glDeleteRenderbuffers(1, intBuf1, 0); JmeIosGLES.glDeleteRenderbuffers(1, intBuf1, 0);
JmeIosGLES.checkGLError(); JmeIosGLES.checkGLError();
} }
private int convertUsage(Usage usage) { private int convertUsage(Usage usage) {
switch (usage) { switch (usage) {
case Static: case Static:
@ -1276,8 +1276,8 @@ public class IGLESShaderRenderer implements Renderer {
throw new RuntimeException("Unknown usage type."); throw new RuntimeException("Unknown usage type.");
} }
} }
protected void bindProgram(Shader shader) { protected void bindProgram(Shader shader) {
int shaderId = shader.getId(); int shaderId = shader.getId();
if (context.boundShaderProgram != shaderId) { if (context.boundShaderProgram != shaderId) {
@ -1451,8 +1451,8 @@ public class IGLESShaderRenderer implements Renderer {
nameBuf.rewind(); nameBuf.rewind();
} }
public void updateShaderData(Shader shader) { public void updateShaderData(Shader shader) {
int id = shader.getId(); int id = shader.getId();
boolean needRegister = false; boolean needRegister = false;
@ -1676,7 +1676,7 @@ public class IGLESShaderRenderer implements Renderer {
} }
*/ */
} }
private int convertTextureType(Texture.Type type) { private int convertTextureType(Texture.Type type) {
switch (type) { switch (type) {
case TwoDimensional: case TwoDimensional:
@ -1879,14 +1879,14 @@ public class IGLESShaderRenderer implements Renderer {
0); 0);
*/ */
logger.warning("iTODO Android22Workaround"); logger.warning("iTODO Android22Workaround");
JmeIosGLES.glVertexAttribPointer(loc, JmeIosGLES.glVertexAttribPointer(loc,
vb.getNumComponents(), vb.getNumComponents(),
convertVertexBufferFormat(vb.getFormat()), convertVertexBufferFormat(vb.getFormat()),
vb.isNormalized(), vb.isNormalized(),
vb.getStride(), vb.getStride(),
null); null);
JmeIosGLES.checkGLError(); JmeIosGLES.checkGLError();
attribs[loc] = vb; attribs[loc] = vb;
@ -2071,7 +2071,7 @@ public class IGLESShaderRenderer implements Renderer {
} }
} }
public void clearVertexAttribs() { public void clearVertexAttribs() {
IDList attribList = context.attribIndexList; IDList attribList = context.attribIndexList;
for (int i = 0; i < attribList.oldLen; i++) { for (int i = 0; i < attribList.oldLen; i++) {
@ -2348,7 +2348,7 @@ public class IGLESShaderRenderer implements Renderer {
for (int i = 0; i < fb.getNumColorBuffers(); i++) { for (int i = 0; i < fb.getNumColorBuffers(); i++) {
printRealRenderBufferInfo(fb, fb.getColorBuffer(i), "Color" + i); printRealRenderBufferInfo(fb, fb.getColorBuffer(i), "Color" + i);
} }
} }
@ -2540,7 +2540,7 @@ public class IGLESShaderRenderer implements Renderer {
source.clearUpdateNeeded(); source.clearUpdateNeeded();
} else { } else {
logger.log(Level.WARNING, "Bad compile of:\n{0}", logger.log(Level.WARNING, "Bad compile of:\n{0}",
new Object[]{ShaderDebug.formatShaderSource(source.getDefines(), source.getSource(),stringBuf.toString())}); new Object[]{ShaderDebug.formatShaderSource(stringBuf.toString() + source.getDefines() + source.getSource())});
if (infoLog != null) { if (infoLog != null) {
throw new RendererException("compile error in: " + source + "\n" + infoLog); throw new RendererException("compile error in: " + source + "\n" + infoLog);
} else { } else {
@ -2562,7 +2562,7 @@ public class IGLESShaderRenderer implements Renderer {
throw new RuntimeException("Unrecognized shader type."); throw new RuntimeException("Unrecognized shader type.");
} }
} }
private int convertTestFunction(RenderState.TestFunction testFunc) { private int convertTestFunction(RenderState.TestFunction testFunc) {
switch (testFunc) { switch (testFunc) {
case Never: case Never:
@ -2584,17 +2584,17 @@ public class IGLESShaderRenderer implements Renderer {
default: default:
throw new UnsupportedOperationException("Unrecognized test function: " + testFunc); throw new UnsupportedOperationException("Unrecognized test function: " + testFunc);
} }
} }
public void setMainFrameBufferSrgb(boolean srgb) { public void setMainFrameBufferSrgb(boolean srgb) {
} }
public void setLinearizeSrgbImages(boolean linearize) { public void setLinearizeSrgbImages(boolean linearize) {
} }
public void readFrameBufferWithFormat(FrameBuffer fb, ByteBuffer byteBuf, Image.Format format) { public void readFrameBufferWithFormat(FrameBuffer fb, ByteBuffer byteBuf, Image.Format format) {
throw new UnsupportedOperationException("Not supported yet. URA will make that work seamlessly"); throw new UnsupportedOperationException("Not supported yet. URA will make that work seamlessly");
} }
} }

@ -139,7 +139,7 @@ public class JoglRenderer implements Renderer {
public Statistics getStatistics() { public Statistics getStatistics() {
return statistics; return statistics;
} }
@Override @Override
public EnumSet<Caps> getCaps() { public EnumSet<Caps> getCaps() {
return caps; return caps;
@ -169,7 +169,7 @@ public class JoglRenderer implements Renderer {
//workaround, always assume we support GLSL100 //workaround, always assume we support GLSL100
//some cards just don't report this correctly //some cards just don't report this correctly
caps.add(Caps.GLSL100); caps.add(Caps.GLSL100);
String versionStr = null; String versionStr = null;
if (caps.contains(Caps.OpenGL20) || gl.isGL2ES2()) { if (caps.contains(Caps.OpenGL20) || gl.isGL2ES2()) {
versionStr = gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION); versionStr = gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION);
@ -180,25 +180,25 @@ public class JoglRenderer implements Renderer {
"required for the JOGL " + "required for the JOGL " +
"renderer!"); "renderer!");
} }
// Fix issue in TestRenderToMemory when GL_FRONT is the main // Fix issue in TestRenderToMemory when GL_FRONT is the main
// buffer being used. // buffer being used.
gl.glGetIntegerv(GL2GL3.GL_DRAW_BUFFER, intBuf1); gl.glGetIntegerv(GL2GL3.GL_DRAW_BUFFER, intBuf1);
initialDrawBuf = intBuf1.get(0); initialDrawBuf = intBuf1.get(0);
gl.glGetIntegerv(GL2GL3.GL_READ_BUFFER, intBuf1); gl.glGetIntegerv(GL2GL3.GL_READ_BUFFER, intBuf1);
initialReadBuf = intBuf1.get(0); initialReadBuf = intBuf1.get(0);
// XXX: This has to be GL_BACK for canvas on Mac // XXX: This has to be GL_BACK for canvas on Mac
// Since initialDrawBuf is GL_FRONT for pbuffer, gotta // Since initialDrawBuf is GL_FRONT for pbuffer, gotta
// change this value later on ... // change this value later on ...
// initialDrawBuf = GL_BACK; // initialDrawBuf = GL_BACK;
// initialReadBuf = GL_BACK; // initialReadBuf = GL_BACK;
int spaceIdx = versionStr.indexOf(" "); int spaceIdx = versionStr.indexOf(" ");
if (spaceIdx >= 1) { if (spaceIdx >= 1) {
versionStr = versionStr.substring(0, spaceIdx); versionStr = versionStr.substring(0, spaceIdx);
} }
try { try {
float version = Float.parseFloat(versionStr); float version = Float.parseFloat(versionStr);
glslVer = (int) (version * 100); glslVer = (int) (version * 100);
@ -235,7 +235,7 @@ public class JoglRenderer implements Renderer {
caps.add(Caps.GLSL100); caps.add(Caps.GLSL100);
break; break;
} }
if (!caps.contains(Caps.GLSL100)) { if (!caps.contains(Caps.GLSL100)) {
logger.log(Level.WARNING, "Force-adding GLSL100 support, since OpenGL2 is supported."); logger.log(Level.WARNING, "Force-adding GLSL100 support, since OpenGL2 is supported.");
caps.add(Caps.GLSL100); caps.add(Caps.GLSL100);
@ -298,7 +298,7 @@ public class JoglRenderer implements Renderer {
if (gl.isExtensionAvailable("GL_ARB_depth_buffer_float")) { if (gl.isExtensionAvailable("GL_ARB_depth_buffer_float")) {
caps.add(Caps.FloatDepthBuffer); caps.add(Caps.FloatDepthBuffer);
} }
if (caps.contains(Caps.OpenGL30)) { if (caps.contains(Caps.OpenGL30)) {
caps.add(Caps.PackedDepthStencilBuffer); caps.add(Caps.PackedDepthStencilBuffer);
} }
@ -320,7 +320,7 @@ public class JoglRenderer implements Renderer {
if (gl.isExtensionAvailable("GL_ARB_vertex_array_object")) { if (gl.isExtensionAvailable("GL_ARB_vertex_array_object")) {
caps.add(Caps.VertexBufferArray); caps.add(Caps.VertexBufferArray);
} }
if (gl.isExtensionAvailable("GL_ARB_texture_non_power_of_two")) { if (gl.isExtensionAvailable("GL_ARB_texture_non_power_of_two")) {
caps.add(Caps.NonPowerOfTwoTextures); caps.add(Caps.NonPowerOfTwoTextures);
} }
@ -358,7 +358,7 @@ public class JoglRenderer implements Renderer {
gl.glGetIntegerv(GL2GL3.GL_MAX_COLOR_ATTACHMENTS, intBuf16); gl.glGetIntegerv(GL2GL3.GL_MAX_COLOR_ATTACHMENTS, intBuf16);
maxFBOAttachs = intBuf16.get(0); maxFBOAttachs = intBuf16.get(0);
logger.log(Level.FINER, "FBO Max renderbuffers: {0}", maxFBOAttachs); logger.log(Level.FINER, "FBO Max renderbuffers: {0}", maxFBOAttachs);
if (gl.isExtensionAvailable("GL_EXT_framebuffer_multisample")) { if (gl.isExtensionAvailable("GL_EXT_framebuffer_multisample")) {
caps.add(Caps.FrameBufferMultisample); caps.add(Caps.FrameBufferMultisample);
@ -378,14 +378,14 @@ public class JoglRenderer implements Renderer {
maxDepthTexSamples = intBuf16.get(0); maxDepthTexSamples = intBuf16.get(0);
logger.log(Level.FINER, "Texture Multisample Depth Samples: {0}", maxDepthTexSamples); logger.log(Level.FINER, "Texture Multisample Depth Samples: {0}", maxDepthTexSamples);
} }
gl.glGetIntegerv(GL2ES2.GL_MAX_DRAW_BUFFERS, intBuf16); gl.glGetIntegerv(GL2ES2.GL_MAX_DRAW_BUFFERS, intBuf16);
maxMRTFBOAttachs = intBuf16.get(0); maxMRTFBOAttachs = intBuf16.get(0);
if (maxMRTFBOAttachs > 1) { if (maxMRTFBOAttachs > 1) {
caps.add(Caps.FrameBufferMRT); caps.add(Caps.FrameBufferMRT);
logger.log(Level.FINER, "FBO Max MRT renderbuffers: {0}", maxMRTFBOAttachs); logger.log(Level.FINER, "FBO Max MRT renderbuffers: {0}", maxMRTFBOAttachs);
} }
//if (gl.isExtensionAvailable("GL_ARB_draw_buffers")) { //if (gl.isExtensionAvailable("GL_ARB_draw_buffers")) {
// caps.add(Caps.FrameBufferMRT); // caps.add(Caps.FrameBufferMRT);
// gl.glGetIntegerv(GL2GL3.GL_MAX_DRAW_BUFFERS, intBuf16); // gl.glGetIntegerv(GL2GL3.GL_MAX_DRAW_BUFFERS, intBuf16);
@ -406,15 +406,15 @@ public class JoglRenderer implements Renderer {
} }
caps.add(Caps.Multisample); caps.add(Caps.Multisample);
} }
//supports sRGB pipeline //supports sRGB pipeline
if ((gl.isExtensionAvailable("GL_ARB_framebuffer_sRGB") && gl.isExtensionAvailable("GL_EXT_texture_sRGB")) || gl.isExtensionAvailable("GL_VERSION_3_0")){ if ((gl.isExtensionAvailable("GL_ARB_framebuffer_sRGB") && gl.isExtensionAvailable("GL_EXT_texture_sRGB")) || gl.isExtensionAvailable("GL_VERSION_3_0")){
caps.add(Caps.Srgb); caps.add(Caps.Srgb);
} }
logger.log(Level.FINE, "Caps: {0}", caps); logger.log(Level.FINE, "Caps: {0}", caps);
} }
@Override @Override
public void invalidateState() { public void invalidateState() {
context.reset(); context.reset();
@ -427,7 +427,7 @@ public class JoglRenderer implements Renderer {
gl.glGetIntegerv(GL2GL3.GL_READ_BUFFER, intBuf1); gl.glGetIntegerv(GL2GL3.GL_READ_BUFFER, intBuf1);
initialReadBuf = intBuf1.get(0); initialReadBuf = intBuf1.get(0);
} }
@Override @Override
public void resetGLObjects() { public void resetGLObjects() {
logger.log(Level.FINE, "Reseting objects and invalidating state"); logger.log(Level.FINE, "Reseting objects and invalidating state");
@ -435,7 +435,7 @@ public class JoglRenderer implements Renderer {
statistics.clearMemory(); statistics.clearMemory();
invalidateState(); invalidateState();
} }
@Override @Override
public void cleanup() { public void cleanup() {
logger.log(Level.FINE, "Deleting objects and invalidating state"); logger.log(Level.FINE, "Deleting objects and invalidating state");
@ -443,13 +443,13 @@ public class JoglRenderer implements Renderer {
statistics.clearMemory(); statistics.clearMemory();
invalidateState(); invalidateState();
} }
// private void checkCap(Caps cap) { // private void checkCap(Caps cap) {
// if (!caps.contains(cap)) { // if (!caps.contains(cap)) {
// throw new UnsupportedOperationException("Required capability missing: " + cap.name()); // throw new UnsupportedOperationException("Required capability missing: " + cap.name());
// } // }
// } // }
/*********************************************************************\ /*********************************************************************\
|* Render State *| |* Render State *|
\*********************************************************************/ \*********************************************************************/
@ -458,7 +458,7 @@ public class JoglRenderer implements Renderer {
GL gl = GLContext.getCurrentGL(); GL gl = GLContext.getCurrentGL();
gl.glDepthRange(start, end); gl.glDepthRange(start, end);
} }
@Override @Override
public void clearBuffers(boolean color, boolean depth, boolean stencil) { public void clearBuffers(boolean color, boolean depth, boolean stencil) {
GL gl = GLContext.getCurrentGL(); GL gl = GLContext.getCurrentGL();
@ -526,7 +526,7 @@ public class JoglRenderer implements Renderer {
if (state.isDepthTest() && !context.depthTestEnabled) { if (state.isDepthTest() && !context.depthTestEnabled) {
gl.glEnable(GL.GL_DEPTH_TEST); gl.glEnable(GL.GL_DEPTH_TEST);
gl.glDepthFunc(convertTestFunction(context.depthFunc)); gl.glDepthFunc(convertTestFunction(context.depthFunc));
context.depthTestEnabled = true; context.depthTestEnabled = true;
} else if (!state.isDepthTest() && context.depthTestEnabled) { } else if (!state.isDepthTest() && context.depthTestEnabled) {
gl.glDisable(GL.GL_DEPTH_TEST); gl.glDisable(GL.GL_DEPTH_TEST);
@ -540,15 +540,15 @@ public class JoglRenderer implements Renderer {
if (state.isAlphaTest() && !context.alphaTestEnabled) { if (state.isAlphaTest() && !context.alphaTestEnabled) {
gl.glEnable(GL2ES1.GL_ALPHA_TEST); gl.glEnable(GL2ES1.GL_ALPHA_TEST);
gl.getGL2ES1().glAlphaFunc(convertTestFunction(context.alphaFunc), context.alphaTestFallOff); gl.getGL2ES1().glAlphaFunc(convertTestFunction(context.alphaFunc), context.alphaTestFallOff);
context.alphaTestEnabled = true; context.alphaTestEnabled = true;
} else if (!state.isAlphaTest() && context.alphaTestEnabled) { } else if (!state.isAlphaTest() && context.alphaTestEnabled) {
gl.glDisable(GL2ES1.GL_ALPHA_TEST); gl.glDisable(GL2ES1.GL_ALPHA_TEST);
context.alphaTestEnabled = false; context.alphaTestEnabled = false;
} }
if (state.getAlphaFallOff() != context.alphaTestFallOff) { if (state.getAlphaFallOff() != context.alphaTestFallOff) {
gl.getGL2ES1().glAlphaFunc(convertTestFunction(context.alphaFunc), context.alphaTestFallOff); gl.getGL2ES1().glAlphaFunc(convertTestFunction(context.alphaFunc), context.alphaTestFallOff);
context.alphaTestFallOff = state.getAlphaFallOff(); context.alphaTestFallOff = state.getAlphaFallOff();
} }
if (state.getAlphaFunc() != context.alphaFunc) { if (state.getAlphaFunc() != context.alphaFunc) {
gl.getGL2ES1().glAlphaFunc(convertTestFunction(state.getAlphaFunc()), context.alphaTestFallOff); gl.getGL2ES1().glAlphaFunc(convertTestFunction(state.getAlphaFunc()), context.alphaTestFallOff);
context.alphaFunc = state.getAlphaFunc(); context.alphaFunc = state.getAlphaFunc();
@ -686,7 +686,7 @@ public class JoglRenderer implements Renderer {
break; break;
case Screen: case Screen:
gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE_MINUS_SRC_COLOR); gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE_MINUS_SRC_COLOR);
break; break;
case Exclusion: case Exclusion:
gl.glBlendFunc(GL.GL_ONE_MINUS_DST_COLOR, GL.GL_ONE_MINUS_SRC_COLOR); gl.glBlendFunc(GL.GL_ONE_MINUS_DST_COLOR, GL.GL_ONE_MINUS_SRC_COLOR);
break; break;
@ -739,7 +739,7 @@ public class JoglRenderer implements Renderer {
} }
} }
} }
private int convertStencilOperation(RenderState.StencilOperation stencilOp) { private int convertStencilOperation(RenderState.StencilOperation stencilOp) {
switch (stencilOp) { switch (stencilOp) {
case Keep: case Keep:
@ -785,7 +785,7 @@ public class JoglRenderer implements Renderer {
throw new UnsupportedOperationException("Unrecognized test function: " + testFunc); throw new UnsupportedOperationException("Unrecognized test function: " + testFunc);
} }
} }
/*********************************************************************\ /*********************************************************************\
|* Camera and World transforms *| |* Camera and World transforms *|
\*********************************************************************/ \*********************************************************************/
@ -847,7 +847,7 @@ public class JoglRenderer implements Renderer {
uniform.setLocation(-1); uniform.setLocation(-1);
// uniform is not declared in shader // uniform is not declared in shader
logger.log(Level.FINE, "Uniform {0} is not declared in shader {1}.", new Object[]{uniform.getName(), shader.getSources()}); logger.log(Level.FINE, "Uniform {0} is not declared in shader {1}.", new Object[]{uniform.getName(), shader.getSources()});
} else { } else {
uniform.setLocation(loc); uniform.setLocation(loc);
} }
@ -989,7 +989,7 @@ public class JoglRenderer implements Renderer {
uniform.reset(); // e.g check location again uniform.reset(); // e.g check location again
} }
} }
public int convertShaderType(Shader.ShaderType type) { public int convertShaderType(Shader.ShaderType type) {
switch (type) { switch (type) {
case Fragment: case Fragment:
@ -1002,7 +1002,7 @@ public class JoglRenderer implements Renderer {
throw new UnsupportedOperationException("Unrecognized shader type."); throw new UnsupportedOperationException("Unrecognized shader type.");
} }
} }
public void updateShaderSourceData(ShaderSource source) { public void updateShaderSourceData(ShaderSource source) {
int id = source.getId(); int id = source.getId();
GL gl = GLContext.getCurrentGL(); GL gl = GLContext.getCurrentGL();
@ -1051,7 +1051,7 @@ public class JoglRenderer implements Renderer {
codeBuf.put(definesCodeData); codeBuf.put(definesCodeData);
codeBuf.put(sourceCodeData); codeBuf.put(sourceCodeData);
codeBuf.flip(); codeBuf.flip();
byte[] array = new byte[codeBuf.limit()]; byte[] array = new byte[codeBuf.limit()];
codeBuf.rewind(); codeBuf.rewind();
codeBuf.get(array); codeBuf.get(array);
@ -1091,7 +1091,7 @@ public class JoglRenderer implements Renderer {
source.clearUpdateNeeded(); source.clearUpdateNeeded();
} else { } else {
logger.log(Level.WARNING, "Bad compile of:\n{0}", logger.log(Level.WARNING, "Bad compile of:\n{0}",
new Object[]{ShaderDebug.formatShaderSource(source.getDefines(), source.getSource(), stringBuf.toString())}); new Object[]{ShaderDebug.formatShaderSource(stringBuf.toString() + source.getDefines() + source.getSource())});
if (infoLog != null) { if (infoLog != null) {
throw new RendererException("compile error in: " + source + "\n" + infoLog); throw new RendererException("compile error in: " + source + "\n" + infoLog);
} else { } else {
@ -1296,7 +1296,7 @@ public class JoglRenderer implements Renderer {
GL.GL_NEAREST); GL.GL_NEAREST);
gl.glBindFramebuffer(GL2GL3.GL_FRAMEBUFFER, prevFBO); gl.glBindFramebuffer(GL2GL3.GL_FRAMEBUFFER, prevFBO);
try { try {
checkFrameBufferError(); checkFrameBufferError();
} catch (IllegalStateException ex) { } catch (IllegalStateException ex) {
@ -1309,7 +1309,7 @@ public class JoglRenderer implements Renderer {
// TODO: support non-blit copies? // TODO: support non-blit copies?
} }
} }
private String getTargetBufferName(int buffer) { private String getTargetBufferName(int buffer) {
switch (buffer) { switch (buffer) {
case GL.GL_NONE: case GL.GL_NONE:
@ -1400,7 +1400,7 @@ public class JoglRenderer implements Renderer {
printRealRenderBufferInfo(fb, fb.getColorBuffer(i), "Color" + i); printRealRenderBufferInfo(fb, fb.getColorBuffer(i), "Color" + i);
} }
} }
private void checkFrameBufferError() { private void checkFrameBufferError() {
GL gl = GLContext.getCurrentGL(); GL gl = GLContext.getCurrentGL();
int status = gl.glCheckFramebufferStatus(GL.GL_FRAMEBUFFER); int status = gl.glCheckFramebufferStatus(GL.GL_FRAMEBUFFER);
@ -1433,7 +1433,7 @@ public class JoglRenderer implements Renderer {
+ "Framebuffer object status is invalid. "); + "Framebuffer object status is invalid. ");
} }
} }
private void updateRenderBuffer(FrameBuffer fb, RenderBuffer rb) { private void updateRenderBuffer(FrameBuffer fb, RenderBuffer rb) {
GL gl = GLContext.getCurrentGL(); GL gl = GLContext.getCurrentGL();
int id = rb.getId(); int id = rb.getId();
@ -1454,7 +1454,7 @@ public class JoglRenderer implements Renderer {
} }
TextureUtil.GLImageFormat glFmt = TextureUtil.getImageFormatWithError(rb.getFormat(), fb.isSrgb()); TextureUtil.GLImageFormat glFmt = TextureUtil.getImageFormatWithError(rb.getFormat(), fb.isSrgb());
if (fb.getSamples() > 1 && gl.isExtensionAvailable("GL_EXT_framebuffer_multisample") if (fb.getSamples() > 1 && gl.isExtensionAvailable("GL_EXT_framebuffer_multisample")
&& gl.isGL2GL3()/*&& gl.isFunctionAvailable("glRenderbufferStorageMultisample")*/) { && gl.isGL2GL3()/*&& gl.isFunctionAvailable("glRenderbufferStorageMultisample")*/) {
int samples = fb.getSamples(); int samples = fb.getSamples();
@ -1470,7 +1470,7 @@ public class JoglRenderer implements Renderer {
glFmt.internalFormat, fb.getWidth(), fb.getHeight()); glFmt.internalFormat, fb.getWidth(), fb.getHeight());
} }
} }
private int convertAttachmentSlot(int attachmentSlot) { private int convertAttachmentSlot(int attachmentSlot) {
// can also add support for stencil here // can also add support for stencil here
if (attachmentSlot == FrameBuffer.SLOT_DEPTH) { if (attachmentSlot == FrameBuffer.SLOT_DEPTH) {
@ -1483,7 +1483,7 @@ public class JoglRenderer implements Renderer {
return GL.GL_COLOR_ATTACHMENT0 + attachmentSlot; return GL.GL_COLOR_ATTACHMENT0 + attachmentSlot;
} }
public void updateRenderTexture(FrameBuffer fb, RenderBuffer rb) { public void updateRenderTexture(FrameBuffer fb, RenderBuffer rb) {
GL gl = GLContext.getCurrentGL(); GL gl = GLContext.getCurrentGL();
Texture tex = rb.getTexture(); Texture tex = rb.getTexture();
@ -1497,13 +1497,13 @@ public class JoglRenderer implements Renderer {
setupTextureParams(tex); setupTextureParams(tex);
} }
gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER,
convertAttachmentSlot(rb.getSlot()), convertAttachmentSlot(rb.getSlot()),
convertTextureType(tex.getType(), image.getMultiSamples(), rb.getFace()), convertTextureType(tex.getType(), image.getMultiSamples(), rb.getFace()),
image.getId(), image.getId(),
0); 0);
} }
public void updateFrameBufferAttachment(FrameBuffer fb, RenderBuffer rb) { public void updateFrameBufferAttachment(FrameBuffer fb, RenderBuffer rb) {
boolean needAttach; boolean needAttach;
if (rb.getTexture() == null) { if (rb.getTexture() == null) {
@ -1520,7 +1520,7 @@ public class JoglRenderer implements Renderer {
GL.GL_RENDERBUFFER, rb.getId()); GL.GL_RENDERBUFFER, rb.getId());
} }
} }
public void updateFrameBuffer(FrameBuffer fb) { public void updateFrameBuffer(FrameBuffer fb) {
GL gl = GLContext.getCurrentGL(); GL gl = GLContext.getCurrentGL();
int id = fb.getId(); int id = fb.getId();
@ -1553,7 +1553,7 @@ public class JoglRenderer implements Renderer {
fb.clearUpdateNeeded(); fb.clearUpdateNeeded();
} }
public Vector2f[] getFrameBufferSamplePositions(FrameBuffer fb) { public Vector2f[] getFrameBufferSamplePositions(FrameBuffer fb) {
if (fb.getSamples() <= 1) { if (fb.getSamples() <= 1) {
throw new IllegalArgumentException("Framebuffer must be multisampled"); throw new IllegalArgumentException("Framebuffer must be multisampled");
@ -1579,7 +1579,7 @@ public class JoglRenderer implements Renderer {
public void setMainFrameBufferOverride(FrameBuffer fb) { public void setMainFrameBufferOverride(FrameBuffer fb) {
mainFbOverride = fb; mainFbOverride = fb;
} }
@Override @Override
public void setFrameBuffer(FrameBuffer fb) { public void setFrameBuffer(FrameBuffer fb) {
GL gl = GLContext.getCurrentGL(); GL gl = GLContext.getCurrentGL();
@ -1587,7 +1587,7 @@ public class JoglRenderer implements Renderer {
throw new RendererException("Framebuffer objects are not supported" + throw new RendererException("Framebuffer objects are not supported" +
" by the video hardware"); " by the video hardware");
} }
if (fb == null && mainFbOverride != null) { if (fb == null && mainFbOverride != null) {
fb = mainFbOverride; fb = mainFbOverride;
} }
@ -1597,7 +1597,7 @@ public class JoglRenderer implements Renderer {
return; return;
} }
} }
// generate mipmaps for last FB if needed // generate mipmaps for last FB if needed
if (lastFb != null) { if (lastFb != null) {
for (int i = 0; i < lastFb.getNumColorBuffers(); i++) { for (int i = 0; i < lastFb.getNumColorBuffers(); i++) {
@ -1614,7 +1614,7 @@ public class JoglRenderer implements Renderer {
} }
} }
} }
if (fb == null) { if (fb == null) {
// unbind any fbos // unbind any fbos
if (context.boundFBO != 0) { if (context.boundFBO != 0) {
@ -1643,7 +1643,7 @@ public class JoglRenderer implements Renderer {
throw new IllegalArgumentException("The framebuffer: " + fb throw new IllegalArgumentException("The framebuffer: " + fb
+ "\nDoesn't have any color/depth buffers"); + "\nDoesn't have any color/depth buffers");
} }
if (fb.isUpdateNeeded()) { if (fb.isUpdateNeeded()) {
updateFrameBuffer(fb); updateFrameBuffer(fb);
} }
@ -1714,7 +1714,7 @@ public class JoglRenderer implements Renderer {
assert fb.getId() >= 0; assert fb.getId() >= 0;
assert context.boundFBO == fb.getId(); assert context.boundFBO == fb.getId();
lastFb = fb; lastFb = fb;
try { try {
checkFrameBufferError(); checkFrameBufferError();
} catch (IllegalStateException ex) { } catch (IllegalStateException ex) {
@ -1748,13 +1748,13 @@ public class JoglRenderer implements Renderer {
gl.glReadPixels(vpX, vpY, vpW, vpH, /*GL.GL_RGBA*/ GL.GL_BGRA, GL.GL_UNSIGNED_BYTE, byteBuf); gl.glReadPixels(vpX, vpY, vpW, vpH, /*GL.GL_RGBA*/ GL.GL_BGRA, GL.GL_UNSIGNED_BYTE, byteBuf);
} }
private void deleteRenderBuffer(FrameBuffer fb, RenderBuffer rb) { private void deleteRenderBuffer(FrameBuffer fb, RenderBuffer rb) {
intBuf1.put(0, rb.getId()); intBuf1.put(0, rb.getId());
GL gl = GLContext.getCurrentGL(); GL gl = GLContext.getCurrentGL();
gl.glDeleteRenderbuffers(1, intBuf1); gl.glDeleteRenderbuffers(1, intBuf1);
} }
@Override @Override
public void deleteFrameBuffer(FrameBuffer fb) { public void deleteFrameBuffer(FrameBuffer fb) {
if (fb.getId() != -1) { if (fb.getId() != -1) {
@ -1785,10 +1785,10 @@ public class JoglRenderer implements Renderer {
private int convertTextureType(Texture.Type type, int samples, int face) { private int convertTextureType(Texture.Type type, int samples, int face) {
GL gl = GLContext.getCurrentGL(); GL gl = GLContext.getCurrentGL();
if (samples > 1 && !gl.isExtensionAvailable("GL_ARB_texture_multisample")) { if (samples > 1 && !gl.isExtensionAvailable("GL_ARB_texture_multisample")) {
throw new RendererException("Multisample textures are not supported" + throw new RendererException("Multisample textures are not supported" +
" by the video hardware."); " by the video hardware.");
} }
switch (type) { switch (type) {
case TwoDimensional: case TwoDimensional:
if (samples > 1) { if (samples > 1) {
@ -1941,7 +1941,7 @@ public class JoglRenderer implements Renderer {
statistics.onNewTexture(); statistics.onNewTexture();
} }
// bind texture // bind texture
int target = convertTextureType(type, img.getMultiSamples(), -1); int target = convertTextureType(type, img.getMultiSamples(), -1);
if (context.boundTextureUnit != unit) { if (context.boundTextureUnit != unit) {
gl.glActiveTexture(GL.GL_TEXTURE0 + unit); gl.glActiveTexture(GL.GL_TEXTURE0 + unit);
@ -1957,7 +1957,7 @@ public class JoglRenderer implements Renderer {
if (!img.hasMipmaps() && img.isGeneratedMipmapsRequired()) { if (!img.hasMipmaps() && img.isGeneratedMipmapsRequired()) {
// Image does not have mipmaps, but they are required. // Image does not have mipmaps, but they are required.
// Generate from base level. // Generate from base level.
if (!gl.isExtensionAvailable("GL_VERSION_3_0")) { if (!gl.isExtensionAvailable("GL_VERSION_3_0")) {
if (gl.isGL2ES1()) { if (gl.isGL2ES1()) {
gl.glTexParameteri(target, GL2ES1.GL_GENERATE_MIPMAP, GL.GL_TRUE); gl.glTexParameteri(target, GL2ES1.GL_GENERATE_MIPMAP, GL.GL_TRUE);
@ -1968,7 +1968,7 @@ public class JoglRenderer implements Renderer {
// We'll generate mipmaps via glGenerateMipmapEXT (see below) // We'll generate mipmaps via glGenerateMipmapEXT (see below)
} }
} else if (img.hasMipmaps()) { } else if (img.hasMipmaps()) {
// Image already has mipmaps, set the max level based on the // Image already has mipmaps, set the max level based on the
// number of mipmaps we have. // number of mipmaps we have.
if (gl.isGL2GL3()) { if (gl.isGL2GL3()) {
gl.glTexParameteri(target, GL2ES3.GL_TEXTURE_MAX_LEVEL, img.getMipMapSizes().length - 1); gl.glTexParameteri(target, GL2ES3.GL_TEXTURE_MAX_LEVEL, img.getMipMapSizes().length - 1);
@ -2003,7 +2003,7 @@ public class JoglRenderer implements Renderer {
throw new RendererException("Multisample textures not supported by graphics hardware"); throw new RendererException("Multisample textures not supported by graphics hardware");
} }
} }
if (target == GL.GL_TEXTURE_CUBE_MAP) { if (target == GL.GL_TEXTURE_CUBE_MAP) {
List<ByteBuffer> data = img.getData(); List<ByteBuffer> data = img.getData();
if (data.size() != 6) { if (data.size() != 6) {
@ -2018,12 +2018,12 @@ public class JoglRenderer implements Renderer {
if (!caps.contains(Caps.TextureArray)) { if (!caps.contains(Caps.TextureArray)) {
throw new RendererException("Texture arrays not supported by graphics hardware"); throw new RendererException("Texture arrays not supported by graphics hardware");
} }
List<ByteBuffer> data = img.getData(); List<ByteBuffer> data = img.getData();
// -1 index specifies prepare data for 2D Array // -1 index specifies prepare data for 2D Array
TextureUtil.uploadTexture(img, target, -1, 0, linearizeSrgbImages); TextureUtil.uploadTexture(img, target, -1, 0, linearizeSrgbImages);
for (int i = 0; i < data.size(); i++) { for (int i = 0; i < data.size(); i++) {
// upload each slice of 2D array in turn // upload each slice of 2D array in turn
// this time with the appropriate index // this time with the appropriate index
@ -2140,7 +2140,7 @@ public class JoglRenderer implements Renderer {
throw new RuntimeException("Unknown usage type: " + usage); throw new RuntimeException("Unknown usage type: " + usage);
} }
} }
private int convertFormat(VertexBuffer.Format format) { private int convertFormat(VertexBuffer.Format format) {
switch (format) { switch (format) {
case Byte: case Byte:
@ -2232,7 +2232,7 @@ public class JoglRenderer implements Renderer {
//statistics.onDeleteVertexBuffer(); //statistics.onDeleteVertexBuffer();
} }
} }
public void clearVertexAttribs() { public void clearVertexAttribs() {
GL gl = GLContext.getCurrentGL(); GL gl = GLContext.getCurrentGL();
IDList attribList = context.attribIndexList; IDList attribList = context.attribIndexList;
@ -2246,12 +2246,12 @@ public class JoglRenderer implements Renderer {
} }
context.attribIndexList.copyNewToOld(); context.attribIndexList.copyNewToOld();
} }
public void setVertexAttrib(VertexBuffer vb, VertexBuffer idb) { public void setVertexAttrib(VertexBuffer vb, VertexBuffer idb) {
if (vb.getBufferType() == VertexBuffer.Type.Index) { if (vb.getBufferType() == VertexBuffer.Type.Index) {
throw new IllegalArgumentException("Index buffers not allowed to be set to vertex attrib"); throw new IllegalArgumentException("Index buffers not allowed to be set to vertex attrib");
} }
int programId = context.boundShaderProgram; int programId = context.boundShaderProgram;
if (programId > 0) { if (programId > 0) {
GL gl = GLContext.getCurrentGL(); GL gl = GLContext.getCurrentGL();
@ -2275,7 +2275,7 @@ public class JoglRenderer implements Renderer {
attrib.setLocation(loc); attrib.setLocation(loc);
} }
} }
if (vb.isInstanced()) { if (vb.isInstanced()) {
if (!gl.isExtensionAvailable("GL_ARB_instanced_arrays") if (!gl.isExtensionAvailable("GL_ARB_instanced_arrays")
|| !gl.isExtensionAvailable("GL_ARB_draw_instanced")) { || !gl.isExtensionAvailable("GL_ARB_draw_instanced")) {
@ -2341,7 +2341,7 @@ public class JoglRenderer implements Renderer {
4 * 4 * i); 4 * 4 * i);
} }
} }
for (int i = 0; i < slotsRequired; i++) { for (int i = 0; i < slotsRequired; i++) {
int slot = loc + i; int slot = loc + i;
if (vb.isInstanced() && (attribs[slot] == null || !attribs[slot].isInstanced())) { if (vb.isInstanced() && (attribs[slot] == null || !attribs[slot].isInstanced())) {
@ -2362,7 +2362,7 @@ public class JoglRenderer implements Renderer {
public void setVertexAttrib(VertexBuffer vb) { public void setVertexAttrib(VertexBuffer vb) {
setVertexAttrib(vb, null); setVertexAttrib(vb, null);
} }
public void drawTriangleArray(Mesh.Mode mode, int count, int vertCount) { public void drawTriangleArray(Mesh.Mode mode, int count, int vertCount) {
boolean useInstancing = count > 1 && caps.contains(Caps.MeshInstancing); boolean useInstancing = count > 1 && caps.contains(Caps.MeshInstancing);
GL gl = GLContext.getCurrentGL(); GL gl = GLContext.getCurrentGL();
@ -2375,7 +2375,7 @@ public class JoglRenderer implements Renderer {
gl.glDrawArrays(convertElementMode(mode), 0, vertCount); gl.glDrawArrays(convertElementMode(mode), 0, vertCount);
} }
} }
public void drawTriangleList(VertexBuffer indexBuf, Mesh mesh, int count) { public void drawTriangleList(VertexBuffer indexBuf, Mesh mesh, int count) {
if (indexBuf.getBufferType() != VertexBuffer.Type.Index) { if (indexBuf.getBufferType() != VertexBuffer.Type.Index) {
throw new IllegalArgumentException("Only index buffers are allowed as triangle lists."); throw new IllegalArgumentException("Only index buffers are allowed as triangle lists.");
@ -2397,10 +2397,10 @@ public class JoglRenderer implements Renderer {
} else { } else {
//statistics.onVertexBufferUse(indexBuf, true); //statistics.onVertexBufferUse(indexBuf, true);
} }
int vertCount = mesh.getVertexCount(); int vertCount = mesh.getVertexCount();
boolean useInstancing = count > 1 && caps.contains(Caps.MeshInstancing); boolean useInstancing = count > 1 && caps.contains(Caps.MeshInstancing);
if (mesh.getMode() == Mode.Hybrid) { if (mesh.getMode() == Mode.Hybrid) {
int[] modeStart = mesh.getModeStart(); int[] modeStart = mesh.getModeStart();
int[] elementLengths = mesh.getElementLengths(); int[] elementLengths = mesh.getElementLengths();
@ -2531,7 +2531,7 @@ public class JoglRenderer implements Renderer {
if (interleavedData != null && interleavedData.isUpdateNeeded()) { if (interleavedData != null && interleavedData.isUpdateNeeded()) {
updateBufferData(interleavedData); updateBufferData(interleavedData);
} }
if (instanceData != null) { if (instanceData != null) {
setVertexAttrib(instanceData, null); setVertexAttrib(instanceData, null);
} }
@ -2552,7 +2552,7 @@ public class JoglRenderer implements Renderer {
} }
} }
} }
private void renderMeshVertexArray(Mesh mesh, int lod, int count, VertexBuffer instanceData) { private void renderMeshVertexArray(Mesh mesh, int lod, int count, VertexBuffer instanceData) {
if (mesh.getId() == -1) { if (mesh.getId() == -1) {
updateVertexArray(mesh, instanceData); updateVertexArray(mesh, instanceData);
@ -2583,13 +2583,13 @@ public class JoglRenderer implements Renderer {
clearVertexAttribs(); clearVertexAttribs();
clearTextureUnits(); clearTextureUnits();
} }
private void renderMeshDefault(Mesh mesh, int lod, int count, VertexBuffer[] instanceData) { private void renderMeshDefault(Mesh mesh, int lod, int count, VertexBuffer[] instanceData) {
// Here while count is still passed in. Can be removed when/if // Here while count is still passed in. Can be removed when/if
// the method is collapsed again. -pspeed // the method is collapsed again. -pspeed
count = Math.max(mesh.getInstanceCount(), count); count = Math.max(mesh.getInstanceCount(), count);
VertexBuffer interleavedData = mesh.getBuffer(Type.InterleavedData); VertexBuffer interleavedData = mesh.getBuffer(Type.InterleavedData);
if (interleavedData != null && interleavedData.isUpdateNeeded()) { if (interleavedData != null && interleavedData.isUpdateNeeded()) {
updateBufferData(interleavedData); updateBufferData(interleavedData);
@ -2607,7 +2607,7 @@ public class JoglRenderer implements Renderer {
setVertexAttrib(vb, null); setVertexAttrib(vb, null);
} }
} }
for (VertexBuffer vb : mesh.getBufferList().getArray()) { for (VertexBuffer vb : mesh.getBufferList().getArray()) {
if (vb.getBufferType() == Type.InterleavedData if (vb.getBufferType() == Type.InterleavedData
|| vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers || vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers
@ -2684,8 +2684,8 @@ public class JoglRenderer implements Renderer {
logger.log(Level.FINER, "SRGB FrameBuffer enabled (Gamma Correction)"); logger.log(Level.FINER, "SRGB FrameBuffer enabled (Gamma Correction)");
}else{ }else{
GLContext.getCurrentGL().glDisable(GL3.GL_FRAMEBUFFER_SRGB); GLContext.getCurrentGL().glDisable(GL3.GL_FRAMEBUFFER_SRGB);
} }
} }
@Override @Override
@ -2694,6 +2694,6 @@ public class JoglRenderer implements Renderer {
} }
public void readFrameBufferWithFormat(FrameBuffer fb, ByteBuffer byteBuf, Image.Format format) { public void readFrameBufferWithFormat(FrameBuffer fb, ByteBuffer byteBuf, Image.Format format) {
throw new UnsupportedOperationException("Not supported yet. URA will make that work seamlessly"); throw new UnsupportedOperationException("Not supported yet. URA will make that work seamlessly");
} }
} }

Loading…
Cancel
Save