Skip to content

Commit

Permalink
Test loadCommonCapabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
kristinfjola committed Apr 3, 2016
1 parent c7dba4b commit 16c474d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class GLRenderer implements Renderer {
protected final RenderContext context = new RenderContext();
private final NativeObjectManager objManager = new NativeObjectManager();
protected final EnumSet<Caps> caps = EnumSet.noneOf(Caps.class);
private final EnumMap<Limits, Integer> limits = new EnumMap<Limits, Integer>(Limits.class);
protected final EnumMap<Limits, Integer> limits = new EnumMap<Limits, Integer>(Limits.class);

private FrameBuffer mainFbOverride = null;
private final Statistics statistics = new Statistics();
Expand Down Expand Up @@ -457,7 +457,7 @@ protected void loadCapabilities() {
loadCapabilitiesCommon();
}

private int getInteger(int en) {
protected int getInteger(int en) {
intBuf16.clear();
gl.glGetInteger(en, intBuf16);
return intBuf16.get(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.jme3.renderer.opengl;

import com.jme3.renderer.Caps;
import com.jme3.renderer.Limits;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
Expand Down Expand Up @@ -124,4 +125,67 @@ public void loadCapabilitiesGLSL1Support() throws Exception {
assertTrue(r.caps.contains(Caps.GLSL110));
assertTrue(r.caps.contains(Caps.GLSL100));
}

@Test
public void loadCapabilitiesCommon() {
doReturn(300).when(r).extractVersion(null);

r.initialize();

verify(r).loadExtensions();
assertTrue(r.limits.get(Limits.VertexTextureUnits) == r.getInteger(GL.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS));
assertFalse(r.caps.contains(Caps.VertexTextureFetch));
assertTrue(r.limits.get(Limits.FragmentTextureUnits) == r.getInteger(GL.GL_MAX_TEXTURE_IMAGE_UNITS));
assertTrue(r.limits.get(Limits.VertexUniformVectors) == r.getInteger(GL.GL_MAX_VERTEX_UNIFORM_VECTORS));
assertTrue(r.limits.get(Limits.VertexAttributes) == r.getInteger(GL.GL_MAX_VERTEX_ATTRIBS));
assertTrue(r.limits.get(Limits.TextureSize) == r.getInteger(GL.GL_MAX_TEXTURE_SIZE));
assertTrue(r.limits.get(Limits.CubemapSize) == r.getInteger(GL.GL_MAX_CUBE_MAP_TEXTURE_SIZE));
assertFalse(r.caps.contains(Caps.MeshInstancing));
assertTrue(r.caps.contains(Caps.IntegerIndexBuffer));
assertFalse(r.caps.contains(Caps.TextureBuffer));

// texture format
assertTrue(r.caps.contains(Caps.OpenGL30));
assertTrue(r.caps.contains(Caps.FloatTexture));
assertTrue(r.caps.contains(Caps.DepthTexture));
assertFalse(r.caps.contains(Caps.Rgba8));
assertTrue(r.caps.contains(Caps.PackedDepthStencilBuffer));
assertFalse(r.caps.contains(Caps.FloatColorBuffer));
assertFalse(r.caps.contains(Caps.FloatDepthBuffer));
assertTrue(r.caps.contains(Caps.PackedFloatColorBuffer));
assertTrue(r.caps.contains(Caps.PackedFloatTexture));
assertTrue(r.caps.contains(Caps.SharedExponentTexture));
assertFalse(r.caps.contains(Caps.TextureCompressionS3TC));
assertFalse(r.caps.contains(Caps.TextureCompressionETC2));
assertFalse(r.caps.contains(Caps.TextureCompressionETC1));
assertFalse(r.caps.contains(Caps.TextureCompressionETC1));
// end texture format

assertTrue(r.caps.contains(Caps.VertexBufferArray));
assertTrue(r.caps.contains(Caps.NonPowerOfTwoTextures));
assertFalse(r.caps.contains(Caps.PartialNonPowerOfTwoTextures));
assertTrue(r.caps.contains(Caps.TextureArray));
assertFalse(r.caps.contains(Caps.TextureFilterAnisotropic));
assertFalse(r.limits.containsKey(Limits.TextureAnisotropy));

// big if statement
assertTrue(r.caps.contains(Caps.FrameBuffer));
assertTrue(r.limits.get(Limits.RenderBufferSize) == r.getInteger(GLFbo.GL_MAX_RENDERBUFFER_SIZE_EXT));
assertTrue(r.limits.get(Limits.FrameBufferAttachments) == r.getInteger(GLFbo.GL_MAX_COLOR_ATTACHMENTS_EXT));
assertTrue(r.caps.contains(Caps.FrameBufferBlit));
assertFalse(r.caps.contains(Caps.FrameBufferMultisample));
assertFalse(r.limits.containsKey(Limits.FrameBufferSamples));
assertFalse(r.caps.contains(Caps.TextureMultisample));
assertFalse(r.limits.containsKey(Limits.ColorTextureSamples));
assertFalse(r.limits.containsKey(Limits.DepthTextureSamples));
assertTrue(r.limits.get(Limits.FrameBufferMrtAttachments) == r.getInteger(GLExt.GL_MAX_DRAW_BUFFERS_ARB));
assertFalse(r.caps.contains(Caps.FrameBufferMRT));
// end big if statement

assertFalse(r.caps.contains(Caps.Multisample));
assertTrue(r.caps.contains(Caps.Srgb));
assertFalse(r.caps.contains(Caps.SeamlessCubemap));
assertFalse(r.caps.contains(Caps.CoreProfile));
assertFalse(r.caps.contains(Caps.BinaryShader));
}
}

0 comments on commit 16c474d

Please sign in to comment.