@Override public void drawSolidPolygon(Vec2[] vertices, int vertexCount, Color3f color) { GL2 gl = panel.getGL().getGL2(); gl.glPushMatrix(); transformViewport(gl, zero); gl.glBegin(GL2.GL_TRIANGLE_FAN); gl.glColor4f(color.x, color.y, color.z, .4f); for (int i = 0; i < vertexCount; i++) { Vec2 v = vertices[i]; gl.glVertex2f(v.x, v.y); } gl.glEnd(); gl.glBegin(GL2.GL_LINE_LOOP); gl.glColor4f(color.x, color.y, color.z, 1f); for (int i = 0; i < vertexCount; i++) { Vec2 v = vertices[i]; gl.glVertex2f(v.x, v.y); } gl.glEnd(); gl.glPopMatrix(); }
@Override public void drawPolygon(Vec2[] vertices, int vertexCount, Color3f color) { GL2 gl = panel.getGL().getGL2(); gl.glPushMatrix(); transformViewport(gl, zero); gl.glBegin(GL2.GL_LINE_LOOP); gl.glColor4f(color.x, color.y, color.z, 1f); for (int i = 0; i < vertexCount; i++) { Vec2 v = vertices[i]; gl.glVertex2f(v.x, v.y); } gl.glEnd(); gl.glPopMatrix(); }
@Override public void drawCircle(Vec2 center, float radius, Color3f color) { GL2 gl = panel.getGL().getGL2(); gl.glPushMatrix(); transformViewport(gl, zero); float theta = 2 * MathUtils.PI / NUM_CIRCLE_POINTS; float c = MathUtils.cos(theta); float s = MathUtils.sin(theta); float x = radius; float y = 0; float cx = center.x; float cy = center.y; gl.glBegin(GL2.GL_LINE_LOOP); gl.glColor4f(color.x, color.y, color.z, 1); for (int i = 0; i < NUM_CIRCLE_POINTS; i++) { gl.glVertex3f(x + cx, y + cy, 0); // apply the rotation matrix float temp = x; x = c * x - s * y; y = s * temp + c * y; } gl.glEnd(); gl.glPopMatrix(); }
float cy = center.y; gl.glBegin(GL2.GL_TRIANGLE_FAN); gl.glColor4f(color.x, color.y, color.z, .4f); for (int i = 0; i < NUM_CIRCLE_POINTS; i++) { gl.glVertex3f(x + cx, y + cy, 0); gl.glColor4f(color.x, color.y, color.z, 1); for (int i = 0; i < NUM_CIRCLE_POINTS; i++) { gl.glVertex3f(x + cx, y + cy, 0);
gl.glBegin(GL2.GL_LINE_LOOP); if (colors == null) { gl.glColor4f(1, 1, 1, 1); } else { ParticleColor color = colors[i];
gl.glBegin(GL2.GL_TRIANGLE_FAN); if (colors == null) { gl.glColor4f(1, 1, 1, .4f); } else { ParticleColor color = colors[i];
@Override public void drawCircle(Vec2 center, float radius, Vec2 axis, Color3f color) { GL2 gl = panel.getGL().getGL2(); gl.glPushMatrix(); transformViewport(gl, zero); float theta = 2 * MathUtils.PI / NUM_CIRCLE_POINTS; float c = MathUtils.cos(theta); float s = MathUtils.sin(theta); float x = radius; float y = 0; float cx = center.x; float cy = center.y; gl.glBegin(GL2.GL_LINE_LOOP); gl.glColor4f(color.x, color.y, color.z, 1); for (int i = 0; i < NUM_CIRCLE_POINTS; i++) { gl.glVertex3f(x + cx, y + cy, 0); // apply the rotation matrix float temp = x; x = c * x - s * y; y = s * temp + c * y; } gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(cx, cy, 0); gl.glVertex3f(cx + axis.x * radius, cy + axis.y * radius, 0); gl.glEnd(); gl.glPopMatrix(); }
/** Changes the color of the polygons, and therefore the drawn images, this TextureRenderer produces. Use of this method is optional. The TextureRenderer uses the GL_MODULATE texture environment mode, which causes the portions of the rendered texture to be multiplied by the color of the rendered polygons. The polygon color can be varied to achieve effects like tinting of the overall output or fading in and out by changing the alpha of the color. <P> Each component ranges from 0.0f - 1.0f. The alpha component, if used, does not need to be premultiplied into the color channels as described in the documentation for {@link com.jogamp.opengl.util.texture.Texture Texture}, although premultiplied colors are used internally. The default color is opaque white. @param r the red component of the new color @param g the green component of the new color @param b the blue component of the new color @param a the alpha component of the new color, 0.0f = completely transparent, 1.0f = completely opaque @throws GLException If an OpenGL context is not current when this method is called */ public void setColor(final float r, final float g, final float b, final float a) throws GLException { final GL2 gl = GLContext.getCurrentGL().getGL2(); this.r = r * a; this.g = g * a; this.b = b * a; this.a = a; gl.glColor4f(this.r, this.g, this.b, this.a); }
@Override void renderContents(GL2 gl) { // Get text bounds. Rectangle2D bounds = renderer.getBounds(getMessage()); // Render message background: final float bx1 = .45f * (float) (width - bounds.getWidth()); final float bx2 = .55f * (float) (width + bounds.getWidth()); final float by1 = .45f * (float) (height - bounds.getHeight()); final float by2 = .55f * (float) (height + bounds.getHeight()); gl.glBegin(GL2.GL_QUADS); gl.glColor4f(0f, 0f, 0f, .75f); gl.glVertex2f(bx1, by1); gl.glVertex2f(bx1, by2); gl.glVertex2f(bx2, by2); gl.glVertex2f(bx2, by1); gl.glEnd(); // Render message renderer.beginRendering(width, height); renderer.setColor(1f, 1f, 1f, 1f); renderer.setColor(1f, 1f, 1f, 1f); renderer.draw(getMessage(), (width - (int) bounds.getWidth()) >> 1, (height - (int) bounds.getHeight()) >> 1); renderer.endRendering(); }
gl.glColor4f(0f, 0f, 0f, .75f); for (int i = 0; i < numopt; i++) { if (bounds[numopt - i - 1] == null) {
@Override public void render( DrawContext dc ) { GL2 gl = dc.getGL( ).getGL2( ); gl.glPushAttrib( GL2.GL_POLYGON_BIT ); gl.glPolygonMode( GL2.GL_FRONT, GL2.GL_FILL ); gl.glEnable( GL2.GL_CULL_FACE ); gl.glCullFace( GL2.GL_BACK ); SurfaceTileRenderer r = renderer != null ? renderer : dc.getGeographicSurfaceTileRenderer( ); if ( opacity != 1.0f ) { gl.glEnable( GL2.GL_BLEND ); gl.glBlendFunc( GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA ); gl.glColor4f( 1.0f, 1.0f, 1.0f, opacity ); } else { gl.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); } try { r.renderTiles( dc, this.thisList ); } finally { gl.glPopAttrib( ); } }
gl.glUnmapBuffer(GL.GL_ARRAY_BUFFER); gl.glColor4f(1f, 1f, 1f, 1f); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vbi[0]); gl.glVertexPointer(2, GL.GL_FLOAT, 5 * ByteArrayUtil.SIZE_FLOAT, 0);
/** * Main render method * * @param gl GL context */ public final void render(GL2 gl) { gl.glMatrixMode(GL2.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glOrtho(0, width, 0, height, -1, +1); gl.glColor4f(0f, 0f, 0f, .5f); // Fade background: gl.glBegin(GL2.GL_QUADS); gl.glVertex2f(0f, 0f); gl.glVertex2f(width, 0f); gl.glVertex2f(width, height); gl.glVertex2f(0f, height); gl.glEnd(); renderContents(gl); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPopMatrix(); }
try gl.glColor4f(this.color[0], this.color[1], this.color[2], this.color[3]); this.drawOutline(dc, a, b, c, d); gl.glTranslated(r.x, r.y, r.z);
gl.glColor4f(0f, 0f, 0f, 1f); for(Layout.Edge edge : shared.layout.edges) { Node n1 = shared.layout.getNode(edge.dim1), gl.glColor4f(1f, 1f, 1f, 1f); final Node node2 = shared.layout.getNode(od); gl.glColor4f(0f, 0f, 0f, 1f); gl.glVertex3d(node1.getX(), node1.getY(), 0f); gl.glVertex3d(node1.getX(), node1.getY(), 1f);
gl.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
gl.glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_TEXTURE_ENV_MODE, GL2ES1.GL_MODULATE); gl.glColor4f(r, g, b, a); if (smoothingChanged) { smoothingChanged = false;