Merge pull request #277 from zzuegg/master
Added GL_MAX_VERTEX_UNIFORM_COMPONENTS
This commit is contained in:
commit
37c572434c
@ -75,4 +75,6 @@ public enum Limits {
|
|||||||
ColorTextureSamples,
|
ColorTextureSamples,
|
||||||
|
|
||||||
DepthTextureSamples,
|
DepthTextureSamples,
|
||||||
|
|
||||||
|
VertexUniformVectors,
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,8 @@ public interface GL {
|
|||||||
public static final int GL_MAX_TEXTURE_SIZE = 0xD33;
|
public static final int GL_MAX_TEXTURE_SIZE = 0xD33;
|
||||||
public static final int GL_MAX_VERTEX_ATTRIBS = 0x8869;
|
public static final int GL_MAX_VERTEX_ATTRIBS = 0x8869;
|
||||||
public static final int GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C;
|
public static final int GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C;
|
||||||
|
public static final int GL_MAX_VERTEX_UNIFORM_COMPONENTS = 0x8B4A;
|
||||||
|
public static final int GL_MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB;
|
||||||
public static final int GL_MIRRORED_REPEAT = 0x8370;
|
public static final int GL_MIRRORED_REPEAT = 0x8370;
|
||||||
public static final int GL_NEAREST = 0x2600;
|
public static final int GL_NEAREST = 0x2600;
|
||||||
public static final int GL_NEAREST_MIPMAP_LINEAR = 0x2702;
|
public static final int GL_NEAREST_MIPMAP_LINEAR = 0x2702;
|
||||||
|
@ -257,13 +257,17 @@ public class GLRenderer implements Renderer {
|
|||||||
// gl.glGetInteger(GL.GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, intBuf16);
|
// gl.glGetInteger(GL.GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, intBuf16);
|
||||||
// fragUniforms = intBuf16.get(0);
|
// fragUniforms = intBuf16.get(0);
|
||||||
// logger.log(Level.FINER, "Fragment Uniforms: {0}", fragUniforms);
|
// logger.log(Level.FINER, "Fragment Uniforms: {0}", fragUniforms);
|
||||||
|
if (caps.contains(Caps.OpenGLES20)) {
|
||||||
|
limits.put(Limits.VertexUniformVectors, getInteger(GL.GL_MAX_VERTEX_UNIFORM_VECTORS));
|
||||||
|
} else {
|
||||||
|
limits.put(Limits.VertexUniformVectors, getInteger(GL.GL_MAX_VERTEX_UNIFORM_COMPONENTS) / 4);
|
||||||
|
}
|
||||||
limits.put(Limits.VertexAttributes, getInteger(GL.GL_MAX_VERTEX_ATTRIBS));
|
limits.put(Limits.VertexAttributes, getInteger(GL.GL_MAX_VERTEX_ATTRIBS));
|
||||||
limits.put(Limits.TextureSize, getInteger(GL.GL_MAX_TEXTURE_SIZE));
|
limits.put(Limits.TextureSize, getInteger(GL.GL_MAX_TEXTURE_SIZE));
|
||||||
limits.put(Limits.CubemapSize, getInteger(GL.GL_MAX_CUBE_MAP_TEXTURE_SIZE));
|
limits.put(Limits.CubemapSize, getInteger(GL.GL_MAX_CUBE_MAP_TEXTURE_SIZE));
|
||||||
|
|
||||||
if (hasExtension("GL_ARB_draw_instanced") &&
|
if (hasExtension("GL_ARB_draw_instanced") &&
|
||||||
hasExtension("GL_ARB_instanced_arrays")) {
|
hasExtension("GL_ARB_instanced_arrays")) {
|
||||||
caps.add(Caps.MeshInstancing);
|
caps.add(Caps.MeshInstancing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,11 +284,11 @@ public class GLRenderer implements Renderer {
|
|||||||
boolean hasFloatTexture;
|
boolean hasFloatTexture;
|
||||||
|
|
||||||
hasFloatTexture = hasExtension("GL_OES_texture_half_float") &&
|
hasFloatTexture = hasExtension("GL_OES_texture_half_float") &&
|
||||||
hasExtension("GL_OES_texture_float");
|
hasExtension("GL_OES_texture_float");
|
||||||
|
|
||||||
if (!hasFloatTexture) {
|
if (!hasFloatTexture) {
|
||||||
hasFloatTexture = hasExtension("GL_ARB_texture_float") &&
|
hasFloatTexture = hasExtension("GL_ARB_texture_float") &&
|
||||||
hasExtension("GL_ARB_half_float_pixel");
|
hasExtension("GL_ARB_half_float_pixel");
|
||||||
|
|
||||||
if (!hasFloatTexture) {
|
if (!hasFloatTexture) {
|
||||||
hasFloatTexture = caps.contains(Caps.OpenGL30);
|
hasFloatTexture = caps.contains(Caps.OpenGL30);
|
||||||
@ -302,8 +306,8 @@ public class GLRenderer implements Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hasExtension("GL_OES_rgb8_rgba8") ||
|
if (hasExtension("GL_OES_rgb8_rgba8") ||
|
||||||
hasExtension("GL_ARM_rgba8") ||
|
hasExtension("GL_ARM_rgba8") ||
|
||||||
hasExtension("GL_EXT_texture_format_BGRA8888")) {
|
hasExtension("GL_EXT_texture_format_BGRA8888")) {
|
||||||
caps.add(Caps.Rgba8);
|
caps.add(Caps.Rgba8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,7 +316,7 @@ public class GLRenderer implements Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hasExtension("GL_ARB_color_buffer_float") &&
|
if (hasExtension("GL_ARB_color_buffer_float") &&
|
||||||
hasExtension("GL_ARB_half_float_pixel")) {
|
hasExtension("GL_ARB_half_float_pixel")) {
|
||||||
// XXX: Require both 16 and 32 bit float support for FloatColorBuffer.
|
// XXX: Require both 16 and 32 bit float support for FloatColorBuffer.
|
||||||
caps.add(Caps.FloatColorBuffer);
|
caps.add(Caps.FloatColorBuffer);
|
||||||
}
|
}
|
||||||
@ -322,7 +326,7 @@ public class GLRenderer implements Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((hasExtension("GL_EXT_packed_float") && hasFloatTexture) ||
|
if ((hasExtension("GL_EXT_packed_float") && hasFloatTexture) ||
|
||||||
caps.contains(Caps.OpenGL30)) {
|
caps.contains(Caps.OpenGL30)) {
|
||||||
// Either OpenGL3 is available or both packed_float & half_float_pixel.
|
// Either OpenGL3 is available or both packed_float & half_float_pixel.
|
||||||
caps.add(Caps.PackedFloatColorBuffer);
|
caps.add(Caps.PackedFloatColorBuffer);
|
||||||
caps.add(Caps.PackedFloatTexture);
|
caps.add(Caps.PackedFloatTexture);
|
||||||
@ -350,13 +354,13 @@ public class GLRenderer implements Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hasExtension("GL_ARB_texture_non_power_of_two") ||
|
if (hasExtension("GL_ARB_texture_non_power_of_two") ||
|
||||||
hasExtension("GL_OES_texture_npot") ||
|
hasExtension("GL_OES_texture_npot") ||
|
||||||
caps.contains(Caps.OpenGL30)) {
|
caps.contains(Caps.OpenGL30)) {
|
||||||
caps.add(Caps.NonPowerOfTwoTextures);
|
caps.add(Caps.NonPowerOfTwoTextures);
|
||||||
} else {
|
} else {
|
||||||
logger.log(Level.WARNING, "Your graphics card does not "
|
logger.log(Level.WARNING, "Your graphics card does not "
|
||||||
+ "support non-power-of-2 textures. "
|
+ "support non-power-of-2 textures. "
|
||||||
+ "Some features might not work.");
|
+ "Some features might not work.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (caps.contains(Caps.OpenGLES20)) {
|
if (caps.contains(Caps.OpenGLES20)) {
|
||||||
@ -422,7 +426,7 @@ public class GLRenderer implements Renderer {
|
|||||||
|
|
||||||
// Supports sRGB pipeline.
|
// Supports sRGB pipeline.
|
||||||
if ( (hasExtension("GL_ARB_framebuffer_sRGB") && hasExtension("GL_EXT_texture_sRGB"))
|
if ( (hasExtension("GL_ARB_framebuffer_sRGB") && hasExtension("GL_EXT_texture_sRGB"))
|
||||||
|| caps.contains(Caps.OpenGL30) ) {
|
|| caps.contains(Caps.OpenGL30) ) {
|
||||||
caps.add(Caps.Srgb);
|
caps.add(Caps.Srgb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,18 +448,18 @@ public class GLRenderer implements Renderer {
|
|||||||
|
|
||||||
// Print context information
|
// Print context information
|
||||||
logger.log(Level.INFO, "OpenGL Renderer Information\n" +
|
logger.log(Level.INFO, "OpenGL Renderer Information\n" +
|
||||||
" * Vendor: {0}\n" +
|
" * Vendor: {0}\n" +
|
||||||
" * Renderer: {1}\n" +
|
" * Renderer: {1}\n" +
|
||||||
" * OpenGL Version: {2}\n" +
|
" * OpenGL Version: {2}\n" +
|
||||||
" * GLSL Version: {3}\n" +
|
" * GLSL Version: {3}\n" +
|
||||||
" * Profile: {4}",
|
" * Profile: {4}",
|
||||||
new Object[]{
|
new Object[]{
|
||||||
gl.glGetString(GL.GL_VENDOR),
|
gl.glGetString(GL.GL_VENDOR),
|
||||||
gl.glGetString(GL.GL_RENDERER),
|
gl.glGetString(GL.GL_RENDERER),
|
||||||
gl.glGetString(GL.GL_VERSION),
|
gl.glGetString(GL.GL_VERSION),
|
||||||
gl.glGetString(GL.GL_SHADING_LANGUAGE_VERSION),
|
gl.glGetString(GL.GL_SHADING_LANGUAGE_VERSION),
|
||||||
caps.contains(Caps.CoreProfile) ? "Core" : "Compatibility"
|
caps.contains(Caps.CoreProfile) ? "Core" : "Compatibility"
|
||||||
});
|
});
|
||||||
|
|
||||||
// Print capabilities (if fine logging is enabled)
|
// Print capabilities (if fine logging is enabled)
|
||||||
if (logger.isLoggable(Level.FINE)) {
|
if (logger.isLoggable(Level.FINE)) {
|
||||||
@ -536,8 +540,8 @@ public class GLRenderer implements Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************\
|
/*********************************************************************\
|
||||||
|* Render State *|
|
|* Render State *|
|
||||||
\*********************************************************************/
|
\*********************************************************************/
|
||||||
public void setDepthRange(float start, float end) {
|
public void setDepthRange(float start, float end) {
|
||||||
gl.glDepthRange(start, end);
|
gl.glDepthRange(start, end);
|
||||||
}
|
}
|
||||||
@ -815,8 +819,8 @@ public class GLRenderer implements Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************\
|
/*********************************************************************\
|
||||||
|* Camera and World transforms *|
|
|* Camera and World transforms *|
|
||||||
\*********************************************************************/
|
\*********************************************************************/
|
||||||
public void setViewPort(int x, int y, int w, int h) {
|
public void setViewPort(int x, int y, int w, int h) {
|
||||||
if (x != vpX || vpY != y || vpW != w || vpH != h) {
|
if (x != vpX || vpY != y || vpW != w || vpH != h) {
|
||||||
gl.glViewport(x, y, w, h);
|
gl.glViewport(x, y, w, h);
|
||||||
@ -859,8 +863,8 @@ public class GLRenderer implements Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************\
|
/*********************************************************************\
|
||||||
|* Shaders *|
|
|* Shaders *|
|
||||||
\*********************************************************************/
|
\*********************************************************************/
|
||||||
protected void updateUniformLocation(Shader shader, Uniform uniform) {
|
protected void updateUniformLocation(Shader shader, Uniform uniform) {
|
||||||
int loc = gl.glGetUniformLocation(shader.getId(), uniform.getName());
|
int loc = gl.glGetUniformLocation(shader.getId(), uniform.getName());
|
||||||
if (loc < 0) {
|
if (loc < 0) {
|
||||||
@ -1043,7 +1047,7 @@ public class GLRenderer implements Renderer {
|
|||||||
|
|
||||||
if (gles2 && !language.equals("GLSL100")) {
|
if (gles2 && !language.equals("GLSL100")) {
|
||||||
throw new RendererException("This shader cannot run in OpenGL ES 2. "
|
throw new RendererException("This shader cannot run in OpenGL ES 2. "
|
||||||
+ "Only GLSL 1.00 shaders are supported.");
|
+ "Only GLSL 1.00 shaders are supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upload shader source.
|
// Upload shader source.
|
||||||
@ -1246,8 +1250,8 @@ public class GLRenderer implements Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************\
|
/*********************************************************************\
|
||||||
|* Framebuffers *|
|
|* Framebuffers *|
|
||||||
\*********************************************************************/
|
\*********************************************************************/
|
||||||
public void copyFrameBuffer(FrameBuffer src, FrameBuffer dst) {
|
public void copyFrameBuffer(FrameBuffer src, FrameBuffer dst) {
|
||||||
copyFrameBuffer(src, dst, true);
|
copyFrameBuffer(src, dst, true);
|
||||||
}
|
}
|
||||||
@ -1663,7 +1667,7 @@ public class GLRenderer implements Renderer {
|
|||||||
gl.glReadPixels(vpX, vpY, vpW, vpH, glFormat, dataType, byteBuf);
|
gl.glReadPixels(vpX, vpY, vpW, vpH, glFormat, dataType, byteBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readFrameBufferWithFormat(FrameBuffer fb, ByteBuffer byteBuf, Image.Format format) {
|
public void readFrameBufferWithFormat(FrameBuffer fb, ByteBuffer byteBuf, Image.Format format) {
|
||||||
GLImageFormat glFormat = texUtil.getImageFormatWithError(format, false);
|
GLImageFormat glFormat = texUtil.getImageFormatWithError(format, false);
|
||||||
readFrameBufferWithGLFormat(fb, byteBuf, glFormat.format, glFormat.dataType);
|
readFrameBufferWithGLFormat(fb, byteBuf, glFormat.format, glFormat.dataType);
|
||||||
}
|
}
|
||||||
@ -1696,12 +1700,12 @@ public class GLRenderer implements Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************\
|
/*********************************************************************\
|
||||||
|* Textures *|
|
|* Textures *|
|
||||||
\*********************************************************************/
|
\*********************************************************************/
|
||||||
private int convertTextureType(Texture.Type type, int samples, int face) {
|
private int convertTextureType(Texture.Type type, int samples, int face) {
|
||||||
if (samples > 1 && !caps.contains(Caps.TextureMultisample)) {
|
if (samples > 1 && !caps.contains(Caps.TextureMultisample)) {
|
||||||
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) {
|
||||||
@ -1724,7 +1728,7 @@ public class GLRenderer implements Renderer {
|
|||||||
case ThreeDimensional:
|
case ThreeDimensional:
|
||||||
if (!caps.contains(Caps.OpenGL20)) {
|
if (!caps.contains(Caps.OpenGL20)) {
|
||||||
throw new RendererException("3D textures are not supported" +
|
throw new RendererException("3D textures are not supported" +
|
||||||
" by the video hardware.");
|
" by the video hardware.");
|
||||||
}
|
}
|
||||||
return GL2.GL_TEXTURE_3D;
|
return GL2.GL_TEXTURE_3D;
|
||||||
case CubeMap:
|
case CubeMap:
|
||||||
@ -1878,8 +1882,8 @@ public class GLRenderer implements Renderer {
|
|||||||
gl2.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_FUNC, GL.GL_LEQUAL);
|
gl2.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_FUNC, GL.GL_LEQUAL);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//restoring default value
|
//restoring default value
|
||||||
gl2.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_MODE, GL.GL_NONE);
|
gl2.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_MODE, GL.GL_NONE);
|
||||||
}
|
}
|
||||||
tex.compareModeUpdated();
|
tex.compareModeUpdated();
|
||||||
}
|
}
|
||||||
@ -1910,13 +1914,13 @@ public class GLRenderer implements Renderer {
|
|||||||
if (!caps.contains(Caps.PartialNonPowerOfTwoTextures)) {
|
if (!caps.contains(Caps.PartialNonPowerOfTwoTextures)) {
|
||||||
// Cannot use any type of NPOT texture (uncommon)
|
// Cannot use any type of NPOT texture (uncommon)
|
||||||
throw new RendererException("non-power-of-2 textures are not "
|
throw new RendererException("non-power-of-2 textures are not "
|
||||||
+ "supported by the video hardware");
|
+ "supported by the video hardware");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Partial NPOT supported..
|
// Partial NPOT supported..
|
||||||
if (tex.getMinFilter().usesMipMapLevels()) {
|
if (tex.getMinFilter().usesMipMapLevels()) {
|
||||||
throw new RendererException("non-power-of-2 textures with mip-maps "
|
throw new RendererException("non-power-of-2 textures with mip-maps "
|
||||||
+ "are not supported by the video hardware");
|
+ "are not supported by the video hardware");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (tex.getType()) {
|
switch (tex.getType()) {
|
||||||
@ -1924,7 +1928,7 @@ public class GLRenderer implements Renderer {
|
|||||||
case ThreeDimensional:
|
case ThreeDimensional:
|
||||||
if (tex.getWrap(WrapAxis.R) != Texture.WrapMode.EdgeClamp) {
|
if (tex.getWrap(WrapAxis.R) != Texture.WrapMode.EdgeClamp) {
|
||||||
throw new RendererException("repeating non-power-of-2 textures "
|
throw new RendererException("repeating non-power-of-2 textures "
|
||||||
+ "are not supported by the video hardware");
|
+ "are not supported by the video hardware");
|
||||||
}
|
}
|
||||||
// fallthrough intentional!!!
|
// fallthrough intentional!!!
|
||||||
case TwoDimensionalArray:
|
case TwoDimensionalArray:
|
||||||
@ -1932,7 +1936,7 @@ public class GLRenderer implements Renderer {
|
|||||||
if (tex.getWrap(WrapAxis.S) != Texture.WrapMode.EdgeClamp
|
if (tex.getWrap(WrapAxis.S) != Texture.WrapMode.EdgeClamp
|
||||||
|| tex.getWrap(WrapAxis.T) != Texture.WrapMode.EdgeClamp) {
|
|| tex.getWrap(WrapAxis.T) != Texture.WrapMode.EdgeClamp) {
|
||||||
throw new RendererException("repeating non-power-of-2 textures "
|
throw new RendererException("repeating non-power-of-2 textures "
|
||||||
+ "are not supported by the video hardware");
|
+ "are not supported by the video hardware");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -2095,9 +2099,9 @@ public class GLRenderer implements Renderer {
|
|||||||
int nextWidth = FastMath.nearestPowerOfTwo(tex.getImage().getWidth());
|
int nextWidth = FastMath.nearestPowerOfTwo(tex.getImage().getWidth());
|
||||||
int nextHeight = FastMath.nearestPowerOfTwo(tex.getImage().getHeight());
|
int nextHeight = FastMath.nearestPowerOfTwo(tex.getImage().getHeight());
|
||||||
logger.log(Level.WARNING,
|
logger.log(Level.WARNING,
|
||||||
"Non-power-of-2 textures are not supported! Scaling texture '" + tex.getName() +
|
"Non-power-of-2 textures are not supported! Scaling texture '" + tex.getName() +
|
||||||
"' of size " + tex.getImage().getWidth() + "x" + tex.getImage().getHeight() +
|
"' of size " + tex.getImage().getWidth() + "x" + tex.getImage().getHeight() +
|
||||||
" to " + nextWidth + "x" + nextHeight);
|
" to " + nextWidth + "x" + nextHeight);
|
||||||
}
|
}
|
||||||
scaleToPot = true;
|
scaleToPot = true;
|
||||||
}
|
}
|
||||||
@ -2147,8 +2151,8 @@ public class GLRenderer implements Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************\
|
/*********************************************************************\
|
||||||
|* Vertex Buffers and Attributes *|
|
|* Vertex Buffers and Attributes *|
|
||||||
\*********************************************************************/
|
\*********************************************************************/
|
||||||
private int convertUsage(Usage usage) {
|
private int convertUsage(Usage usage) {
|
||||||
switch (usage) {
|
switch (usage) {
|
||||||
case Static:
|
case Static:
|
||||||
@ -2487,8 +2491,8 @@ public class GLRenderer implements Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************\
|
/*********************************************************************\
|
||||||
|* Render Calls *|
|
|* Render Calls *|
|
||||||
\*********************************************************************/
|
\*********************************************************************/
|
||||||
public int convertElementMode(Mesh.Mode mode) {
|
public int convertElementMode(Mesh.Mode mode) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case Points:
|
case Points:
|
||||||
@ -2654,7 +2658,7 @@ public class GLRenderer implements Renderer {
|
|||||||
if (!caps.contains(Caps.Srgb) && enableSrgb) {
|
if (!caps.contains(Caps.Srgb) && enableSrgb) {
|
||||||
// Not supported, sorry.
|
// Not supported, sorry.
|
||||||
logger.warning("sRGB framebuffer is not supported " +
|
logger.warning("sRGB framebuffer is not supported " +
|
||||||
"by video hardware, but was requested.");
|
"by video hardware, but was requested.");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user