fix compile errors after libgdx 1.0.0 update

This commit is contained in:
Gered 2014-04-26 22:36:13 -04:00
parent 61cdeea7bb
commit ab9c3a1d9a
7 changed files with 21 additions and 41 deletions

View file

@ -6,7 +6,7 @@ apply plugin: "idea"
group = "ca.blarg.gdx" group = "ca.blarg.gdx"
version = "0.1-SNAPSHOT" version = "0.1-SNAPSHOT"
ext.appName = "gdx-toolbox" ext.appName = "gdx-toolbox"
ext.gdxVersion = "0.9.9" ext.gdxVersion = "1.0.0"
sourceCompatibility = 1.6 sourceCompatibility = 1.6

View file

@ -2,7 +2,7 @@ package ca.blarg.gdx;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.GL10; import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.PixmapIO; import com.badlogic.gdx.graphics.PixmapIO;
@ -45,11 +45,11 @@ public class Screenshot {
// kind of partially transparent pixels for screenshot purposes). // kind of partially transparent pixels for screenshot purposes).
private static Pixmap getFrameBufferPixmap(int x, int y, int w, int h, boolean flipY) { private static Pixmap getFrameBufferPixmap(int x, int y, int w, int h, boolean flipY) {
Gdx.gl.glPixelStorei(GL10.GL_PACK_ALIGNMENT, 1); Gdx.gl.glPixelStorei(GL20.GL_PACK_ALIGNMENT, 1);
final Pixmap pixmap = new Pixmap(w, h, Pixmap.Format.RGB888); final Pixmap pixmap = new Pixmap(w, h, Pixmap.Format.RGB888);
ByteBuffer pixels = pixmap.getPixels(); ByteBuffer pixels = pixmap.getPixels();
Gdx.gl.glReadPixels(x, y, w, h, GL10.GL_RGB, GL10.GL_UNSIGNED_BYTE, pixels); Gdx.gl.glReadPixels(x, y, w, h, GL20.GL_RGB, GL20.GL_UNSIGNED_BYTE, pixels);
final int numBytes = w * h * 3; final int numBytes = w * h * 3;
byte[] lines = new byte[numBytes]; byte[] lines = new byte[numBytes];

View file

@ -2,7 +2,7 @@ package ca.blarg.gdx.graphics;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera; import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.GL10; import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g3d.decals.Decal; import com.badlogic.gdx.graphics.g3d.decals.Decal;
import com.badlogic.gdx.graphics.g3d.decals.DecalMaterial; import com.badlogic.gdx.graphics.g3d.decals.DecalMaterial;
import com.badlogic.gdx.graphics.g3d.decals.GroupStrategy; import com.badlogic.gdx.graphics.g3d.decals.GroupStrategy;
@ -91,9 +91,6 @@ public class AlphaTestCameraGroupStrategy implements GroupStrategy, Disposable {
private final Comparator<Decal> cameraSorter; private final Comparator<Decal> cameraSorter;
public AlphaTestCameraGroupStrategy (final Camera camera) { public AlphaTestCameraGroupStrategy (final Camera camera) {
if (!Gdx.graphics.isGL20Available())
throw new UnsupportedOperationException("AlphaTestCameraGroupStrategy requires shader support.");
this.camera = camera; this.camera = camera;
createDefaultShader(); createDefaultShader();
@ -109,9 +106,6 @@ public class AlphaTestCameraGroupStrategy implements GroupStrategy, Disposable {
} }
public AlphaTestCameraGroupStrategy (Camera camera, Comparator<Decal> sorter) { public AlphaTestCameraGroupStrategy (Camera camera, Comparator<Decal> sorter) {
if (!Gdx.graphics.isGL20Available())
throw new UnsupportedOperationException("AlphaTestCameraGroupStrategy requires shader support.");
this.camera = camera; this.camera = camera;
this.cameraSorter = sorter; this.cameraSorter = sorter;
createDefaultShader(); createDefaultShader();
@ -133,7 +127,7 @@ public class AlphaTestCameraGroupStrategy implements GroupStrategy, Disposable {
@Override @Override
public void beforeGroup (int group, Array<Decal> contents) { public void beforeGroup (int group, Array<Decal> contents) {
if (group == GROUP_BLEND) { if (group == GROUP_BLEND) {
Gdx.gl.glEnable(GL10.GL_BLEND); Gdx.gl.glEnable(GL20.GL_BLEND);
contents.sort(cameraSorter); contents.sort(cameraSorter);
} else { } else {
for (int i = 0, n = contents.size; i < n; i++) { for (int i = 0, n = contents.size; i < n; i++) {
@ -162,13 +156,13 @@ public class AlphaTestCameraGroupStrategy implements GroupStrategy, Disposable {
@Override @Override
public void afterGroup (int group) { public void afterGroup (int group) {
if (group == GROUP_BLEND) { if (group == GROUP_BLEND) {
Gdx.gl.glDisable(GL10.GL_BLEND); Gdx.gl.glDisable(GL20.GL_BLEND);
} }
} }
@Override @Override
public void beforeGroups () { public void beforeGroups () {
Gdx.gl.glEnable(GL10.GL_DEPTH_TEST); Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);
shader.begin(); shader.begin();
shader.setUniformMatrix("u_projectionViewMatrix", camera.combined); shader.setUniformMatrix("u_projectionViewMatrix", camera.combined);
shader.setUniformi("u_texture", 0); shader.setUniformi("u_texture", 0);
@ -177,8 +171,8 @@ public class AlphaTestCameraGroupStrategy implements GroupStrategy, Disposable {
@Override @Override
public void afterGroups () { public void afterGroups () {
shader.end(); shader.end();
Gdx.gl.glDisable(GL10.GL_TEXTURE_2D); Gdx.gl.glDisable(GL20.GL_TEXTURE_2D);
Gdx.gl.glDisable(GL10.GL_DEPTH_TEST); Gdx.gl.glDisable(GL20.GL_DEPTH_TEST);
} }
private void createDefaultShader () { private void createDefaultShader () {

View file

@ -2,13 +2,12 @@ package ca.blarg.gdx.graphics;
import com.badlogic.gdx.graphics.Camera; import com.badlogic.gdx.graphics.Camera;
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.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.g3d.decals.Decal; import com.badlogic.gdx.graphics.g3d.decals.Decal;
import com.badlogic.gdx.graphics.g3d.decals.DecalBatch; import com.badlogic.gdx.graphics.g3d.decals.DecalBatch;
import com.badlogic.gdx.graphics.g3d.decals.DecalMaterial; import com.badlogic.gdx.graphics.g3d.decals.DecalMaterial;
import com.badlogic.gdx.graphics.g3d.decals.GroupStrategy;
import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Disposable; import com.badlogic.gdx.utils.Disposable;
@ -199,8 +198,8 @@ public class BillboardSpriteBatch implements Disposable {
int destFactor = DecalMaterial.NO_BLEND; int destFactor = DecalMaterial.NO_BLEND;
if (tint.a > 0.0f && tint.a < 1.0f) { if (tint.a > 0.0f && tint.a < 1.0f) {
srcFactor = GL10.GL_SRC_ALPHA; srcFactor = GL20.GL_SRC_ALPHA;
destFactor = GL10.GL_ONE_MINUS_SRC_ALPHA; destFactor = GL20.GL_ONE_MINUS_SRC_ALPHA;
} }
decal.setColor(tint); decal.setColor(tint);

View file

@ -4,16 +4,14 @@ import ca.blarg.gdx.graphics.shaders.DebugShader;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera; import com.badlogic.gdx.graphics.Camera;
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.glutils.ImmediateModeRenderer; import com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer;
import com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer10;
import com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20; import com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20;
import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.math.collision.BoundingBox; import com.badlogic.gdx.math.collision.BoundingBox;
import com.badlogic.gdx.math.collision.Ray; import com.badlogic.gdx.math.collision.Ray;
import com.badlogic.gdx.math.collision.Segment; import com.badlogic.gdx.math.collision.Segment;
import com.badlogic.gdx.math.collision.Sphere; import com.badlogic.gdx.math.collision.Sphere;
import ca.blarg.gdx.graphics.shaders.DebugShader;
/** /**
* Similar idea to {@link com.badlogic.gdx.graphics.glutils.ShapeRenderer}, but provides more convenient methods to * Similar idea to {@link com.badlogic.gdx.graphics.glutils.ShapeRenderer}, but provides more convenient methods to
@ -35,10 +33,7 @@ public class DebugGeometryRenderer {
boolean oldDepthTestEnabled; boolean oldDepthTestEnabled;
public DebugGeometryRenderer() { public DebugGeometryRenderer() {
if (Gdx.graphics.isGL20Available()) renderer = new ImmediateModeRenderer20(5000, false, true, 0, new DebugShader());
renderer = new ImmediateModeRenderer20(5000, false, true, 0, new DebugShader());
else
renderer = new ImmediateModeRenderer10();
} }
private void vtx(Vector3 v, Color c) { private void vtx(Vector3 v, Color c) {
@ -53,9 +48,9 @@ public class DebugGeometryRenderer {
private void enableDepthTest(boolean enable) { private void enableDepthTest(boolean enable) {
if (enable) if (enable)
Gdx.gl.glEnable(GL10.GL_DEPTH_TEST); Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);
else else
Gdx.gl.glDisable(GL10.GL_DEPTH_TEST); Gdx.gl.glDisable(GL20.GL_DEPTH_TEST);
} }
public void begin(Camera camera) { public void begin(Camera camera) {
@ -63,9 +58,9 @@ public class DebugGeometryRenderer {
} }
public void begin(Camera camera, boolean enableDepthTest) { public void begin(Camera camera, boolean enableDepthTest) {
renderer.begin(camera.combined, GL10.GL_LINES); renderer.begin(camera.combined, GL20.GL_LINES);
oldDepthTestEnabled = Gdx.gl20.glIsEnabled(GL10.GL_DEPTH_TEST); oldDepthTestEnabled = Gdx.gl20.glIsEnabled(GL20.GL_DEPTH_TEST);
enableDepthTest(enableDepthTest); enableDepthTest(enableDepthTest);
Gdx.gl20.glLineWidth(2.0f); Gdx.gl20.glLineWidth(2.0f);
} }

View file

@ -37,14 +37,6 @@ public class ExtendedSpriteBatch extends SpriteBatch {
super(size, defaultShader); super(size, defaultShader);
} }
public ExtendedSpriteBatch(int size, int buffers) {
super(size, buffers);
}
public ExtendedSpriteBatch(int size, int buffers, ShaderProgram defaultShader) {
super(size, buffers, defaultShader);
}
public void setPixelScale(int pixelScale) { public void setPixelScale(int pixelScale) {
if (pixelScale <= 0) if (pixelScale <= 0)
throw new IllegalArgumentException(); throw new IllegalArgumentException();

View file

@ -79,9 +79,9 @@ public final class GraphicsHelpers {
* restored (any Pixmap's drawn to it will need to be redrawn after the context restore). * restored (any Pixmap's drawn to it will need to be redrawn after the context restore).
*/ */
public static void drawToTexture (Texture destTexture, Pixmap srcPixmap, int x, int y) { public static void drawToTexture (Texture destTexture, Pixmap srcPixmap, int x, int y) {
Gdx.gl.glBindTexture(GL10.GL_TEXTURE_2D, destTexture.getTextureObjectHandle()); Gdx.gl.glBindTexture(GL20.GL_TEXTURE_2D, destTexture.getTextureObjectHandle());
Gdx.gl.glTexSubImage2D( Gdx.gl.glTexSubImage2D(
GL10.GL_TEXTURE_2D, 0, GL20.GL_TEXTURE_2D, 0,
x, y, x, y,
srcPixmap.getWidth(), srcPixmap.getHeight(), srcPixmap.getWidth(), srcPixmap.getHeight(),
srcPixmap.getGLFormat(), srcPixmap.getGLFormat(),