changed to completely dedicated mesh instead of generic
This commit is contained in:
parent
a45662238f
commit
3c6616a242
@ -10,50 +10,74 @@ import com.badlogic.gdx.graphics.VertexAttributes.Usage;
|
||||
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
|
||||
public class Parallelogram implements Disposable {
|
||||
public class TitleBarMesh implements Disposable {
|
||||
private Mesh mesh;
|
||||
private OrthographicCamera cam;
|
||||
private ShaderProgram shader;
|
||||
private Color color;
|
||||
private int height;
|
||||
|
||||
public final int POSITION_VARS = 2;
|
||||
public final int COLOR_VARS = 1; //Packed color data
|
||||
public final int TOTAL_VARS = POSITION_VARS + COLOR_VARS;
|
||||
public final int MAX_QUADS = 1;
|
||||
public final int MAX_VERTS = 4 * MAX_QUADS;
|
||||
public final int MAX_POLY = 1;
|
||||
public final int MAX_VERTS = 4 * MAX_POLY;
|
||||
|
||||
private float[] verts = new float[MAX_VERTS * TOTAL_VARS];
|
||||
|
||||
|
||||
public Parallelogram(OrthographicCamera camera) {
|
||||
this.cam = camera;
|
||||
public TitleBarMesh() {
|
||||
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"));
|
||||
|
||||
color = new Color(Color.WHITE);
|
||||
}
|
||||
|
||||
public void setCam(OrthographicCamera cam) {
|
||||
this.cam = cam;
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public void setHeight(int height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
private int idx = 0;
|
||||
|
||||
public void drawParallelogram(float x, float y, float width, float height, float topOffset, Color color) {
|
||||
public void draw() {
|
||||
if (idx >= verts.length) {
|
||||
flush();
|
||||
}
|
||||
|
||||
float c = color.toFloatBits();
|
||||
|
||||
verts[idx++] = x;
|
||||
verts[idx++] = y;
|
||||
verts[idx++] = 0;
|
||||
verts[idx++] = Gdx.graphics.getHeight()/2;
|
||||
verts[idx++] = c;
|
||||
|
||||
verts[idx++] = x + width;
|
||||
verts[idx++] = y;
|
||||
verts[idx++] = Gdx.graphics.getWidth();
|
||||
verts[idx++] = Gdx.graphics.getHeight()-height;
|
||||
verts[idx++] = c;
|
||||
|
||||
verts[idx++] = x + width + topOffset;
|
||||
verts[idx++] = y + height;
|
||||
verts[idx++] = Gdx.graphics.getWidth();
|
||||
verts[idx++] = Gdx.graphics.getHeight();
|
||||
verts[idx++] = c;
|
||||
|
||||
verts[idx++] = x + topOffset;
|
||||
verts[idx++] = y + height;
|
||||
verts[idx++] = 0;
|
||||
verts[idx++] = Gdx.graphics.getHeight()/2 + height;
|
||||
verts[idx++] = c;
|
||||
}
|
||||
|
@ -1,21 +1,23 @@
|
||||
package zero1hd.rhythmbullet.graphics.ui.components;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
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;
|
||||
import zero1hd.rhythmbullet.graphics.meshes.TitleBarMesh;
|
||||
|
||||
public class TitleBarVisualizer extends Group implements Disposable {
|
||||
private Visualizer hvisual;
|
||||
private Parallelogram parall;
|
||||
private TitleBarMesh background;
|
||||
private Image titleImage;
|
||||
|
||||
public TitleBarVisualizer(AssetManager assets) {
|
||||
public TitleBarVisualizer(AssetManager assets, OrthographicCamera camera) {
|
||||
if (assets == null) throw new NullPointerException("TitleBarVisualizer requires assets manager... ITS NULL YOU FOOL");
|
||||
|
||||
hvisual = new Visualizer();
|
||||
@ -24,6 +26,10 @@ public class TitleBarVisualizer extends Group implements Disposable {
|
||||
titleImage = new Image(assets.get("title.png", Texture.class));
|
||||
addActor(titleImage);
|
||||
|
||||
background = new TitleBarMesh();
|
||||
background.setHeight((int) (Gdx.graphics.getHeight()*0.2));
|
||||
background.setCam(camera);
|
||||
|
||||
hvisual.setY(getHeight());
|
||||
}
|
||||
|
||||
@ -34,7 +40,7 @@ public class TitleBarVisualizer extends Group implements Disposable {
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
parall.drawParallelogram(getX(), getY(), getWidth(), getHeight(), 30, getColor());
|
||||
background.draw();
|
||||
super.draw(batch, parentAlpha);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package zero1hd.rhythmbullet.graphics.ui.pages;
|
||||
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
@ -15,10 +16,10 @@ public class MainPage extends Page implements OnDifferentSongListener {
|
||||
|
||||
private SongListController sc;
|
||||
private TitleBarVisualizer titleBar;
|
||||
public MainPage(RhythmBullet core, Vector3 targetPosition, SongListController sc) {
|
||||
public MainPage(RhythmBullet core, Vector3 targetPosition, SongListController sc, OrthographicCamera camera) {
|
||||
this.sc = sc;
|
||||
|
||||
titleBar = new TitleBarVisualizer(core.getAssetManager());
|
||||
titleBar = new TitleBarVisualizer(core.getAssetManager(), camera);
|
||||
addActor(titleBar);
|
||||
|
||||
sc.addOnDifferentSongListener(this);
|
||||
|
@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.ScreenAdapter;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
||||
@ -59,7 +60,7 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
|
||||
|
||||
@Override
|
||||
public void postTransition() {
|
||||
mainPage = new MainPage(core, targetPosition, sc);
|
||||
mainPage = new MainPage(core, targetPosition, sc, (OrthographicCamera) stage.getCamera());
|
||||
mainPage.setPosition(0, 0);
|
||||
stage.addActor(mainPage);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user