* Add checks for maximum texture resolution in all renderers

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9980 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Sha..rd 12 years ago
parent 78d1754df1
commit 9e03dba566
  1. 11
      engine/src/android/com/jme3/renderer/android/OGLESShaderRenderer.java
  2. 7
      engine/src/jogl/com/jme3/renderer/jogl/JoglGL1Renderer.java
  3. 13
      engine/src/jogl/com/jme3/renderer/jogl/JoglRenderer.java
  4. 7
      engine/src/lwjgl/com/jme3/renderer/lwjgl/LwjglGL1Renderer.java
  5. 12
      engine/src/lwjgl/com/jme3/renderer/lwjgl/LwjglRenderer.java

@ -1494,6 +1494,17 @@ public class OGLESShaderRenderer implements Renderer {
img.setMipmapsGenerated(true); img.setMipmapsGenerated(true);
} }
if (target == GLES20.GL_TEXTURE_CUBE_MAP) {
// Check max texture size before upload
if (img.getWidth() > maxCubeTexSize || img.getHeight() > maxCubeTexSize) {
throw new RendererException("Cannot upload cubemap " + img + ". The maximum supported cubemap resolution is " + maxCubeTexSize);
}
} else {
if (img.getWidth() > maxTexSize || img.getHeight() > maxTexSize) {
throw new RendererException("Cannot upload texture " + img + ". The maximum supported texture resolution is " + maxTexSize);
}
}
if (target == GLES20.GL_TEXTURE_CUBE_MAP) { if (target == GLES20.GL_TEXTURE_CUBE_MAP) {
// Upload a cube map / sky box // Upload a cube map / sky box
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

@ -41,6 +41,7 @@ import com.jme3.math.Vector3f;
import com.jme3.renderer.Caps; import com.jme3.renderer.Caps;
import com.jme3.renderer.GL1Renderer; import com.jme3.renderer.GL1Renderer;
import com.jme3.renderer.RenderContext; import com.jme3.renderer.RenderContext;
import com.jme3.renderer.RendererException;
import com.jme3.renderer.Statistics; import com.jme3.renderer.Statistics;
import com.jme3.scene.Mesh; import com.jme3.scene.Mesh;
import com.jme3.scene.Mesh.Mode; import com.jme3.scene.Mesh.Mode;
@ -142,6 +143,8 @@ public class JoglGL1Renderer implements GL1Renderer {
gl.glGetIntegerv(GL2.GL_MAX_LIGHTS, ib1); gl.glGetIntegerv(GL2.GL_MAX_LIGHTS, ib1);
maxLights = ib1.get(0); maxLights = ib1.get(0);
gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, ib1);
maxTexSize = ib1.get(0);
} }
public void invalidateState() { public void invalidateState() {
@ -805,6 +808,10 @@ public class JoglGL1Renderer implements GL1Renderer {
} else { } else {
} }
if (img.getWidth() > maxTexSize || img.getHeight() > maxTexSize) {
throw new RendererException("Cannot upload texture " + img + ". The maximum supported texture resolution is " + maxTexSize);
}
/* /*
if (target == GL_TEXTURE_CUBE_MAP) { if (target == GL_TEXTURE_CUBE_MAP) {
List<ByteBuffer> data = img.getData(); List<ByteBuffer> data = img.getData();

@ -1903,7 +1903,18 @@ 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) {
// Check max texture size before upload
if (img.getWidth() > maxCubeTexSize || img.getHeight() > maxCubeTexSize) {
throw new RendererException("Cannot upload cubemap " + img + ". The maximum supported cubemap resolution is " + maxCubeTexSize);
}
} else {
if (img.getWidth() > maxTexSize || img.getHeight() > maxTexSize) {
throw new RendererException("Cannot upload texture " + img + ". The maximum supported texture resolution is " + maxTexSize);
}
}
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) {

@ -10,6 +10,7 @@ import com.jme3.math.Vector3f;
import com.jme3.renderer.Caps; import com.jme3.renderer.Caps;
import com.jme3.renderer.GL1Renderer; import com.jme3.renderer.GL1Renderer;
import com.jme3.renderer.RenderContext; import com.jme3.renderer.RenderContext;
import com.jme3.renderer.RendererException;
import com.jme3.renderer.Statistics; import com.jme3.renderer.Statistics;
import com.jme3.scene.Mesh; import com.jme3.scene.Mesh;
import com.jme3.scene.Mesh.Mode; import com.jme3.scene.Mesh.Mode;
@ -111,7 +112,7 @@ public class LwjglGL1Renderer implements GL1Renderer {
} }
maxLights = glGetInteger(GL_MAX_LIGHTS); maxLights = glGetInteger(GL_MAX_LIGHTS);
maxTexSize = glGetInteger(GL_MAX_TEXTURE_SIZE);
} }
public void invalidateState() { public void invalidateState() {
@ -761,6 +762,10 @@ public class LwjglGL1Renderer implements GL1Renderer {
} else { } else {
} }
if (img.getWidth() > maxTexSize || img.getHeight() > maxTexSize) {
throw new RendererException("Cannot upload texture " + img + ". The maximum supported texture resolution is " + maxTexSize);
}
/* /*
if (target == GL_TEXTURE_CUBE_MAP) { if (target == GL_TEXTURE_CUBE_MAP) {
List<ByteBuffer> data = img.getData(); List<ByteBuffer> data = img.getData();

@ -85,6 +85,7 @@ public class LwjglRenderer implements Renderer {
private final StringBuilder stringBuf = new StringBuilder(250); private final StringBuilder stringBuf = new StringBuilder(250);
private final IntBuffer intBuf1 = BufferUtils.createIntBuffer(1); private final IntBuffer intBuf1 = BufferUtils.createIntBuffer(1);
private final IntBuffer intBuf16 = BufferUtils.createIntBuffer(16); private final IntBuffer intBuf16 = BufferUtils.createIntBuffer(16);
private final FloatBuffer floatBuf16 = BufferUtils.createFloatBuffer(16);
private final RenderContext context = new RenderContext(); private final RenderContext context = new RenderContext();
private final NativeObjectManager objManager = new NativeObjectManager(); private final NativeObjectManager objManager = new NativeObjectManager();
private final EnumSet<Caps> caps = EnumSet.noneOf(Caps.class); private final EnumSet<Caps> caps = EnumSet.noneOf(Caps.class);
@ -1851,6 +1852,17 @@ public class LwjglRenderer 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_TEXTURE_CUBE_MAP) {
// Check max texture size before upload
if (img.getWidth() > maxCubeTexSize || img.getHeight() > maxCubeTexSize) {
throw new RendererException("Cannot upload cubemap " + img + ". The maximum supported cubemap resolution is " + maxCubeTexSize);
}
} else {
if (img.getWidth() > maxTexSize || img.getHeight() > maxTexSize) {
throw new RendererException("Cannot upload texture " + img + ". The maximum supported texture resolution is " + maxTexSize);
}
}
if (target == GL_TEXTURE_CUBE_MAP) { if (target == GL_TEXTURE_CUBE_MAP) {
List<ByteBuffer> data = img.getData(); List<ByteBuffer> data = img.getData();

Loading…
Cancel
Save