public void applyInternalTransform(DrawContext dc) { if (dc == null) { String message = Logging.getMessage("nullValue.DrawContextIsNull"); Logging.logger().severe(message); throw new IllegalStateException(message); } Texture texture = this.getTexture(dc); if (texture == null) { texture = this.requestTexture(dc); } if (texture == null) { return; } if (texture.getMustFlipVertically()) { GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility. gl.glMatrixMode(GL2.GL_TEXTURE); gl.glLoadIdentity(); gl.glScaled(1, -1, 1); gl.glTranslated(0, -1, 0); } }
public void applyInternalTransform(DrawContext dc) { if (dc == null) { String message = Logging.getMessage("nullValue.DrawContextIsNull"); Logging.logger().severe(message); throw new IllegalStateException(message); } // Use the tile's texture if available. Texture t = this.getTextureFromCache(dc); if (t == null) { t = this.initializeTexture(dc, this.imageSource); } if (t != null) { if (t.getMustFlipVertically()) { GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility. gl.glMatrixMode(GL2.GL_TEXTURE); gl.glLoadIdentity(); gl.glScaled(1, -1, 1); gl.glTranslated(0, -1, 0); } } }
protected void initializeFrame(DrawContext dc) { if (dc.getGLContext() == null) { String message = Logging.getMessage("BasicSceneController.GLContextNullStartRedisplay"); Logging.logger().severe(message); throw new IllegalStateException(message); } GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility. gl.glPushAttrib(GL2.GL_VIEWPORT_BIT | GL2.GL_ENABLE_BIT | GL2.GL_TRANSFORM_BIT); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glEnable(GL.GL_DEPTH_TEST); }
protected void applyStandardLightDirection(GL2 gl, int light, Vec4 direction) { // Setup the light as a directional light coming from the viewpoint. This requires two state changes // (a) Set the light position as direction x, y, z, and set the w-component to 0, which tells OpenGL this is // a directional light. // (b) Invoke the light position call with the identity matrix on the modelview stack. Since the position // is transformed by the Vec4 vec = direction.normalize3(); float[] parameters = new float[4]; parameters[0] = (float)vec.x; parameters[1] = (float)vec.y; parameters[2] = (float)vec.z; parameters[3] = 0.0f; gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glLightfv(light, GL2.GL_POSITION, parameters, 0); gl.glPopMatrix(); }