/** * Check if we are keeping the size limits in terms of attribute locations on the card. */ public void checkAttributeSizeLimits() { final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); if (_shaderAttributes.size() > caps.getMaxGLSLVertexAttributes()) { logger.severe("Too many shader attributes(standard+defined): " + _shaderAttributes.size() + " maximum: " + caps.getMaxGLSLVertexAttributes()); } }
public static TextureRenderer fetch(final int width, final int height, final Renderer renderer) { for (final Iterator<TextureRenderer> it = INSTANCE.renderers.iterator(); it.hasNext();) { final TextureRenderer texRend = it.next(); if (texRend.getWidth() == width && texRend.getHeight() == height) { it.remove(); return texRend; } } // none found, make one return TextureRendererFactory.INSTANCE.createTextureRenderer(width, height, renderer, ContextManager .getCurrentContext().getCapabilities()); }
@Override public Lwjgl3TextureRenderer createTextureRenderer(final int width, final int height, final int depthBits, final int samples) { return new Lwjgl3TextureRenderer(width, height, depthBits, samples, this, ContextManager.getCurrentContext().getCapabilities()); } }
private void init(final Renderer renderer) { _tRenderer = TextureRendererFactory.INSTANCE.createTextureRenderer(_twidth, _theight, _depth, _samples, renderer, ContextManager.getCurrentContext().getCapabilities()); _tRenderer.setBackgroundColor(new ColorRGBA(0, 0, 0, 0)); resetTexture(); }
@Override public void setupPointParameters(final float pointSize, final boolean antialiased, final boolean isSprite, final boolean useDistanceAttenuation, final FloatBuffer attenuationCoefficients, final float minPointSize, final float maxPointSize) { final RenderContext context = ContextManager.getCurrentContext(); // TODO: make a record for point states GL11.glPointSize(pointSize); if (isSprite && context.getCapabilities().isPointSpritesSupported()) { GL11.glEnable(ARBPointSprite.GL_POINT_SPRITE_ARB); GL11.glTexEnvi(ARBPointSprite.GL_POINT_SPRITE_ARB, ARBPointSprite.GL_COORD_REPLACE_ARB, GL11.GL_TRUE); } if (useDistanceAttenuation && context.getCapabilities().isPointParametersSupported()) { ARBPointParameters.glPointParameterARB(ARBPointParameters.GL_POINT_DISTANCE_ATTENUATION_ARB, attenuationCoefficients); ARBPointParameters.glPointParameterfARB(ARBPointParameters.GL_POINT_SIZE_MIN_ARB, minPointSize); ARBPointParameters.glPointParameterfARB(ARBPointParameters.GL_POINT_SIZE_MAX_ARB, maxPointSize); } if (antialiased) { GL11.glEnable(GL11.GL_POINT_SMOOTH); GL11.glHint(GL11.GL_POINT_SMOOTH_HINT, GL11.GL_NICEST); } }
/** * Applies all instancing info to the mesh and returns if the current render call is allowed to continue * * @param mesh * @param renderer * @param shader * @return continue rendering or skip rendering all together */ public boolean apply(final Mesh mesh, final Renderer renderer, final GLSLShaderObjectsState shader) { final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); if (!caps.isGeometryInstancingSupported()) { throw new Ardor3dException("Geometry instancing not supported for current graphics configuration"); } if (_meshesToDraw <= 0) { // reset for next draw call _primCount = -1; shader.setUniform("nrOfInstances", -1); _visibleMeshes.clear(); return false; } shader.setUniform("transforms", fillTransformBuffer(), 4); shader.setUniform("nrOfInstances", getPrimitiveCount()); return true; }
public static void apply(final ClipState state) { // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); final ClipStateRecord record = (ClipStateRecord) context.getStateRecord(StateType.Clip); context.setCurrentState(StateType.Clip, state); final ContextCapabilities caps = context.getCapabilities(); final int max = Math.min(ClipState.MAX_CLIP_PLANES, caps.getMaxUserClipPlanes()); if (state.isEnabled()) { for (int i = 0; i < max; i++) { enableClipPlane(i, state.getPlaneEnabled(i), state, record); } } else { for (int i = 0; i < max; i++) { enableClipPlane(i, false, state, record); } } if (!record.isValid()) { record.validate(); } }
public static void apply(final JoglRenderer renderer, final ClipState state) { // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); final ClipStateRecord record = (ClipStateRecord) context.getStateRecord(StateType.Clip); context.setCurrentState(StateType.Clip, state); final ContextCapabilities caps = context.getCapabilities(); final int max = Math.min(ClipState.MAX_CLIP_PLANES, caps.getMaxUserClipPlanes()); if (state.isEnabled()) { for (int i = 0; i < max; i++) { enableClipPlane(i, state.getPlaneEnabled(i), state, record); } } else { for (int i = 0; i < max; i++) { enableClipPlane(i, false, state, record); } } if (!record.isValid()) { record.validate(); } }
public void setupFogDataVBO(final FloatBufferData data) { final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); if (!caps.isFogCoordinatesSupported()) { return; } final RendererRecord rendRecord = context.getRendererRecord(); final int vboID = setupVBO(data, context); if (vboID != 0) { GL11.glEnableClientState(EXTFogCoord.GL_FOG_COORDINATE_ARRAY_EXT); LwjglRendererUtil.setBoundVBO(rendRecord, vboID); EXTFogCoord.glFogCoordPointerEXT(GL11.GL_FLOAT, 0, 0); } else { GL11.glDisableClientState(EXTFogCoord.GL_FOG_COORDINATE_ARRAY_EXT); } }
/** * Useful for external lwjgl based classes that need to safely set the current texture. */ public static void doTextureBind(final Texture texture, final int unit, final boolean invalidateState) { // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); final TextureStateRecord record = (TextureStateRecord) context.getStateRecord(StateType.Texture); if (invalidateState) { // Set this to null because no current state really matches anymore context.setCurrentState(StateType.Texture, null); } checkAndSetUnit(unit, record, caps); final int id = texture.getTextureIdForContext(context); GL11C.glBindTexture(getGLType(texture.getType()), id); if (Constants.stats) { StatCollector.addStat(StatType.STAT_TEXTURE_BINDS, 1); } if (record != null) { record.units[unit].boundTexture = id; } }
LwjglTextureStateUtil.applyFilter(tex, texRecord, 0, record, context.getCapabilities()); LwjglTextureStateUtil.applyWrap(tex, texRecord, 0, record, context.getCapabilities());
/** * Useful for external lwjgl based classes that need to safely set the current texture. */ public static void doTextureBind(final Texture texture, final int unit, final boolean invalidateState) { // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); final TextureStateRecord record = (TextureStateRecord) context.getStateRecord(StateType.Texture); if (invalidateState) { // Set this to null because no current state really matches anymore context.setCurrentState(StateType.Texture, null); } checkAndSetUnit(unit, record, caps); final int id = texture.getTextureIdForContext(context.getGlContextRep()); GL11.glBindTexture(getGLType(texture.getType()), id); if (Constants.stats) { StatCollector.addStat(StatType.STAT_TEXTURE_BINDS, 1); } if (record != null) { record.units[unit].boundTexture = id; } }
/** * Useful for external jogl based classes that need to safely set the current texture. */ public static void doTextureBind(final Texture texture, final int unit, final boolean invalidateState) { final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); final TextureStateRecord record = (TextureStateRecord) context.getStateRecord(StateType.Texture); if (invalidateState) { // Set this to null because no current state really matches anymore context.setCurrentState(StateType.Texture, null); } checkAndSetUnit(unit, record, caps); final int id = texture.getTextureIdForContext(context.getGlContextRep()); gl.glBindTexture(getGLType(texture.getType()), id); if (Constants.stats) { StatCollector.addStat(StatType.STAT_TEXTURE_BINDS, 1); } if (record != null) { record.units[unit].boundTexture = id; } }
@Override public void setupPointParameters(final float pointSize, final boolean antialiased, final boolean isSprite, final boolean useDistanceAttenuation, final FloatBuffer attenuationCoefficients, final float minPointSize, final float maxPointSize) { final RenderContext context = ContextManager.getCurrentContext(); final GL gl = GLContext.getCurrentGL(); // TODO: make this into a pointrecord call if (gl.isGL2GL3()) { gl.getGL2GL3().glPointSize(pointSize); } if (antialiased) { if (gl.isGL2ES1()) { gl.glEnable(GL2ES1.GL_POINT_SMOOTH); gl.glHint(GL2ES1.GL_POINT_SMOOTH_HINT, GL.GL_NICEST); } } if (isSprite && context.getCapabilities().isPointSpritesSupported()) { if (gl.isGL2ES1()) { gl.glEnable(GL2ES1.GL_POINT_SPRITE); gl.getGL2ES1().glTexEnvi(GL2ES1.GL_POINT_SPRITE, GL2ES1.GL_COORD_REPLACE, GL.GL_TRUE); } } if (useDistanceAttenuation && context.getCapabilities().isPointParametersSupported()) { if (gl.isGL2GL3()) { gl.getGL2GL3().glPointParameterfv(GL2ES1.GL_POINT_DISTANCE_ATTENUATION, attenuationCoefficients); gl.getGL2GL3().glPointParameterf(GL2ES1.GL_POINT_SIZE_MIN, minPointSize); gl.getGL2GL3().glPointParameterf(GL2ES1.GL_POINT_SIZE_MAX, maxPointSize); } } }
private void updateShaderVariables() { if (_pssmShader != null && ContextManager.getCurrentContext().getCapabilities().isGLSLSupported()) { final float split1 = (float) _pssmCam.getSplitDistances()[1]; final float split2 = (float) (_pssmCam.getSplitDistances().length > 2 ? _pssmCam.getSplitDistances()[2]
final ContextCapabilities caps = ContextManager.getCurrentContext().getCapabilities();
public void setupFogDataVBO(final FloatBufferData data) { final GL gl = GLContext.getCurrentGL(); final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); if (!caps.isFogCoordinatesSupported()) { return; } final RendererRecord rendRecord = context.getRendererRecord(); final int vboID = setupVBO(data, context); if (vboID != 0) { if (gl.isGL2GL3()) { gl.getGL2GL3().glEnableClientState(GL2.GL_FOG_COORDINATE_ARRAY); } JoglRendererUtil.setBoundVBO(rendRecord, vboID); if (gl.isGL2()) { gl.getGL2().glFogCoordPointer(GL.GL_FLOAT, 0, 0); } } else { if (gl.isGL2GL3()) { gl.getGL2GL3().glDisableClientState(GL2.GL_FOG_COORDINATE_ARRAY); } } }
public static void apply(final BlendState state) { // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); final BlendStateRecord record = (BlendStateRecord) context.getStateRecord(StateType.Blend); final ContextCapabilities caps = context.getCapabilities(); context.setCurrentState(StateType.Blend, state); if (state.isEnabled()) { applyBlendEquations(state.isBlendEnabled(), state, record, caps); applyBlendColor(state.isBlendEnabled(), state, record, caps); applyBlendFunctions(state.isBlendEnabled(), state, record, caps); applyTest(state.isTestEnabled(), state, record); applyAlphaCoverage(state.isSampleAlphaToCoverageEnabled(), state.isSampleAlphaToOneEnabled(), record, caps); applySampleCoverage(state.isSampleCoverageEnabled(), state, record, caps); } else { // disable blend applyBlendEquations(false, state, record, caps); // disable alpha test applyTest(false, state, record); // disable sample coverage applyAlphaCoverage(false, false, record, caps); applySampleCoverage(false, state, record, caps); } if (!record.isValid()) { record.validate(); } }
final ContextCapabilities caps = context.getCapabilities(); context.setCurrentState(StateType.Blend, state);
final ContextCapabilities caps = context.getCapabilities(); context.setCurrentState(StateType.Blend, state);