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(); } }
/** if enabled, set the states for this pass and then render. */ public final void renderPass(final Renderer r) { if (!_enabled) { return; } _context = ContextManager.getCurrentContext(); _context.pushEnforcedStates(); _context.enforceStates(_passStates); doRender(r); _context.popEnforcedStates(); _context = null; }
_context.pushEnforcedStates(); _context.enforceState(_shadowTextureState); _context.enforceState(_discardShadowFragments); if (_pssmShader != null && _context.getCapabilities().isGLSLSupported()) { GLSLShaderObjectsState currentShader = _drawShaderDebug ? _pssmDebugShader : _pssmShader; if (_drawShaderDebug) { currentShader = _mainShader; _context.enforceState(currentShader); _context.popEnforcedStates();
/** * Applies all currently set renderstates to the supplied context * * @param context */ public void applyPassNodeStates(final RenderContext context) { context.pushEnforcedStates(); context.enforceStates(_passStates); }
@Override public void doRender(final Renderer renderer) { // if there's nothing to do if (_spatials.size() == 0) { return; } // normal render _context.enforceState(_frontCull); super.doRender(renderer); // set up the render states // CullState.setFlippedCulling(true); _context.enforceState(_backCull); _context.enforceState(_wireframeState); _context.enforceState(_noLights); _context.enforceState(_noTexture); _context.enforceState(_blendState); // this will draw the wireframe super.doRender(renderer); // revert state changes // CullState.setFlippedCulling(false); _context.clearEnforcedStates(); }
/** * 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()); } }
final ContextCapabilities caps = context.getCapabilities(); final TextureStateRecord record = (TextureStateRecord) context.getStateRecord(StateType.Texture); TextureManager.addToCache(texture); } else { final int textureId = cached.getTextureIdForContext(context.getGlContextRep()); if (textureId != 0) { doTextureBind(cached, unit, false); texture.setTextureIdForContext(context.getGlContextRep(), textureId);
final int maxDrawBuffers = ContextManager.getCurrentContext().getCapabilities().getMaxFBOColorAttachments(); ContextManager.getCurrentContext().pushFBOTextureRenderer(this); ContextManager.getCurrentContext().popFBOTextureRenderer(); ContextManager.getCurrentContext().pushFBOTextureRenderer(this); if (tex.getType() == Type.TwoDimensional) { gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0 + colorsAdded, GL.GL_TEXTURE_2D, tex.getTextureIdForContext(context.getGlContextRep()), 0); } else if (tex.getType() == Type.CubeMap) { gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0 + colorsAdded, JoglTextureStateUtil.getGLCubeMapFace(((TextureCubeMap) tex).getCurrentRTTFace()), tex.getTextureIdForContext(context.getGlContextRep()), 0); } else { throw new IllegalArgumentException("Invalid texture type: " + tex.getType()); tex.getTextureIdForContext(context.getGlContextRep()), 0); } else if (tex.getType() == Type.CubeMap) { gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, JoglTextureStateUtil.getGLCubeMapFace(((TextureCubeMap) tex).getCurrentRTTFace()), tex.getTextureIdForContext(context.getGlContextRep()), 0); } else { throw new IllegalArgumentException("Invalid texture type: " + tex.getType()); ContextManager.getCurrentContext().popFBOTextureRenderer();
final RendererRecord record = context.getRendererRecord(); _backgroundColor.getAlpha()); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, _fboID); ContextManager.getCurrentContext().pushEnforcedStates(); ContextManager.getCurrentContext().clearEnforcedStates(); ContextManager.getCurrentContext().enforceStates(_enforcedStates);
public void setupTextureData(final List<FloatBufferData> textureCoords) { final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); final RendererRecord rendRecord = context.getRendererRecord(); final TextureState ts = (TextureState) context.getCurrentState(RenderState.StateType.Texture); int enabledTextures = rendRecord.getEnabledTextures(); final boolean valid = rendRecord.isTexturesValid();
interleaved.getBuffer().put(bufferSize); final RendererRecord rendRecord = context.getRendererRecord(); final ContextCapabilities caps = context.getCapabilities(); interleaved.setVBOID(context.getGlContextRep(), vboID); final TextureState ts = (TextureState) context.getCurrentState(RenderState.StateType.Texture); if (ts != null) { for (int i = 0; i <= ts.getMaxTextureIndexUsed() && i < caps.getNumberOfFragmentTexCoordUnits(); i++) {
public void render(final Spatial toDraw, final Texture tex, final int clear) { try { ContextManager.getCurrentContext().pushFBOTextureRenderer(this); setupForSingleTexDraw(tex); if (_samples > 0 && _supportsMultisample) { setMSFBO(); } switchCameraIn(clear); doDraw(toDraw); switchCameraOut(); if (_samples > 0 && _supportsMultisample) { blitMSFBO(); } takedownForSingleTexDraw(tex); ContextManager.getCurrentContext().popFBOTextureRenderer(); } catch (final Exception e) { logger.logp(Level.SEVERE, this.getClass().toString(), "render(Spatial, Texture, boolean)", "Exception", e); } }
_context.pushEnforcedStates(); _context.enforceState(_shadowTextureState); _context.enforceState(_discardShadowFragments); _context.enforceState(_shadowPassOffsetState); _context.popEnforcedStates();
final RendererRecord record = context.getRendererRecord(); ContextManager.getCurrentContext().pushEnforcedStates(); ContextManager.getCurrentContext().clearEnforcedStates(); ContextManager.getCurrentContext().enforceStates(_enforcedStates); ContextManager.getCurrentContext().pushEnforcedMaterial(); ContextManager.getCurrentContext().enforceMaterial(_enforcedMaterial);
/** * 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; } }
final ContextCapabilities caps = context.getCapabilities(); if (caps.isVBOSupported() && !useVBO) { renderer.unbindVBO(); final ShaderObjectsStateRecord record = (ShaderObjectsStateRecord) context.getStateRecord(StateType.GLSLShader);
protected <T> void render(final T toRender, final Consumer<T> consumer, final List<Texture> texs, final int clear) { final int maxDrawBuffers = ContextManager.getCurrentContext().getCapabilities().getMaxFBOColorAttachments(); ContextManager.getCurrentContext().pushFBOTextureRenderer(this); ContextManager.getCurrentContext().popFBOTextureRenderer(); ContextManager.getCurrentContext().pushFBOTextureRenderer(this); ContextManager.getCurrentContext().popFBOTextureRenderer();
RenderState setState = context.hasEnforcedStates() ? context.getEnforcedState(StateType.Cull) : null; if (setState == null) { final RenderState oldCullState = context.getEnforcedState(StateType.Cull); final RenderState oldZState = context.getEnforcedState(StateType.ZBuffer); context.enforceState(_tranparentCull); context.enforceState(_transparentZBuff); context.clearEnforcedState(StateType.ZBuffer); if (oldZState != null) { context.enforceState(oldZState); context.enforceState(oldCullState); } else { context.clearEnforcedState(StateType.Cull);
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); } }
public void render(final Renderer renderer, final Camera camera, final List<Spatial> spatials, final Spatial spatial, final EnumMap<StateType, RenderState> enforcedStates) { if (camera != Camera.getCurrentCamera()) { camera.update(); } camera.apply(renderer); final RenderContext context = ContextManager.getCurrentContext(); context.enforceStates(enforcedStates); if (spatial != null) { spatial.onDraw(renderer); } else { for (final Spatial spat : spatials) { spat.onDraw(renderer); } } renderer.renderBuckets(); context.clearEnforcedStates(); }