Skip to content

Commit

Permalink
display bg elements in gl20
Browse files Browse the repository at this point in the history
  • Loading branch information
godrin committed Oct 11, 2012
1 parent 0daf112 commit 2c0dbf7
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions defend/src/com/cdm/view/elements/BackgroundElement.java
Expand Up @@ -4,9 +4,12 @@
import java.util.Arrays;
import java.util.List;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.math.Vector3;
import com.cdm.view.IRenderer;
import com.cdm.view.PolySprite;
import com.cdm.view.Position;
import com.cdm.view.elements.Grid.GridElement;

Expand All @@ -27,6 +30,7 @@ public class BackgroundElement implements Element {
private Position pos;
private final Color c0 = new Color(0.5f, 0.5f, 0.8f, 0.2f);
private final Color c1 = new Color(0.5f, 0.5f, 0.8f, 0.2f);
private final Color c2 = new Color(0.0f, 0.0f, 0.0f, 0.0f);
private static final float OUTER = 1.0f;
private static final float INNER = 0.8f;
private static final float ROT_WIDTH = 0.2f;
Expand All @@ -37,6 +41,7 @@ public class BackgroundElement implements Element {
private float lightness = 0.0f;
private GridElement gridElement;
private float rotatingSpeed = 0.8f;
private static PolySprite sprite = null;

public BackgroundElement(Position p, GridElement e) {
pos = p;
Expand Down Expand Up @@ -68,6 +73,16 @@ public BackgroundElement(Position p, GridElement e) {

setVecs();

if (sprite == null) {
sprite = new PolySprite();
sprite.fillRectangle(-OUTER, -OUTER, OUTER * 2, OUTER * 2, c0);
sprite.fillRectangle(-INNER, -INNER, INNER * 2, INNER * 2, c1);
sprite.fillRectangle(-0.7f, -0.7f, 1.4f, 0.1f, c0);
sprite.makeNiceRectangle(0.15f, -INNER, -INNER, INNER*2, INNER*2, c0, c2);

sprite.init();
}

}

public void move(float t) {
Expand All @@ -77,9 +92,11 @@ public void move(float t) {
rotateAngle = 0;
rotating = false;
}
setVecs();
if (Gdx.gl20 == null)
setVecs();
}
setColor(t);
if (Gdx.gl20 == null)
setColor(t);
}

private void setColor(float t) {
Expand Down Expand Up @@ -144,12 +161,14 @@ public void startRotation() {

@Override
public void draw(IRenderer renderer) {
if (false) {
if (Gdx.gl20 == null) {
renderer.drawPoly(pos, boxes, 0, c0, size);

renderer.drawPoly(pos, boxes0, 0, c1, size);

renderer.drawLines(pos, lines, 0, c0, size);
} else {
renderer.render(sprite, pos, size, 0, GL20.GL_TRIANGLES);
}
}

Expand Down

0 comments on commit 2c0dbf7

Please sign in to comment.