* Added checking for image format
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7376 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
0d0454f248
commit
b5a8080f61
@ -518,7 +518,7 @@ public class LwjglGL1Renderer implements GL1Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check sizes if graphics card doesn't support NPOT
|
// Check sizes if graphics card doesn't support NPOT
|
||||||
if (!GLContext.getCapabilities().GL_ARB_texture_non_power_of_two){
|
// if (!GLContext.getCapabilities().GL_ARB_texture_non_power_of_two){
|
||||||
if (img.getWidth() != 0 && img.getHeight() != 0){
|
if (img.getWidth() != 0 && img.getHeight() != 0){
|
||||||
if (!FastMath.isPowerOfTwo(img.getWidth())
|
if (!FastMath.isPowerOfTwo(img.getWidth())
|
||||||
|| !FastMath.isPowerOfTwo(img.getHeight())
|
|| !FastMath.isPowerOfTwo(img.getHeight())
|
||||||
@ -529,7 +529,7 @@ public class LwjglGL1Renderer implements GL1Renderer {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!img.hasMipmaps() && mips) {
|
if (!img.hasMipmaps() && mips) {
|
||||||
// No pregenerated mips available,
|
// No pregenerated mips available,
|
||||||
|
@ -906,7 +906,7 @@ public class LwjglRenderer implements Renderer {
|
|||||||
// case Geometry:
|
// case Geometry:
|
||||||
// return ARBGeometryShader4.GL_GEOMETRY_SHADER_ARB;
|
// return ARBGeometryShader4.GL_GEOMETRY_SHADER_ARB;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unrecognized shader type.");
|
throw new UnsupportedOperationException("Unrecognized shader type.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1219,7 +1219,7 @@ public class LwjglRenderer implements Renderer {
|
|||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new UnsupportedOperationException("EXT_framebuffer_blit required.");
|
throw new RendererException("EXT_framebuffer_blit required.");
|
||||||
// TODO: support non-blit copies?
|
// TODO: support non-blit copies?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1269,10 +1269,12 @@ public class LwjglRenderer implements Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fb.getWidth() > maxRBSize || fb.getHeight() > maxRBSize) {
|
if (fb.getWidth() > maxRBSize || fb.getHeight() > maxRBSize) {
|
||||||
throw new UnsupportedOperationException("Resolution " + fb.getWidth()
|
throw new RendererException("Resolution " + fb.getWidth()
|
||||||
+ ":" + fb.getHeight() + " is not supported.");
|
+ ":" + fb.getHeight() + " is not supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextureUtil.checkFormatSupported(rb.getFormat());
|
||||||
|
|
||||||
if (fb.getSamples() > 1 && GLContext.getCapabilities().GL_EXT_framebuffer_multisample) {
|
if (fb.getSamples() > 1 && GLContext.getCapabilities().GL_EXT_framebuffer_multisample) {
|
||||||
int samples = fb.getSamples();
|
int samples = fb.getSamples();
|
||||||
if (maxFBOSamples < samples) {
|
if (maxFBOSamples < samples) {
|
||||||
@ -1457,7 +1459,7 @@ public class LwjglRenderer implements Renderer {
|
|||||||
} else {
|
} else {
|
||||||
if (fb.isMultiTarget()) {
|
if (fb.isMultiTarget()) {
|
||||||
if (fb.getNumColorBuffers() > maxMRTFBOAttachs) {
|
if (fb.getNumColorBuffers() > maxMRTFBOAttachs) {
|
||||||
throw new UnsupportedOperationException("Framebuffer has more"
|
throw new RendererException("Framebuffer has more"
|
||||||
+ " targets than are supported"
|
+ " targets than are supported"
|
||||||
+ " on the system!");
|
+ " on the system!");
|
||||||
}
|
}
|
||||||
@ -1843,7 +1845,7 @@ public class LwjglRenderer implements Renderer {
|
|||||||
case Stream:
|
case Stream:
|
||||||
return GL_STREAM_DRAW;
|
return GL_STREAM_DRAW;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unknown usage type.");
|
throw new UnsupportedOperationException("Unknown usage type.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1869,7 +1871,7 @@ public class LwjglRenderer implements Renderer {
|
|||||||
case Double:
|
case Double:
|
||||||
return GL_DOUBLE;
|
return GL_DOUBLE;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unknown buffer format.");
|
throw new UnsupportedOperationException("Unknown buffer format.");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1929,7 +1931,7 @@ public class LwjglRenderer implements Renderer {
|
|||||||
glBufferData(target, (DoubleBuffer) vb.getData(), usage);
|
glBufferData(target, (DoubleBuffer) vb.getData(), usage);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unknown buffer format.");
|
throw new UnsupportedOperationException("Unknown buffer format.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (vb.getFormat()) {
|
switch (vb.getFormat()) {
|
||||||
@ -1952,7 +1954,7 @@ public class LwjglRenderer implements Renderer {
|
|||||||
glBufferSubData(target, 0, (DoubleBuffer) vb.getData());
|
glBufferSubData(target, 0, (DoubleBuffer) vb.getData());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unknown buffer format.");
|
throw new UnsupportedOperationException("Unknown buffer format.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }else{
|
// }else{
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
|
|
||||||
package com.jme3.renderer.lwjgl;
|
package com.jme3.renderer.lwjgl;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GLContext;
|
||||||
|
import com.jme3.renderer.RendererException;
|
||||||
import org.lwjgl.opengl.EXTAbgr;
|
import org.lwjgl.opengl.EXTAbgr;
|
||||||
import com.jme3.texture.Image;
|
import com.jme3.texture.Image;
|
||||||
import com.jme3.texture.Image.Format;
|
import com.jme3.texture.Image.Format;
|
||||||
@ -40,6 +42,7 @@ import org.lwjgl.opengl.ARBDepthBufferFloat;
|
|||||||
import org.lwjgl.opengl.ARBHalfFloatPixel;
|
import org.lwjgl.opengl.ARBHalfFloatPixel;
|
||||||
import org.lwjgl.opengl.ARBTextureFloat;
|
import org.lwjgl.opengl.ARBTextureFloat;
|
||||||
import org.lwjgl.opengl.ARBTextureMultisample;
|
import org.lwjgl.opengl.ARBTextureMultisample;
|
||||||
|
import org.lwjgl.opengl.ContextCapabilities;
|
||||||
import org.lwjgl.opengl.EXTPackedFloat;
|
import org.lwjgl.opengl.EXTPackedFloat;
|
||||||
import org.lwjgl.opengl.EXTTextureArray;
|
import org.lwjgl.opengl.EXTTextureArray;
|
||||||
import org.lwjgl.opengl.EXTTextureSharedExponent;
|
import org.lwjgl.opengl.EXTTextureSharedExponent;
|
||||||
@ -54,6 +57,49 @@ import static org.lwjgl.opengl.GL14.*;
|
|||||||
|
|
||||||
public class TextureUtil {
|
public class TextureUtil {
|
||||||
|
|
||||||
|
private static boolean isFormatSupported(Format fmt, ContextCapabilities caps){
|
||||||
|
switch (fmt){
|
||||||
|
case ARGB4444:
|
||||||
|
return false;
|
||||||
|
case BGR8:
|
||||||
|
return caps.OpenGL12 || caps.GL_EXT_bgra;
|
||||||
|
case DXT1:
|
||||||
|
case DXT1A:
|
||||||
|
case DXT3:
|
||||||
|
case DXT5:
|
||||||
|
return caps.GL_EXT_texture_compression_s3tc;
|
||||||
|
case Depth:
|
||||||
|
case Depth16:
|
||||||
|
case Depth24:
|
||||||
|
case Depth32:
|
||||||
|
return caps.OpenGL14 || caps.GL_ARB_depth_texture;
|
||||||
|
case Depth32F:
|
||||||
|
case Luminance16F:
|
||||||
|
case Luminance16FAlpha16F:
|
||||||
|
case Luminance32F:
|
||||||
|
case RGBA16F:
|
||||||
|
case RGBA32F:
|
||||||
|
return caps.OpenGL30 || caps.GL_ARB_texture_float;
|
||||||
|
case LATC:
|
||||||
|
case LTC:
|
||||||
|
return caps.GL_EXT_texture_compression_latc;
|
||||||
|
case RGB9E5:
|
||||||
|
case RGB16F_to_RGB9E5:
|
||||||
|
return caps.OpenGL30 || caps.GL_EXT_texture_shared_exponent;
|
||||||
|
case RGB111110F:
|
||||||
|
case RGB16F_to_RGB111110F:
|
||||||
|
return caps.OpenGL30 || caps.GL_EXT_packed_float;
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void checkFormatSupported(Format fmt) {
|
||||||
|
if (!isFormatSupported(fmt, GLContext.getCapabilities())) {
|
||||||
|
throw new RendererException("Image format '" + fmt + "' is unsupported by the video hardware.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static int convertTextureFormat(Format fmt){
|
public static int convertTextureFormat(Format fmt){
|
||||||
switch (fmt){
|
switch (fmt){
|
||||||
case Alpha16:
|
case Alpha16:
|
||||||
@ -132,8 +178,10 @@ public class TextureUtil {
|
|||||||
int index,
|
int index,
|
||||||
int border,
|
int border,
|
||||||
boolean tdc){
|
boolean tdc){
|
||||||
|
|
||||||
Image.Format fmt = img.getFormat();
|
Image.Format fmt = img.getFormat();
|
||||||
|
|
||||||
|
checkFormatSupported(fmt);
|
||||||
|
|
||||||
ByteBuffer data;
|
ByteBuffer data;
|
||||||
if (index >= 0 && img.getData() != null && img.getData().size() > 0){
|
if (index >= 0 && img.getData() != null && img.getData().size() > 0){
|
||||||
data = img.getData(index);
|
data = img.getData(index);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user