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:com.kotcrab.vis.editor.module.physicseditor.PRenderer.java
License:Apache License
public void drawBallThrowPath(Vector2 p1, Vector2 p2) { if (p1 == null || p2 == null) return;//from w w w. j ava 2 s .c o m Gdx.gl.glLineWidth(3); Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); float w = 0.03f * camera.getZoom(); drawer.setProjectionMatrix(camera.getCombinedMatrix()); drawer.begin(ShapeRenderer.ShapeType.Line); drawer.setColor(BALLTHROWPATH_COLOR); drawer.line(p1.x, p1.y, p2.x, p2.y); drawer.end(); drawer.setProjectionMatrix(camera.getCombinedMatrix()); drawer.begin(ShapeType.Filled); drawer.setColor(BALLTHROWPATH_COLOR); drawer.rect(p2.cpy().sub(w / 2, w / 2).x, p2.cpy().sub(w / 2, w / 2).y, w, w); drawer.end(); }
From source file:com.kotcrab.vis.editor.module.physicseditor.PRenderer.java
License:Apache License
private void drawBoundingBox(float w, float h) { Gdx.gl.glLineWidth(1);/* w w w . j ava 2 s .c o m*/ Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); drawer.begin(ShapeType.Line); drawer.setColor(AXIS_COLOR); drawer.rect(0, 0, w, h); drawer.end(); }
From source file:com.kotcrab.vis.editor.module.physicseditor.PRenderer.java
License:Apache License
private void drawGrid(float gap) { Gdx.gl.glLineWidth(1);// w ww .j av a2s. com Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); if (gap <= 0) gap = 0.001f; float x = camera.getX(); float y = camera.getY(); float w = camera.getCamera().viewportWidth; float h = camera.getCamera().viewportHeight; float z = camera.getZoom(); drawer.begin(ShapeRenderer.ShapeType.Line); drawer.setColor(GRID_COLOR); for (float d = 0; d < x + w / 2 * z; d += gap) drawer.line(d, y - h / 2 * z, d, y + h / 2 * z); for (float d = -gap; d > x - w / 2 * z; d -= gap) drawer.line(d, y - h / 2 * z, d, y + h / 2 * z); for (float d = 0; d < y + h / 2 * z; d += gap) drawer.line(x - w / 2 * z, d, x + w / 2 * z, d); for (float d = -gap; d > y - h / 2 * z; d -= gap) drawer.line(x - w / 2 * z, d, x + w / 2 * z, d); drawer.end(); }
From source file:com.kotcrab.vis.editor.module.physicseditor.PRenderer.java
License:Apache License
private void drawShapes(Array<ShapeModel> shapes, Vector2 nextPoint) { Gdx.gl.glLineWidth(2);/*from w w w . j av a 2 s . co m*/ Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); for (ShapeModel shape : shapes) { Array<Vector2> vs = shape.getVertices(); if (vs.size == 0) continue; switch (shape.getType()) { case POLYGON: drawer.begin(ShapeRenderer.ShapeType.Line); drawer.setColor(SHAPE_COLOR); for (int i = 1; i < vs.size; i++) drawer.line(vs.get(i).x, vs.get(i).y, vs.get(i - 1).x, vs.get(i - 1).y); if (shape.isClosed()) { drawer.setColor(SHAPE_COLOR); drawer.line(vs.get(0).x, vs.get(0).y, vs.get(vs.size - 1).x, vs.get(vs.size - 1).y); } else { drawer.setColor(SHAPE_LASTLINE_COLOR); drawer.line(vs.get(vs.size - 1).x, vs.get(vs.size - 1).y, nextPoint.x, nextPoint.y); } drawer.end(); break; case CIRCLE: if (shape.isClosed()) { Vector2 center = shape.getVertices().get(0); float radius = shape.getVertices().get(1).cpy().sub(center).len(); if (radius > 0.0001f) { drawer.begin(ShapeType.Line); drawer.setColor(SHAPE_COLOR); drawer.circle(center.x, center.y, radius, 20); drawer.end(); } } else { Vector2 center = shape.getVertices().get(0); float radius = nextPoint.cpy().sub(center).len(); if (radius > 0.0001f) { drawer.begin(ShapeType.Line); drawer.setColor(SHAPE_LASTLINE_COLOR); drawer.circle(center.x, center.y, radius, 20); drawer.end(); } } break; } } }
From source file:com.kotcrab.vis.editor.module.physicseditor.PRenderer.java
License:Apache License
private void drawPoints(Array<ShapeModel> shapes, List<Vector2> selectedPoints, Vector2 nearestPoint, Vector2 nextPoint) {//from w w w . j av a2 s. co m Gdx.gl.glLineWidth(2); Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); float w = 0.025f * camera.getZoom(); for (ShapeModel shape : shapes) { for (Vector2 p : shape.getVertices()) { if (p == nearestPoint || (selectedPoints != null && selectedPoints.contains(p))) { drawer.begin(ShapeType.Filled); drawer.setColor(SHAPE_COLOR); drawer.rect(p.cpy().sub(w / 2, w / 2).x, p.cpy().sub(w / 2, w / 2).y, w, w); drawer.end(); } else { drawer.begin(ShapeType.Line); drawer.setColor(SHAPE_COLOR); drawer.rect(p.cpy().sub(w / 2, w / 2).x, p.cpy().sub(w / 2, w / 2).y, w, w); drawer.end(); } } } if (nextPoint != null) { drawer.begin(ShapeType.Line); drawer.setColor(SHAPE_LASTLINE_COLOR); drawer.rect(nextPoint.cpy().sub(w / 2, w / 2).x, nextPoint.cpy().sub(w / 2, w / 2).y, w, w); drawer.end(); } }
From source file:com.kotcrab.vis.editor.module.physicseditor.PRenderer.java
License:Apache License
private void drawPolygons(Array<PolygonModel> polygons) { Gdx.gl.glLineWidth(2);//from w w w.java 2s .co m Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); drawer.begin(ShapeRenderer.ShapeType.Line); drawer.setColor(POLYGON_COLOR); for (PolygonModel polygon : polygons) { List<Vector2> vs = polygon.vertices; for (int i = 1, n = vs.size(); i < n; i++) drawer.line(vs.get(i).x, vs.get(i).y, vs.get(i - 1).x, vs.get(i - 1).y); if (vs.size() > 1) drawer.line(vs.get(0).x, vs.get(0).y, vs.get(vs.size() - 1).x, vs.get(vs.size() - 1).y); } drawer.end(); }
From source file:com.kotcrab.vis.editor.module.physicseditor.PRenderer.java
License:Apache License
private void drawOrigin(Vector2 o, Vector2 nearestPoint) { Gdx.gl.glLineWidth(2);/*from ww w. j a va2s . co m*/ Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); float len = 0.03f * camera.getZoom(); float radius = 0.02f * camera.getZoom(); drawer.begin(ShapeRenderer.ShapeType.Line); drawer.setColor(ORIGIN_COLOR); drawer.line(o.x - len, o.y, o.x + len, o.y); drawer.line(o.x, o.y - len, o.x, o.y + len); drawer.end(); if (nearestPoint != o) { drawer.begin(ShapeType.Line); drawer.setColor(ORIGIN_COLOR); drawer.circle(o.x, o.y, radius, 20); drawer.end(); } else { drawer.begin(ShapeType.Filled); drawer.setColor(ORIGIN_COLOR); drawer.circle(o.x, o.y, radius, 20); drawer.end(); } }
From source file:com.kotcrab.vis.editor.module.physicseditor.PRenderer.java
License:Apache License
private void drawMouseSelection(float x1, float y1, float x2, float y2) { Gdx.gl.glLineWidth(3);/*from www . j a v a 2 s. c om*/ Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); Rectangle rect = new Rectangle(Math.min(x1, x2), Math.min(y1, y2), Math.abs(x2 - x1), Math.abs(y2 - y1)); drawer.begin(ShapeType.Filled); drawer.setColor(MOUSESELECTION_FILL_COLOR); drawer.rect(rect.x, rect.y, rect.width, rect.height); drawer.end(); drawer.begin(ShapeType.Line); drawer.setColor(MOUSESELECTION_STROKE_COLOR); drawer.rect(rect.x, rect.y, rect.width, rect.height); drawer.end(); }
From source file:com.kotcrab.vis.editor.module.scene.entitymanipulator.RectangularSelection.java
License:Apache License
public void render(ShapeRenderer shapeRenderer) { if (rectToDraw != null) { Gdx.gl20.glEnable(GL20.GL_BLEND); Color border = selectionMode == SelectionMode.Inner ? INNER_MODE_BORDER_COLOR : OVERLAP_MODE_BORDER_COLOR; Color fill = selectionMode == SelectionMode.Inner ? INNER_MODE_FILL_COLOR : OVERLAP_MODE_FILL_COLOR; shapeRenderer.setColor(border);//from ww w . j a v a 2 s.com shapeRenderer.begin(ShapeType.Line); shapeRenderer.rect(rectToDraw.getX(), rectToDraw.getY(), rectToDraw.getWidth(), rectToDraw.getHeight()); shapeRenderer.end(); shapeRenderer.setColor(fill); shapeRenderer.begin(ShapeType.Filled); shapeRenderer.rect(rectToDraw.getX(), rectToDraw.getY(), rectToDraw.getWidth(), rectToDraw.getHeight()); shapeRenderer.end(); } }
From source file:com.kotcrab.vis.editor.module.scene.RectangularSelection.java
License:Apache License
public void render(ShapeRenderer shapeRenderer) { if (rectToDraw != null) { Gdx.gl20.glEnable(GL20.GL_BLEND); shapeRenderer.setColor(0.11f, 0.63f, 0.89f, 1); shapeRenderer.begin(ShapeType.Line); shapeRenderer.rect(rectToDraw.getX(), rectToDraw.getY(), rectToDraw.getWidth(), rectToDraw.getHeight()); shapeRenderer.end();//from w ww. j av a2 s . c o m shapeRenderer.setColor(0.05f, 0.33f, 0.49f, 0.3f); shapeRenderer.begin(ShapeType.Filled); shapeRenderer.rect(rectToDraw.getX(), rectToDraw.getY(), rectToDraw.getWidth(), rectToDraw.getHeight()); shapeRenderer.end(); } }