@Override protected void prepare_glState( GL gl ) { gl.glEnable( GL2.GL_TEXTURE_2D ); gl.glDisable( GL2.GL_BLEND ); } };
private void oldInit( GL gl ) { LOG.debug( "Initializing opengl context settings." ); gl.glShadeModel( GL.GL_SMOOTH ); gl.glPolygonMode( GL.GL_FRONT_AND_BACK, GL.GL_FILL ); gl.glLightModelf( GL.GL_LIGHT_MODEL_LOCAL_VIEWER, GL.GL_TRUE ); gl.glEnable( GL.GL_LIGHTING ); gl.glEnable( GL.GL_LIGHT0 ); gl.glDepthFunc( GL.GL_LEQUAL ); gl.glEnable( GL.GL_DEPTH_TEST ); // enable vertex arrays gl.glEnableClientState( GL.GL_VERTEX_ARRAY ); gl.glEnableClientState( GL.GL_NORMAL_ARRAY ); // LOG.debug( "Created shader program id: " + shaderProgramId ); createCompositingTextureShaderPrograms( gl ); }
@Override public void init( GLAutoDrawable drawable ) { LOG.trace( "init( GLAutoDrawable ) called" ); GL gl = drawable.getGL(); gl.glEnable( GL.GL_BLEND ); // enable color and texture blending gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA ); }
@Override protected void enableArrays( RenderContext glRenderContext, DirectGeometryBuffer geomBuffer ) { super.enableArrays( glRenderContext, geomBuffer ); if ( texturePosition >= 0 && textureBuffer == null && geomBuffer != null ) { textureBuffer = geomBuffer.getTextureCoordinates( texturePosition, textureOrdinatesCount ); if ( textureBuffer == null ) { texturePosition = -1; } } if ( textureBuffer != null ) { glRenderContext.getContext().glEnable( GL.GL_TEXTURE_2D ); TexturePool.loadTexture( glRenderContext, texture ); glRenderContext.getContext().glEnableClientState( GL.GL_TEXTURE_COORD_ARRAY ); glRenderContext.getContext().glTexCoordPointer( 2, GL.GL_FLOAT, 0, textureBuffer ); } }
private static void enableFog(final boolean enable, final FogStateRecord record) { final GL gl = GLContext.getCurrentGL(); if (record.isValid()) { if (enable && !record.enabled) { gl.glEnable(GL2ES1.GL_FOG); record.enabled = true; } else if (!enable && record.enabled) { gl.glDisable(GL2ES1.GL_FOG); record.enabled = false; } } else { if (enable) { gl.glEnable(GL2ES1.GL_FOG); } else { gl.glDisable(GL2ES1.GL_FOG); } record.enabled = enable; } }
private static void setOffsetEnabled(final OffsetType type, final boolean typeEnabled, final OffsetStateRecord record) { final GL gl = GLContext.getCurrentGL(); final int glType = getGLType(type); if (!record.isValid() || typeEnabled != record.enabledOffsets.contains(type)) { if (typeEnabled) { gl.glEnable(glType); } else { gl.glDisable(glType); } } }
private static void setCullEnabled(final boolean enable, final CullState state, final CullStateRecord record) { final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || record.enabled != enable) { if (enable) { gl.glEnable(GL.GL_CULL_FACE); } else { gl.glDisable(GL.GL_CULL_FACE); } record.enabled = enable; } }
private final void setSynchronousImpl() { if(isExtensionARB()) { if(synchronous) { ctx.getGL().glEnable(GL2ES2.GL_DEBUG_OUTPUT_SYNCHRONOUS); } else { ctx.getGL().glDisable(GL2ES2.GL_DEBUG_OUTPUT_SYNCHRONOUS); } if(DEBUG) { System.err.println("GLDebugMessageHandler: synchronous "+synchronous); } } }
private static void setEnabled(final boolean enable, final boolean twoSided, final StencilStateRecord record, final ContextCapabilities caps) { final GL gl = GLContext.getCurrentGL(); if (record.isValid()) { if (enable && !record.enabled) { gl.glEnable(GL.GL_STENCIL_TEST); } else if (!enable && record.enabled) { gl.glDisable(GL.GL_STENCIL_TEST); } } else { if (enable) { gl.glEnable(GL.GL_STENCIL_TEST); } else { gl.glDisable(GL.GL_STENCIL_TEST); } } setTwoSidedEnabled(enable ? twoSided : false, record, caps); record.enabled = enable; }
@Override public void init(GLAutoDrawable drawable) { //TODO Debug und Trace GL einbauen GL gl = gc.getGL(); logger.info("INIT GL IS: " + gl.getClass().getName()); gl.glEnable(GL.GL_DEPTH_TEST); gl.glDepthFunc(GL.GL_LEQUAL); // Enable VSync gl.setSwapInterval(1); // Setup the drawing area and shading mode gl.glClearColor(0.0f, 1.0f, 1.0f, 0f); meminfo = new MemoryInfoProvider(gc).get(); }
private static void setTwoSidedEnabled(final boolean enable, final StencilStateRecord record, final ContextCapabilities caps) { final GL gl = GLContext.getCurrentGL(); if (caps.isTwoSidedStencilSupported()) { if (record.isValid()) { if (enable && !record.useTwoSided) { gl.glEnable(GL2.GL_STENCIL_TEST_TWO_SIDE_EXT); } else if (!enable && record.useTwoSided) { gl.glDisable(GL2.GL_STENCIL_TEST_TWO_SIDE_EXT); } } else { if (enable) { gl.glEnable(GL2.GL_STENCIL_TEST_TWO_SIDE_EXT); } else { gl.glDisable(GL2.GL_STENCIL_TEST_TWO_SIDE_EXT); } } } record.useTwoSided = enable; }
@Override public void run(final GL gl, final RegionRenderer renderer) { if( renderer.rs.isHintMaskSet(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED) ) { gl.glDepthMask(false); // gl.glDisable(GL.GL_DEPTH_TEST); // gl.glDepthFunc(GL.GL_ALWAYS); } gl.glEnable(GL.GL_BLEND); gl.glBlendEquation(GL.GL_FUNC_ADD); // default renderer.rs.setHintMask(RenderState.BITHINT_BLENDING_ENABLED); } };
private static void enableDepthTest(final boolean enable, final ZBufferStateRecord record) { final GL gl = GLContext.getCurrentGL(); if (enable && (!record.depthTest || !record.isValid())) { gl.glEnable(GL.GL_DEPTH_TEST); record.depthTest = true; } else if (!enable && (record.depthTest || !record.isValid())) { gl.glDisable(GL.GL_DEPTH_TEST); record.depthTest = false; } }
private static void setSingleLightEnabled(final boolean enable, final int index, final LightStateRecord record, final LightRecord lr) { final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || lr.isEnabled() != enable) { if (enable) { gl.glEnable(GLLightingFunc.GL_LIGHT0 + index); } else { gl.glDisable(GLLightingFunc.GL_LIGHT0 + index); } lr.setEnabled(enable); } }
private static void setLightEnabled(final boolean enable, final LightStateRecord record) { final GL gl = GLContext.getCurrentGL(); if (!record.isValid() || record.isEnabled() != enable) { if (enable) { gl.glEnable(GLLightingFunc.GL_LIGHTING); } else { gl.glDisable(GLLightingFunc.GL_LIGHTING); } record.setEnabled(enable); } }
@Override public boolean bind( DrawContext dc ) { GL gl = dc.getGL( ); gl.glBindTexture( GL2.GL_TEXTURE_2D, textureHandle ); // these settings make fine line drawing against a transparent background appear much more natural // but can make other rendering look too jagged/crisp gl.glTexParameterf( GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR ); gl.glTexParameterf( GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR ); gl.glTexParameterf( GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_CLAMP_TO_EDGE ); gl.glTexParameterf( GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_CLAMP_TO_EDGE ); gl.glBlendFuncSeparate( GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA, GL2.GL_ONE, GL2.GL_ONE_MINUS_SRC_ALPHA ); gl.glEnable( GL2.GL_BLEND ); //GlimpseColor.glColor( gl, GlimpseColor.getWhite( 0.5f ) ); return true; }
public static void setClippingEnabled(final RendererRecord rendRecord, final boolean enabled) { final GL gl = GLContext.getCurrentGL(); if (enabled && (!rendRecord.isClippingTestValid() || !rendRecord.isClippingTestEnabled())) { gl.glEnable(GL.GL_SCISSOR_TEST); rendRecord.setClippingTestEnabled(true); } else if (!enabled && (!rendRecord.isClippingTestValid() || rendRecord.isClippingTestEnabled())) { gl.glDisable(GL.GL_SCISSOR_TEST); rendRecord.setClippingTestEnabled(false); } rendRecord.setClippingTestValid(true); } }
private static void applyColorMaterial(final ColorMaterial colorMaterial, final MaterialFace face, final MaterialStateRecord record) { if (!record.isValid() || face != record.colorMaterialFace || colorMaterial != record.colorMaterial) { final GL gl = GLContext.getCurrentGL(); if (colorMaterial == ColorMaterial.None) { gl.glDisable(GLLightingFunc.GL_COLOR_MATERIAL); } else { final int glMat = getGLColorMaterial(colorMaterial); final int glFace = getGLMaterialFace(face); gl.getGL2().glColorMaterial(glFace, glMat); gl.glEnable(GLLightingFunc.GL_COLOR_MATERIAL); record.resetColorsForCM(face, colorMaterial); } record.colorMaterial = colorMaterial; record.colorMaterialFace = face; } }
private void renderCopyright() { Texture copyImage = TexturePool.getTexture( glRenderContext, copyrightID ); if ( copyImage != null ) { float tH = copyImage.getHeight(); float tW = copyImage.getWidth(); float quadWidth = tW; float quadHeight = tH; glRenderContext.getContext().glEnable( GL.GL_ALPHA_TEST ); glRenderContext.getContext().glAlphaFunc( GL.GL_GREATER, 0.4f ); draw2D( 0, 0, quadWidth, quadHeight, copyImage, true ); glRenderContext.getContext().glDisable( GL.GL_ALPHA_TEST ); glRenderContext.getContext().glAlphaFunc( GL.GL_ALWAYS, 1 ); } }
@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); } } }