private void disableTexture(GL2 gl, Texture texture) { //TODO make it better if (texture != null) { if (drawTexture) { texture.disable(gl); } texture = null; } }
@Override protected void end(Texture texture) { shader.use(gl, false); texture.disable(gl); } }
@Override protected void end(Texture texture) { shader.use(gl, false); texture.disable(gl); } }
@Override protected void end(Texture texture) { gl.glPopMatrix(); texture.disable(gl); Color color = g2d.getColor(); if(color!=null){ g2d.getColorHelper().setColorRespectComposite(color); }else{ System.err.println("GL2ImageDrawer - NULL Color"); } }
texYantra.disable(gl2);
@Override protected void end(Texture texture) { if (savedTransform != null) { g2d.setTransform(savedTransform); } texture.disable(gl); g2d.getColorHelper().setColorRespectComposite(g2d.getColor()); }
gl.glDisableClientState (GL2.GL_VERTEX_ARRAY); if (texture != null ) { texture.disable(gl);
private void endRendering(final boolean ortho) { final GL2 gl = GLContext.getCurrentGL().getGL2(); final Texture texture = getTexture(); texture.disable(gl); if (ortho) { gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glPopMatrix(); gl.glMatrixMode(GL.GL_TEXTURE); gl.glPopMatrix(); } gl.glPopAttrib(); }
@Override public void draw(Graphics3D g) { AWTGraphics3D graphics = (AWTGraphics3D) g; GL2 gl = graphics.getGL2(); texture.enable(gl); texture.bind(gl); gl.glColor3f(1, 1, 1); gl.glBegin(GL2.GL_QUADS); //Draw skybox based on center drawUpperFace(gl, x, y, z, size); drawFrontFace(gl, x, y, z, size); drawRightFace(gl, x, y, z, size); drawLeftFace(gl, x, y, z, size); drawLowerFace(gl, x, y, z, size); drawBackFace(gl, x, y, z, size); gl.glEnd(); texture.disable(gl); }
public void drawTile(double x, double y, double tileSize, Texture texture) { texture.enable(gl); texture.bind(gl); gl.glBegin(GL2.GL_QUADS); //(0,0) gl.glTexCoord2d(0, 0); gl.glVertex3d(x*tileSize, 0, y*tileSize); //(1,0) gl.glTexCoord2d(1, 0); gl.glVertex3d(x*tileSize+tileSize, 0, y*tileSize); //(1,1) gl.glTexCoord2d(1, 1); gl.glVertex3d(x*tileSize+tileSize, 0, y*tileSize+tileSize); //(0,1) gl.glTexCoord2d(0, 1); gl.glVertex3d(x*tileSize, 0, y*tileSize+tileSize); gl.glEnd(); texture.disable(gl); }
private void renderFace(GL2 gl, Texture t) { TextureCoords tc = t.getImageTexCoords(); float tx1 = tc.left(); float ty1 = tc.top(); float tx2 = tc.right(); float ty2 = tc.bottom(); t.enable(gl); t.bind(gl); if (button==4) gl.glColor4f(0.8f, 0.2f, 0.2f, alpha); else gl.glColor4f(alpha, alpha, alpha, alpha); gl.glBegin(GL2.GL_QUADS); gl.glTexCoord2f(tx1, ty1); gl.glVertex2f(currentRect.x, currentRect.y); gl.glTexCoord2f(tx2, ty1); gl.glVertex2f(currentRect.x, currentRect.y + currentRect.height); gl.glTexCoord2f(tx2, ty2); gl.glVertex2f(currentRect.x + currentRect.width, currentRect.y + currentRect.height); gl.glTexCoord2f(tx1, ty2); gl.glVertex2f(currentRect.x + currentRect.width, currentRect.y); gl.glEnd(); t.disable(gl); }
tex.disable(gl); // nop on core } else { gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL.GL_UNSIGNED_SHORT, 0);
tex.disable(gl); // nop on core } else { gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL.GL_UNSIGNED_SHORT, 0);
Texture t = textureCacheService.getTexture(gl, textureName); if (t != null) { t.disable(gl);
private void renderRegion(final GL2ES2 gl) { gl.glUniform(gcu_PMVMatrix02); gca_VerticesAttr.enableBuffer(gl, true); gca_CurveParamsAttr.enableBuffer(gl, true); if( null != gca_ColorsAttr ) { gca_ColorsAttr.enableBuffer(gl, true); } indicesBuffer.bindBuffer(gl, true); // keeps VBO binding if( null != gcu_ColorTexUnit && colorTexSeq.isTextureAvailable() ) { final TextureSequence.TextureFrame frame = colorTexSeq.getNextTexture(gl); gl.glActiveTexture(GL.GL_TEXTURE0 + colorTexSeq.getTextureUnit()); final Texture tex = frame.getTexture(); tex.bind(gl); tex.enable(gl); // nop on core gcu_ColorTexUnit.setData(colorTexSeq.getTextureUnit()); gl.glUniform(gcu_ColorTexUnit); // Always update, since program maybe used by multiple regions gl.glUniform(gcu_ColorTexBBox); // Always update, since program maybe used by multiple regions gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL.GL_UNSIGNED_SHORT, 0); tex.disable(gl); // nop on core } else { gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL.GL_UNSIGNED_SHORT, 0); } indicesBuffer.bindBuffer(gl, false); if( null != gca_ColorsAttr ) { gca_ColorsAttr.enableBuffer(gl, false); } gca_CurveParamsAttr.enableBuffer(gl, false); gca_VerticesAttr.enableBuffer(gl, false); }
private void renderRegion(final GL2ES2 gl) { gl.glUniform(gcu_PMVMatrix02); gca_VerticesAttr.enableBuffer(gl, true); gca_CurveParamsAttr.enableBuffer(gl, true); if( null != gca_ColorsAttr ) { gca_ColorsAttr.enableBuffer(gl, true); } indicesBuffer.bindBuffer(gl, true); // keeps VBO binding if( null != gcu_ColorTexUnit && colorTexSeq.isTextureAvailable() ) { final TextureSequence.TextureFrame frame = colorTexSeq.getNextTexture(gl); gl.glActiveTexture(GL.GL_TEXTURE0 + colorTexSeq.getTextureUnit()); final Texture tex = frame.getTexture(); tex.bind(gl); tex.enable(gl); // nop on core gcu_ColorTexUnit.setData(colorTexSeq.getTextureUnit()); gl.glUniform(gcu_ColorTexUnit); // Always update, since program maybe used by multiple regions gl.glUniform(gcu_ColorTexBBox); // Always update, since program maybe used by multiple regions gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL.GL_UNSIGNED_SHORT, 0); tex.disable(gl); // nop on core } else { gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL.GL_UNSIGNED_SHORT, 0); } indicesBuffer.bindBuffer(gl, false); if( null != gca_ColorsAttr ) { gca_ColorsAttr.enableBuffer(gl, false); } gca_CurveParamsAttr.enableBuffer(gl, false); gca_VerticesAttr.enableBuffer(gl, false); }
private void renderRegion(final GL2ES2 gl) { gl.glUniform(gcu_PMVMatrix02); gca_VerticesAttr.enableBuffer(gl, true); gca_CurveParamsAttr.enableBuffer(gl, true); if( null != gca_ColorsAttr ) { gca_ColorsAttr.enableBuffer(gl, true); } indicesBuffer.bindBuffer(gl, true); // keeps VBO binding if( null != gcu_ColorTexUnit && colorTexSeq.isTextureAvailable() ) { final TextureSequence.TextureFrame frame = colorTexSeq.getNextTexture(gl); gl.glActiveTexture(GL.GL_TEXTURE0 + colorTexSeq.getTextureUnit()); final Texture tex = frame.getTexture(); tex.bind(gl); tex.enable(gl); // nop on core gcu_ColorTexUnit.setData(colorTexSeq.getTextureUnit()); gl.glUniform(gcu_ColorTexUnit); // Always update, since program maybe used by multiple regions gl.glUniform(gcu_ColorTexBBox); // Always update, since program maybe used by multiple regions gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL.GL_UNSIGNED_SHORT, 0); tex.disable(gl); // nop on core } else { gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL.GL_UNSIGNED_SHORT, 0); } indicesBuffer.bindBuffer(gl, false); if( null != gca_ColorsAttr ) { gca_ColorsAttr.enableBuffer(gl, false); } gca_CurveParamsAttr.enableBuffer(gl, false); gca_VerticesAttr.enableBuffer(gl, false); }
private void renderRegion(final GL2ES2 gl) { gl.glUniform(gcu_PMVMatrix02); gca_VerticesAttr.enableBuffer(gl, true); gca_CurveParamsAttr.enableBuffer(gl, true); if( null != gca_ColorsAttr ) { gca_ColorsAttr.enableBuffer(gl, true); } indicesBuffer.bindBuffer(gl, true); // keeps VBO binding if( null != gcu_ColorTexUnit && colorTexSeq.isTextureAvailable() ) { final TextureSequence.TextureFrame frame = colorTexSeq.getNextTexture(gl); gl.glActiveTexture(GL.GL_TEXTURE0 + colorTexSeq.getTextureUnit()); final Texture tex = frame.getTexture(); tex.bind(gl); tex.enable(gl); // nop on core gcu_ColorTexUnit.setData(colorTexSeq.getTextureUnit()); gl.glUniform(gcu_ColorTexUnit); // Always update, since program maybe used by multiple regions gl.glUniform(gcu_ColorTexBBox); // Always update, since program maybe used by multiple regions gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL.GL_UNSIGNED_SHORT, 0); tex.disable(gl); // nop on core } else { gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL.GL_UNSIGNED_SHORT, 0); } indicesBuffer.bindBuffer(gl, false); if( null != gca_ColorsAttr ) { gca_ColorsAttr.enableBuffer(gl, false); } gca_CurveParamsAttr.enableBuffer(gl, false); gca_VerticesAttr.enableBuffer(gl, false); }
public void draw(GL2 gl, Point3d cameraPosition) { gl.glEnable(GL2.GL_LIGHTING); gl.glEnable(GL2.GL_TEXTURE_2D); TextureData td = this.textureLibraryStorageService.getTextureDefault("ground.unknown"); Texture texture = this.textureCacheService.getTexture(gl, td.getTex0()); texture.enable(gl); texture.bind(gl); gl.glBegin(GL2.GL_POLYGON); gl.glColor3f((float) 123 / 256, (float) 111 / 256, (float) 100 / 255); double groundSize = 1500.0; Point3d c = cameraPosition; // gl.glTexCoord2d(tc.left(), tc.bottom()); double xRight = c.x + groundSize; double xLeft = c.x - groundSize; double zButtom = c.z + groundSize; double zTop = c.z - groundSize; gl.glNormal3d(0, 1, 0); gl.glTexCoord2d(xRight * td.getWidth(), zButtom * td.getHeight()); gl.glVertex3d(xRight, -0.01, zButtom); gl.glTexCoord2d(xLeft * td.getWidth(), zButtom * td.getHeight()); gl.glVertex3d(xLeft, -0.01, zButtom); gl.glTexCoord2d(xLeft * td.getWidth(), zTop * td.getHeight()); gl.glVertex3d(xLeft, -0.01, zTop); gl.glTexCoord2d(xRight * td.getWidth(), zTop * td.getHeight()); gl.glVertex3d(xRight, -0.01, zTop); gl.glEnd(); texture.disable(gl); gl.glDisable(GL2.GL_TEXTURE_2D); }