added new mesh to render

This commit is contained in:
Harrison Deng 2017-09-19 00:58:28 -05:00
parent bf2e68e0f7
commit a45662238f
2 changed files with 18 additions and 21 deletions

View File

@ -8,8 +8,9 @@ import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.utils.Disposable;
public class Parallelogram {
public class Parallelogram implements Disposable {
private Mesh mesh;
private OrthographicCamera cam;
private ShaderProgram shader;
@ -25,7 +26,7 @@ public class Parallelogram {
public Parallelogram(OrthographicCamera camera) {
this.cam = camera;
shader = new ShaderProgram(Gdx.files.internal("shaders/mesh.vsh"), Gdx.files.internal("shaders/mesh.vsh"));
mesh = new Mesh(true, MAX_VERTS, 0, new VertexAttribute(Usage.Position, POSITION_VARS, "a_position"),
//still expects 4 color components
new VertexAttribute(Usage.ColorPacked, 4, "a_color"));
@ -81,4 +82,9 @@ public class Parallelogram {
idx = 0;
}
}
@Override
public void dispose() {
mesh.dispose();
}
}

View File

@ -2,18 +2,17 @@ package zero1hd.rhythmbullet.graphics.ui.components;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.utils.Disposable;
import zero1hd.rhythmbullet.graphics.meshes.Parallelogram;
public class TitleBarVisualizer extends Group implements Disposable {
private Visualizer hvisual;
private Sprite backgroundBar;
private Texture backgroundTexture;
private Parallelogram parall;
private Image titleImage;
public TitleBarVisualizer(AssetManager assets) {
@ -22,19 +21,9 @@ public class TitleBarVisualizer extends Group implements Disposable {
hvisual = new Visualizer();
addActor(hvisual);
Pixmap pixmap = new Pixmap(2, 2, Format.RGBA8888);
pixmap.setColor(Color.WHITE);
pixmap.fill();
backgroundTexture = new Texture(pixmap);
pixmap.dispose();
backgroundBar = new Sprite(backgroundTexture);
titleImage = new Image(assets.get("title.png", Texture.class));
addActor(titleImage);
backgroundBar.setPosition(getX(), getY());
backgroundBar.setRotation(getRotation());
backgroundBar.setSize(getWidth(), getHeight());
hvisual.setY(getHeight());
}
@ -43,25 +32,27 @@ public class TitleBarVisualizer extends Group implements Disposable {
super.act(delta);
}
@Override
public void draw(Batch batch, float parentAlpha) {
parall.drawParallelogram(getX(), getY(), getWidth(), getHeight(), 30, getColor());
super.draw(batch, parentAlpha);
}
public Visualizer getHvisual() {
return hvisual;
}
@Override
public void dispose() {
backgroundTexture.dispose();
backgroundTexture = null;
}
@Override
public void setColor(Color color) {
backgroundBar.setColor(color);
super.setColor(color);
}
@Override
public void setColor(float r, float g, float b, float a) {
backgroundBar.setColor(r, g, b, a);
super.setColor(r, g, b, a);
}
}