Fix compile issues with upgrade to libgdx 1.2.0

This commit is contained in:
drdev
2014-06-22 21:50:29 +00:00
parent 4f4118daf4
commit 8bcee9762d
4 changed files with 31 additions and 31 deletions

View File

@@ -41,6 +41,6 @@ public class Main extends AndroidApplication {
//ensure process doesn't stick around after exiting //ensure process doesn't stick around after exiting
android.os.Process.killProcess(android.os.Process.myPid()); android.os.Process.killProcess(android.os.Process.myPid());
} }
}), true); }));
} }
} }

View File

@@ -9,6 +9,6 @@ import forge.util.Utils;
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
new LwjglApplication(Forge.getApp(new LwjglClipboard(), "../forge-gui/", null), new LwjglApplication(Forge.getApp(new LwjglClipboard(), "../forge-gui/", null),
"Forge", (int)Utils.BASE_WIDTH, (int)Utils.BASE_HEIGHT, true); "Forge", (int)Utils.BASE_WIDTH, (int)Utils.BASE_HEIGHT);
} }
} }

View File

@@ -64,8 +64,6 @@ public class Forge implements ApplicationListener {
//install our error handler //install our error handler
ExceptionHandler.registerErrorHandling(); ExceptionHandler.registerErrorHandling();
Texture.setEnforcePotImages(false); //ensure image dimensions don't have to be powers of 2
graphics = new Graphics(); graphics = new Graphics();
splashScreen = new SplashScreen(); splashScreen = new SplashScreen();

View File

@@ -2,7 +2,6 @@ package forge;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
@@ -22,6 +21,9 @@ import forge.toolbox.FDisplayObject;
import forge.util.Utils; import forge.util.Utils;
public class Graphics { public class Graphics {
private static final int GL_BLEND = GL20.GL_BLEND;
private static final int GL_LINE_SMOOTH = 2848; //create constant here since not in GL20
private final SpriteBatch batch = new SpriteBatch(); private final SpriteBatch batch = new SpriteBatch();
private final ShapeRenderer shapeRenderer = new ShapeRenderer(); private final ShapeRenderer shapeRenderer = new ShapeRenderer();
private float regionHeight; private float regionHeight;
@@ -105,10 +107,10 @@ public class Graphics {
} }
boolean needSmoothing = (x1 != x2 && y1 != y2); boolean needSmoothing = (x1 != x2 && y1 != y2);
if (color.a < 1 || needSmoothing) { //enable blending so alpha colored shapes work properly if (color.a < 1 || needSmoothing) { //enable blending so alpha colored shapes work properly
Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glEnable(GL_BLEND);
} }
if (needSmoothing) { if (needSmoothing) {
Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH); Gdx.gl.glEnable(GL_LINE_SMOOTH);
} }
startShape(ShapeType.Line); startShape(ShapeType.Line);
@@ -117,10 +119,10 @@ public class Graphics {
endShape(); endShape();
if (needSmoothing) { if (needSmoothing) {
Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH); Gdx.gl.glDisable(GL_LINE_SMOOTH);
} }
if (color.a < 1 || needSmoothing) { if (color.a < 1 || needSmoothing) {
Gdx.gl.glDisable(GL20.GL_BLEND); Gdx.gl.glDisable(GL_BLEND);
} }
if (thickness > 1) { if (thickness > 1) {
Gdx.gl.glLineWidth(1); Gdx.gl.glLineWidth(1);
@@ -142,10 +144,10 @@ public class Graphics {
color = FSkinColor.alphaColor(color, color.a * alphaComposite); color = FSkinColor.alphaColor(color, color.a * alphaComposite);
} }
if (color.a < 1 || cornerRadius > 0) { //enable blending so alpha colored shapes work properly if (color.a < 1 || cornerRadius > 0) { //enable blending so alpha colored shapes work properly
Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glEnable(GL_BLEND);
} }
if (cornerRadius > 0) { if (cornerRadius > 0) {
Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH); Gdx.gl.glEnable(GL_LINE_SMOOTH);
} }
//adjust width/height so rectangle covers equivalent filled area //adjust width/height so rectangle covers equivalent filled area
@@ -168,10 +170,10 @@ public class Graphics {
endShape(); endShape();
if (cornerRadius > 0) { if (cornerRadius > 0) {
Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH); Gdx.gl.glDisable(GL_LINE_SMOOTH);
} }
if (color.a < 1 || cornerRadius > 0) { if (color.a < 1 || cornerRadius > 0) {
Gdx.gl.glDisable(GL20.GL_BLEND); Gdx.gl.glDisable(GL_BLEND);
} }
if (thickness > 1) { if (thickness > 1) {
Gdx.gl.glLineWidth(1); Gdx.gl.glLineWidth(1);
@@ -192,16 +194,16 @@ public class Graphics {
if (alphaComposite < 1) { if (alphaComposite < 1) {
color = FSkinColor.alphaColor(color, color.a * alphaComposite); color = FSkinColor.alphaColor(color, color.a * alphaComposite);
} }
Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glEnable(GL_BLEND);
Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH); //must be smooth to ensure edges aren't missed Gdx.gl.glEnable(GL_LINE_SMOOTH); //must be smooth to ensure edges aren't missed
startShape(ShapeType.Line); startShape(ShapeType.Line);
shapeRenderer.setColor(color); shapeRenderer.setColor(color);
shapeRenderer.rect(adjustX(x), adjustY(y, h), w, h); shapeRenderer.rect(adjustX(x), adjustY(y, h), w, h);
endShape(); endShape();
Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH); Gdx.gl.glDisable(GL_LINE_SMOOTH);
Gdx.gl.glDisable(GL20.GL_BLEND); Gdx.gl.glDisable(GL_BLEND);
if (thickness > 1) { if (thickness > 1) {
Gdx.gl.glLineWidth(1); Gdx.gl.glLineWidth(1);
} }
@@ -219,7 +221,7 @@ public class Graphics {
color = FSkinColor.alphaColor(color, color.a * alphaComposite); color = FSkinColor.alphaColor(color, color.a * alphaComposite);
} }
if (color.a < 1) { //enable blending so alpha colored shapes work properly if (color.a < 1) { //enable blending so alpha colored shapes work properly
Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glEnable(GL_BLEND);
} }
startShape(ShapeType.Filled); startShape(ShapeType.Filled);
@@ -228,7 +230,7 @@ public class Graphics {
endShape(); endShape();
if (color.a < 1) { if (color.a < 1) {
Gdx.gl.glDisable(GL20.GL_BLEND); Gdx.gl.glDisable(GL_BLEND);
} }
batch.begin(); batch.begin();
@@ -246,16 +248,16 @@ public class Graphics {
if (alphaComposite < 1) { if (alphaComposite < 1) {
color = FSkinColor.alphaColor(color, color.a * alphaComposite); color = FSkinColor.alphaColor(color, color.a * alphaComposite);
} }
Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glEnable(GL_BLEND);
Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH); Gdx.gl.glEnable(GL_LINE_SMOOTH);
startShape(ShapeType.Line); startShape(ShapeType.Line);
shapeRenderer.setColor(color); shapeRenderer.setColor(color);
shapeRenderer.circle(adjustX(x), adjustY(y, 0), radius); shapeRenderer.circle(adjustX(x), adjustY(y, 0), radius);
endShape(); endShape();
Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH); Gdx.gl.glDisable(GL_LINE_SMOOTH);
Gdx.gl.glDisable(GL20.GL_BLEND); Gdx.gl.glDisable(GL_BLEND);
if (thickness > 1) { if (thickness > 1) {
Gdx.gl.glLineWidth(1); Gdx.gl.glLineWidth(1);
} }
@@ -273,7 +275,7 @@ public class Graphics {
color = FSkinColor.alphaColor(color, color.a * alphaComposite); color = FSkinColor.alphaColor(color, color.a * alphaComposite);
} }
if (color.a < 1) { //enable blending so alpha colored shapes work properly if (color.a < 1) { //enable blending so alpha colored shapes work properly
Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glEnable(GL_BLEND);
} }
startShape(ShapeType.Filled); startShape(ShapeType.Filled);
@@ -282,7 +284,7 @@ public class Graphics {
endShape(); endShape();
if (color.a < 1) { if (color.a < 1) {
Gdx.gl.glDisable(GL20.GL_BLEND); Gdx.gl.glDisable(GL_BLEND);
} }
batch.begin(); batch.begin();
@@ -298,7 +300,7 @@ public class Graphics {
color = FSkinColor.alphaColor(color, color.a * alphaComposite); color = FSkinColor.alphaColor(color, color.a * alphaComposite);
} }
if (color.a < 1) { //enable blending so alpha colored shapes work properly if (color.a < 1) { //enable blending so alpha colored shapes work properly
Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glEnable(GL_BLEND);
} }
startShape(ShapeType.Filled); startShape(ShapeType.Filled);
@@ -307,7 +309,7 @@ public class Graphics {
endShape(); endShape();
if (color.a < 1) { if (color.a < 1) {
Gdx.gl.glDisable(GL20.GL_BLEND); Gdx.gl.glDisable(GL_BLEND);
} }
batch.begin(); batch.begin();
@@ -331,7 +333,7 @@ public class Graphics {
} }
boolean needBlending = (color1.a < 1 || color2.a < 1); boolean needBlending = (color1.a < 1 || color2.a < 1);
if (needBlending) { //enable blending so alpha colored shapes work properly if (needBlending) { //enable blending so alpha colored shapes work properly
Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glEnable(GL_BLEND);
} }
Color topLeftColor = color1; Color topLeftColor = color1;
@@ -344,7 +346,7 @@ public class Graphics {
endShape(); endShape();
if (needBlending) { if (needBlending) {
Gdx.gl.glDisable(GL20.GL_BLEND); Gdx.gl.glDisable(GL_BLEND);
} }
batch.begin(); batch.begin();
@@ -430,7 +432,7 @@ public class Graphics {
color = FSkinColor.alphaColor(color, color.a * alphaComposite); color = FSkinColor.alphaColor(color, color.a * alphaComposite);
} }
if (color.a < 1) { //enable blending so alpha colored shapes work properly if (color.a < 1) { //enable blending so alpha colored shapes work properly
Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glEnable(GL_BLEND);
} }
TextBounds textBounds; TextBounds textBounds;
@@ -475,7 +477,7 @@ public class Graphics {
} }
if (color.a < 1) { if (color.a < 1) {
Gdx.gl.glDisable(GL20.GL_BLEND); Gdx.gl.glDisable(GL_BLEND);
} }
} }