List of usage examples for com.badlogic.gdx.graphics GL20 GL_BLEND
int GL_BLEND
To view the source code for com.badlogic.gdx.graphics GL20 GL_BLEND.
Click Source Link
From source file:seventh.client.gfx.GdxCanvas.java
License:Open Source License
@Override public void fillRect(float x, float y, float width, float height, Integer color) { Color c = setTempColor(color); Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); this.shapes.begin(ShapeType.Filled); this.shapes.setColor(c); this.shapes.rect(x, y, width, height); this.shapes.end(); Gdx.gl.glDisable(GL20.GL_BLEND);//from w ww. j a v a 2 s . c o m }
From source file:seventh.client.gfx.GdxCanvas.java
License:Open Source License
@Override public void drawCircle(float radius, int x, int y, Integer color) { Color c = setTempColor(color); Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); this.shapes.setColor(c); this.shapes.begin(ShapeType.Line); this.shapes.circle(x + radius, y + radius, radius); this.shapes.end(); Gdx.gl.glDisable(GL20.GL_BLEND);/* w w w. j a v a 2 s. co m*/ }
From source file:seventh.client.gfx.GdxCanvas.java
License:Open Source License
@Override public void drawCircle(float radius, float x, float y, Integer color) { Color c = setTempColor(color); Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); this.shapes.setColor(c); this.shapes.begin(ShapeType.Line); this.shapes.circle(x + radius, y + radius, radius); this.shapes.end(); Gdx.gl.glDisable(GL20.GL_BLEND);// ww w .j av a 2 s .co m }
From source file:seventh.client.gfx.GdxCanvas.java
License:Open Source License
@Override public void fillCircle(float radius, int x, int y, Integer color) { Color c = setTempColor(color); Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); this.shapes.setColor(c); this.shapes.begin(ShapeType.Filled); this.shapes.circle(x + radius, y + radius, radius); this.shapes.end(); Gdx.gl.glDisable(GL20.GL_BLEND);/*from w ww. j a va2s .co m*/ }
From source file:seventh.client.gfx.GdxCanvas.java
License:Open Source License
@Override public void fillCircle(float radius, float x, float y, Integer color) { Color c = setTempColor(color); Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); this.shapes.setColor(c); this.shapes.begin(ShapeType.Filled); this.shapes.circle(x + radius, y + radius, radius); this.shapes.end(); Gdx.gl.glDisable(GL20.GL_BLEND);//from ww w.ja va 2 s .co m }
From source file:seventh.client.gfx.GdxCanvas.java
License:Open Source License
@Override public void fillArc(float x, float y, float radius, float start, float degrees, Integer color) { Color c = setTempColor(color); Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); this.shapes.setColor(c); this.shapes.begin(ShapeType.Filled); this.shapes.arc(x, y, radius, start, degrees); this.shapes.end(); Gdx.gl.glDisable(GL20.GL_BLEND);//from w ww.ja va2 s .c o m }
From source file:spaceisnear.game.ui.TextField.java
@Override public void paint(Batch batch) { if (checkKeys(keycode)) { keycode = 0;//from w w w. ja v a 2 s .co m } ShapeRenderer renderer = getRenderer(); focused = getStage().getKeyboardFocus() == this; int start = 0; int end = text.length(); int startingXText = 0; //TODO GlyphLayout glyphLayout = new GlyphLayout(font, text); if (glyphLayout.width > getWidthWithoutPaddings()) { end = text.length(); start = end - 1; glyphLayout.setText(font, text, start, end, textColor, getWidthWithoutPaddings(), 0, false, null); while (start > 0 && glyphLayout.width < getWidthWithoutPaddings()) { start--; } glyphLayout.setText(font, text, 0, start, textColor, getWidthWithoutPaddings(), 0, false, null); startingXText = (int) -glyphLayout.width; } // { Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); renderer.setProjectionMatrix(batch.getProjectionMatrix()); renderer.begin(ShapeRenderer.ShapeType.Filled); renderer.setColor(backgroundColor); renderer.rect(0, 0, getWidth(), getHeight()); renderer.end(); Gdx.gl.glDisable(GL20.GL_BLEND); } { renderer.begin(ShapeRenderer.ShapeType.Line); renderer.setColor(borderColor); renderer.rect(0, 0, getWidth() + 1, getHeight()); renderer.end(); } //cursor renderer.begin(ShapeRenderer.ShapeType.Line); font.setColor(Color.BLACK); if (focused) { glyphLayout.setText(font, text, 0, currentPosition, textColor, getWidthWithoutPaddings(), 0, false, null); final float x = 10 + glyphLayout.width + startingXText; renderer.line(x, 3, x, font.getLineHeight() + 2); renderer.line(x + 1, 3, x + 1, font.getLineHeight() + 2); } renderer.end(); batch.begin(); font.setColor(Color.BLACK); font.draw(batch, text.subSequence(start, end), WIDTH_PADDING + getX(), 3 + getY()); batch.end(); }
From source file:spine.SkeletonRendererDebug.java
License:Open Source License
public void draw(Skeleton skeleton) { float skeletonX = skeleton.getX(); float skeletonY = skeleton.getY(); Gdx.gl.glEnable(GL20.GL_BLEND); int srcFunc = premultipliedAlpha ? GL20.GL_ONE : GL20.GL_SRC_ALPHA; Gdx.gl.glBlendFunc(srcFunc, GL20.GL_ONE_MINUS_SRC_ALPHA); ShapeRenderer shapes = this.shapes; Array<Bone> bones = skeleton.getBones(); if (drawBones) { shapes.setColor(boneLineColor);// w w w . jav a 2 s .c om shapes.begin(ShapeType.Filled); for (int i = 0, n = bones.size; i < n; i++) { Bone bone = bones.get(i); if (bone.parent == null) continue; float x = skeletonX + bone.data.length * bone.a + bone.worldX; float y = skeletonY + bone.data.length * bone.c + bone.worldY; shapes.rectLine(skeletonX + bone.worldX, skeletonY + bone.worldY, x, y, boneWidth * scale); } shapes.end(); shapes.begin(ShapeType.Line); shapes.x(skeletonX, skeletonY, 4 * scale); } else shapes.begin(ShapeType.Line); if (drawRegionAttachments) { shapes.setColor(attachmentLineColor); Array<Slot> slots = skeleton.getSlots(); for (int i = 0, n = slots.size; i < n; i++) { Slot slot = slots.get(i); Attachment attachment = slot.attachment; if (attachment instanceof RegionAttachment) { RegionAttachment regionAttachment = (RegionAttachment) attachment; float[] vertices = regionAttachment.updateWorldVertices(slot, false); shapes.line(vertices[X1], vertices[Y1], vertices[X2], vertices[Y2]); shapes.line(vertices[X2], vertices[Y2], vertices[X3], vertices[Y3]); shapes.line(vertices[X3], vertices[Y3], vertices[X4], vertices[Y4]); shapes.line(vertices[X4], vertices[Y4], vertices[X1], vertices[Y1]); } } } if (drawMeshHull || drawMeshTriangles) { Array<Slot> slots = skeleton.getSlots(); for (int i = 0, n = slots.size; i < n; i++) { Slot slot = slots.get(i); Attachment attachment = slot.attachment; float[] vertices = null; short[] triangles = null; int hullLength = 0; if (attachment instanceof MeshAttachment) { MeshAttachment mesh = (MeshAttachment) attachment; mesh.updateWorldVertices(slot, false); vertices = mesh.getWorldVertices(); triangles = mesh.getTriangles(); hullLength = mesh.getHullLength(); } else if (attachment instanceof SkinnedMeshAttachment) { SkinnedMeshAttachment mesh = (SkinnedMeshAttachment) attachment; mesh.updateWorldVertices(slot, false); vertices = mesh.getWorldVertices(); triangles = mesh.getTriangles(); hullLength = mesh.getHullLength(); } if (vertices == null || triangles == null) continue; if (drawMeshTriangles) { shapes.setColor(triangleLineColor); for (int ii = 0, nn = triangles.length; ii < nn; ii += 3) { int v1 = triangles[ii] * 5, v2 = triangles[ii + 1] * 5, v3 = triangles[ii + 2] * 5; shapes.triangle(vertices[v1], vertices[v1 + 1], // vertices[v2], vertices[v2 + 1], // vertices[v3], vertices[v3 + 1] // ); } } if (drawMeshHull && hullLength > 0) { shapes.setColor(attachmentLineColor); hullLength = hullLength / 2 * 5; float lastX = vertices[hullLength - 5], lastY = vertices[hullLength - 4]; for (int ii = 0, nn = hullLength; ii < nn; ii += 5) { float x = vertices[ii], y = vertices[ii + 1]; shapes.line(x, y, lastX, lastY); lastX = x; lastY = y; } } } } if (drawBoundingBoxes) { SkeletonBounds bounds = this.bounds; bounds.update(skeleton, true); shapes.setColor(aabbColor); shapes.rect(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight()); shapes.setColor(boundingBoxColor); Array<FloatArray> polygons = bounds.getPolygons(); for (int i = 0, n = polygons.size; i < n; i++) { FloatArray polygon = polygons.get(i); shapes.polygon(polygon.items, 0, polygon.size); } } shapes.end(); shapes.begin(ShapeType.Filled); if (drawBones) { shapes.setColor(boneOriginColor); for (int i = 0, n = bones.size; i < n; i++) { Bone bone = bones.get(i); shapes.setColor(Color.GREEN); shapes.circle(skeletonX + bone.worldX, skeletonY + bone.worldY, 3 * scale, 8); } } shapes.end(); }
From source file:ta.firegreen.creation.creator.java
License:Apache License
@Override public void create() { batch = new SpriteBatch(); rendu = new ImmediateModeRenderer20(false, true, 0); renduTexture = new ImmediateModeRenderer20(false, true, 1); configF = new ConfigurationFrame(this); cam = new PerspectiveCamera(95, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); Gdx.gl20.glEnable(GL20.GL_TEXTURE_2D); Gdx.gl20.glEnable(GL20.GL_DEPTH_TEST); Gdx.gl20.glEnable(GL20.GL_BLEND); Gdx.gl20.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); shape = new ShapeRenderer(); cam.near = 1;//from w w w .j av a 2s . c om cam.far = 100; cam.direction.set(0, 1, 0); cam.position.set(posX, posY, posZ); cam.lookAt(cibleX, cibleY, cibleZ); cam.update(); configF.setVisible(true); trianglesSelected = new MeshTA(); }
From source file:tools.SpriteBatch.java
License:Apache License
/** * Finishes off rendering. Enables depth writes, disables blending and * texturing. Must always be called after a call to {@link #begin()} *//*from www . j a va 2 s . c o m*/ public void end() { if (!drawing) { throw new IllegalStateException("SpriteBatch.begin must be called before end."); } if (idx > 0) { renderMesh(); } lastTexture = null; idx = 0; drawing = false; GL20 gl = Gdx.gl; gl.glDepthMask(true); if (isBlendingEnabled()) { gl.glDisable(GL20.GL_BLEND); } if (customShader != null) { customShader.end(); } else { shader.end(); } }