List of usage examples for org.lwjgl.opengl GL11 glEnable
public static void glEnable(@NativeType("GLenum") int target)
From source file:com.ardor3d.scene.state.lwjgl.LwjglOffsetStateUtil.java
License:Open Source License
private static void setOffsetEnabled(final OffsetType type, final boolean typeEnabled, final OffsetStateRecord record) { final int glType = getGLType(type); if (!record.isValid() || typeEnabled != record.enabledOffsets.contains(type)) { if (typeEnabled) { GL11.glEnable(glType); } else {/*from w ww .j ava2s .co m*/ GL11.glDisable(glType); } } }
From source file:com.ardor3d.scene.state.lwjgl.LwjglStencilStateUtil.java
License:Open Source License
private static void setEnabled(final boolean enable, final boolean twoSided, final StencilStateRecord record, final ContextCapabilities caps) { if (record.isValid()) { if (enable && !record.enabled) { GL11.glEnable(GL11.GL_STENCIL_TEST); } else if (!enable && record.enabled) { GL11.glDisable(GL11.GL_STENCIL_TEST); }//from w ww . j a v a 2 s.c o m } else { if (enable) { GL11.glEnable(GL11.GL_STENCIL_TEST); } else { GL11.glDisable(GL11.GL_STENCIL_TEST); } } setTwoSidedEnabled(enable ? twoSided : false, record, caps); record.enabled = enable; }
From source file:com.ardor3d.scene.state.lwjgl.LwjglStencilStateUtil.java
License:Open Source License
private static void setTwoSidedEnabled(final boolean enable, final StencilStateRecord record, final ContextCapabilities caps) { if (caps.isTwoSidedStencilSupported()) { if (record.isValid()) { if (enable && !record.useTwoSided) { GL11.glEnable(EXTStencilTwoSide.GL_STENCIL_TEST_TWO_SIDE_EXT); } else if (!enable && record.useTwoSided) { GL11.glDisable(EXTStencilTwoSide.GL_STENCIL_TEST_TWO_SIDE_EXT); }// ww w .ja v a 2s . com } else { if (enable) { GL11.glEnable(EXTStencilTwoSide.GL_STENCIL_TEST_TWO_SIDE_EXT); } else { GL11.glDisable(EXTStencilTwoSide.GL_STENCIL_TEST_TWO_SIDE_EXT); } } } record.useTwoSided = enable; }
From source file:com.ardor3d.scene.state.lwjgl.LwjglTextureStateUtil.java
License:Open Source License
public static void apply(final TextureState state) { // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); final TextureStateRecord record = (TextureStateRecord) context.getStateRecord(StateType.Texture); context.setCurrentState(StateType.Texture, state); if (state.isEnabled()) { Texture texture;//from w ww. j ava2 s. co m Texture.Type type; TextureUnitRecord unitRecord; TextureRecord texRecord; final int glHint = LwjglTextureUtil.getPerspHint(state.getCorrectionType()); if (!record.isValid() || record.hint != glHint) { // set up correction mode GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, glHint); record.hint = glHint; } // loop through all available texture units... for (int i = 0; i < caps.getNumberOfTotalTextureUnits(); i++) { unitRecord = record.units[i]; // grab a texture for this unit, if available texture = state.getTexture(i); // pull our texture id for this texture, for this context. int textureId = texture != null ? texture.getTextureIdForContext(context.getGlContextRep()) : 0; // check for invalid textures - ones that have no opengl id and // no image data if (texture != null && textureId == 0 && texture.getImage() == null) { texture = null; } // null textures above fixed limit do not need to be disabled // since they are not really part of the pipeline. if (texture == null) { if (i >= caps.getNumberOfFixedTextureUnits()) { continue; } else { // a null texture indicates no texturing at this unit // Disable texturing on this unit if enabled. disableTexturing(unitRecord, record, i, caps); if (i < state._keyCache.length) { state._keyCache[i] = null; } // next texture! continue; } } type = texture.getType(); // disable other texturing types for this unit, if enabled. disableTexturing(unitRecord, record, i, type, caps); // Time to bind the texture, so see if we need to load in image // data for this texture. if (textureId == 0) { // texture not yet loaded. // this will load and bind and set the records... load(texture, i); textureId = texture.getTextureIdForContext(context.getGlContextRep()); if (textureId == 0) { continue; } } else if (texture.isDirty(context.getGlContextRep())) { update(texture, i); textureId = texture.getTextureIdForContext(context.getGlContextRep()); if (textureId == 0) { continue; } } else { // texture already exists in OpenGL, just bind it if needed if (!unitRecord.isValid() || unitRecord.boundTexture != textureId) { checkAndSetUnit(i, record, caps); GL11.glBindTexture(getGLType(type), textureId); if (Constants.stats) { StatCollector.addStat(StatType.STAT_TEXTURE_BINDS, 1); } unitRecord.boundTexture = textureId; } } // Use the Java Integer object for the getTextureRecord call to avoid // boxing/unboxing ints for map lookups. final Integer textureIdInteger = texture.getTextureIdForContextAsInteger(context.getGlContextRep()); // Grab our record for this texture texRecord = record.getTextureRecord(textureIdInteger, texture.getType()); // Set the keyCache value for this unit of this texture state // This is done so during state comparison we don't have to // spend a lot of time pulling out classes and finding field // data. state._keyCache[i] = texture.getTextureKey(); // Some texture things only apply to fixed function pipeline if (i < caps.getNumberOfFixedTextureUnits()) { // Enable 2D texturing on this unit if not enabled. if (!unitRecord.isValid() || !unitRecord.enabled[type.ordinal()]) { checkAndSetUnit(i, record, caps); GL11.glEnable(getGLType(type)); unitRecord.enabled[type.ordinal()] = true; } // Set our blend color, if needed. applyBlendColor(texture, unitRecord, i, record, caps); // Set the texture environment mode if this unit isn't // already set properly applyEnvMode(texture.getApply(), unitRecord, i, record, caps); // If our mode is combine, and we support multitexturing // apply combine settings. if (texture.getApply() == ApplyMode.Combine && caps.isMultitextureSupported() && caps.isEnvCombineSupported()) { applyCombineFactors(texture, unitRecord, i, record, caps); } } // Other items only apply to textures below the frag unit limit if (i < caps.getNumberOfFragmentTextureUnits()) { // texture specific params applyFilter(texture, texRecord, i, record, caps); applyWrap(texture, texRecord, i, record, caps); applyShadow(texture, texRecord, i, record, caps); // Set our border color, if needed. applyBorderColor(texture, texRecord, i, record); // all states have now been applied for a tex record, so we // can safely make it valid if (!texRecord.isValid()) { texRecord.validate(); } } // Other items only apply to textures below the frag tex coord // unit limit if (i < caps.getNumberOfFragmentTexCoordUnits()) { // Now time to play with texture matrices // Determine which transforms to do. applyTextureTransforms(texture, i, record, caps); // Now let's look at automatic texture coordinate // generation. applyTexCoordGeneration(texture, unitRecord, i, record, caps); // Set our texture lod bias, if needed. applyLodBias(texture, unitRecord, i, record, caps); } } } else { // turn off texturing TextureUnitRecord unitRecord; if (caps.isMultitextureSupported()) { for (int i = 0; i < caps.getNumberOfFixedTextureUnits(); i++) { unitRecord = record.units[i]; disableTexturing(unitRecord, record, i, caps); } } else { unitRecord = record.units[0]; disableTexturing(unitRecord, record, 0, caps); } } if (!record.isValid()) { record.validate(); } }
From source file:com.ardor3d.scene.state.lwjgl.LwjglTextureStateUtil.java
License:Open Source License
private static void setTextureGen(final TextureUnitRecord unitRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps, final boolean genS, final boolean genT, final boolean genR, final boolean genQ) { if (!unitRecord.isValid()) { checkAndSetUnit(unit, record, caps); if (genS) { GL11.glEnable(GL11.GL_TEXTURE_GEN_S); } else {//from w w w . j a va 2 s .c om GL11.glDisable(GL11.GL_TEXTURE_GEN_S); } if (genT) { GL11.glEnable(GL11.GL_TEXTURE_GEN_T); } else { GL11.glDisable(GL11.GL_TEXTURE_GEN_T); } if (genR) { GL11.glEnable(GL11.GL_TEXTURE_GEN_R); } else { GL11.glDisable(GL11.GL_TEXTURE_GEN_R); } if (genQ) { GL11.glEnable(GL11.GL_TEXTURE_GEN_Q); } else { GL11.glDisable(GL11.GL_TEXTURE_GEN_Q); } } else { if (genS != unitRecord.textureGenS) { checkAndSetUnit(unit, record, caps); if (genS) { GL11.glEnable(GL11.GL_TEXTURE_GEN_S); } else { GL11.glDisable(GL11.GL_TEXTURE_GEN_S); } } if (genT != unitRecord.textureGenT) { checkAndSetUnit(unit, record, caps); if (genT) { GL11.glEnable(GL11.GL_TEXTURE_GEN_T); } else { GL11.glDisable(GL11.GL_TEXTURE_GEN_T); } } if (genR != unitRecord.textureGenR) { checkAndSetUnit(unit, record, caps); if (genR) { GL11.glEnable(GL11.GL_TEXTURE_GEN_R); } else { GL11.glDisable(GL11.GL_TEXTURE_GEN_R); } } if (genQ != unitRecord.textureGenQ) { checkAndSetUnit(unit, record, caps); if (genQ) { GL11.glEnable(GL11.GL_TEXTURE_GEN_Q); } else { GL11.glDisable(GL11.GL_TEXTURE_GEN_Q); } } } unitRecord.textureGenS = genS; unitRecord.textureGenT = genT; unitRecord.textureGenR = genR; unitRecord.textureGenQ = genQ; }
From source file:com.ardor3d.scene.state.lwjgl.LwjglVertexProgramStateUtil.java
License:Open Source License
/** * Applies this vertex program to the current scene. Checks if the GL_ARB_vertex_program extension is supported * before attempting to enable this program. * //from ww w .ja va 2 s. co m * @see com.ardor3d.renderer.state.RenderState#apply() */ public static void apply(final VertexProgramState state) { final RenderContext context = ContextManager.getCurrentContext(); if (context.getCapabilities().isVertexProgramSupported()) { // ask for the current state record final VertexProgramStateRecord record = (VertexProgramStateRecord) context .getStateRecord(StateType.VertexProgram); context.setCurrentState(StateType.VertexProgram, state); if (!record.isValid() || record.getReference() != state) { record.setReference(state); if (state.isEnabled()) { // Vertex program not yet loaded if (state._getProgramID() == -1) { if (state.getProgramAsBuffer() != null) { final int id = create(state.getProgramAsBuffer()); state._setProgramID(id); } else { return; } } GL11.glEnable(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB); ARBProgram.glBindProgramARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, state._getProgramID()); // load environmental parameters... for (int i = 0; i < VertexProgramState._getEnvParameters().length; i++) { if (VertexProgramState._getEnvParameters()[i] != null) { ARBProgram.glProgramEnvParameter4fARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, i, VertexProgramState._getEnvParameters()[i][0], VertexProgramState._getEnvParameters()[i][1], VertexProgramState._getEnvParameters()[i][2], VertexProgramState._getEnvParameters()[i][3]); } } // load local parameters... if (state.isUsingParameters()) { // no parameters are used for (int i = 0; i < state._getParameters().length; i++) { if (state._getParameters()[i] != null) { ARBProgram.glProgramLocalParameter4fARB(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB, i, state._getParameters()[i][0], state._getParameters()[i][1], state._getParameters()[i][2], state._getParameters()[i][3]); } } } } else { GL11.glDisable(ARBVertexProgram.GL_VERTEX_PROGRAM_ARB); } } if (!record.isValid()) { record.validate(); } } }
From source file:com.ardor3d.scene.state.lwjgl.LwjglZBufferStateUtil.java
License:Open Source License
private static void enableDepthTest(final boolean enable, final ZBufferStateRecord record) { if (enable && (!record.depthTest || !record.isValid())) { GL11.glEnable(GL11.GL_DEPTH_TEST); record.depthTest = true;/*from w w w . j a va2s . c o m*/ } else if (!enable && (record.depthTest || !record.isValid())) { GL11.glDisable(GL11.GL_DEPTH_TEST); record.depthTest = false; } }
From source file:com.ardor3d.scene.state.lwjgl.util.LwjglRendererUtil.java
License:Open Source License
public static void setClippingEnabled(final RendererRecord rendRecord, final boolean enabled) { if (enabled && (!rendRecord.isClippingTestValid() || !rendRecord.isClippingTestEnabled())) { GL11.glEnable(GL11.GL_SCISSOR_TEST); rendRecord.setClippingTestEnabled(true); } else if (!enabled && (!rendRecord.isClippingTestValid() || rendRecord.isClippingTestEnabled())) { GL11.glDisable(GL11.GL_SCISSOR_TEST); rendRecord.setClippingTestEnabled(false); }//from w w w . j av a2 s .c om rendRecord.setClippingTestValid(true); }
From source file:com.auroraengine.opengl.GLWindow.java
License:Open Source License
/** * Currently serves as a simple test for implementing some GL settings. * * @throws GLException/*from www . j av a 2 s . c om*/ */ public static void updateGL() throws GLException { GL11.glAlphaFunc(GL11.GL_GEQUAL, 0.5f); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_DEPTH_TEST); }
From source file:com.badlogic.gdx.backends.jglfw.JglfwGL20.java
License:Apache License
public void glEnable(int cap) { GL11.glEnable(cap); }