v0.9.3: added casts to buffer methods to prevent JDK 9+ issues

This commit is contained in:
Evan Debenham
2021-05-09 17:19:15 -04:00
parent 9412eb81f4
commit ef8750b326
15 changed files with 51 additions and 34 deletions

View File

@@ -23,6 +23,7 @@ package com.watabou.glwrap;
import com.badlogic.gdx.Gdx;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;

View File

@@ -24,6 +24,7 @@ package com.watabou.glwrap;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Pixmap;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;
@@ -108,7 +109,7 @@ public class Texture {
order( ByteOrder.nativeOrder() ).
asIntBuffer();
imageBuffer.put( pixels );
imageBuffer.position( 0 );
((Buffer)imageBuffer).position( 0 );
Gdx.gl.glTexImage2D(
Gdx.gl.GL_TEXTURE_2D,
@@ -130,7 +131,7 @@ public class Texture {
allocateDirect( w * h ).
order( ByteOrder.nativeOrder() );
imageBuffer.put( pixels );
imageBuffer.position( 0 );
((Buffer)imageBuffer).position( 0 );
Gdx.gl.glPixelStorei( Gdx.gl.GL_UNPACK_ALIGNMENT, 1 );

View File

@@ -23,6 +23,7 @@ package com.watabou.glwrap;
import com.badlogic.gdx.Gdx;
import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.util.ArrayList;
@@ -74,7 +75,7 @@ public class Vertexbuffer {
public void updateGLData(){
if (updateStart == -1) return;
vertices.position(updateStart);
((Buffer)vertices).position(updateStart);
bind();
if (updateStart == 0 && updateEnd == vertices.limit()){

View File

@@ -28,6 +28,7 @@ import com.watabou.glwrap.Quad;
import com.watabou.glwrap.Vertexbuffer;
import com.watabou.utils.RectF;
import java.nio.Buffer;
import java.nio.FloatBuffer;
public class BitmapText extends Visual {
@@ -74,7 +75,7 @@ public class BitmapText extends Visual {
if (dirty) {
updateVertices();
quads.limit(quads.position());
((Buffer)quads).limit(quads.position());
if (buffer == null)
buffer = new Vertexbuffer(quads);
else

View File

@@ -27,6 +27,7 @@ import com.watabou.glwrap.Quad;
import com.watabou.glwrap.Vertexbuffer;
import com.watabou.utils.RectF;
import java.nio.Buffer;
import java.nio.FloatBuffer;
public class Image extends Visual {
@@ -156,7 +157,7 @@ public class Image extends Visual {
super.draw();
if (dirty) {
verticesBuffer.position( 0 );
((Buffer)verticesBuffer).position( 0 );
verticesBuffer.put( vertices );
if (buffer == null)
buffer = new Vertexbuffer( verticesBuffer );

View File

@@ -27,6 +27,7 @@ import com.watabou.glwrap.Quad;
import com.watabou.glwrap.Vertexbuffer;
import com.watabou.utils.RectF;
import java.nio.Buffer;
import java.nio.FloatBuffer;
public class NinePatch extends Visual {
@@ -91,7 +92,7 @@ public class NinePatch extends Visual {
protected void updateVertices() {
quads.position( 0 );
((Buffer)quads).position( 0 );
float right = width - marginRight;
float bottom = height - marginBottom;

View File

@@ -28,6 +28,7 @@ import com.watabou.glwrap.Quad;
import com.watabou.glwrap.Uniform;
import com.watabou.glwrap.Vertexbuffer;
import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
@@ -72,11 +73,11 @@ public class NoosaScript extends Script {
}
public void drawElements( FloatBuffer vertices, ShortBuffer indices, int size ) {
vertices.position( 0 );
((Buffer)vertices).position( 0 );
aXY.vertexPointer( 2, 4, vertices );
vertices.position( 2 );
((Buffer)vertices).position( 2 );
aUV.vertexPointer( 2, 4, vertices );
Quad.releaseIndices();
@@ -85,11 +86,11 @@ public class NoosaScript extends Script {
}
public void drawQuad( FloatBuffer vertices ) {
vertices.position( 0 );
((Buffer)vertices).position( 0 );
aXY.vertexPointer( 2, 4, vertices );
vertices.position( 2 );
((Buffer)vertices).position( 2 );
aUV.vertexPointer( 2, 4, vertices );
Gdx.gl20.glDrawElements( Gdx.gl20.GL_TRIANGLES, Quad.SIZE, Gdx.gl20.GL_UNSIGNED_SHORT, 0 );
@@ -114,11 +115,11 @@ public class NoosaScript extends Script {
if (size == 0) {
return;
}
vertices.position( 0 );
((Buffer)vertices).position( 0 );
aXY.vertexPointer( 2, 4, vertices );
vertices.position( 2 );
((Buffer)vertices).position( 2 );
aUV.vertexPointer( 2, 4, vertices );
Gdx.gl20.glDrawElements( Gdx.gl20.GL_TRIANGLES, Quad.SIZE * size, Gdx.gl20.GL_UNSIGNED_SHORT, 0 );

View File

@@ -33,6 +33,7 @@ import com.badlogic.gdx.math.Matrix4;
import com.watabou.glwrap.Matrix;
import com.watabou.glwrap.Quad;
import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.util.HashMap;
@@ -155,7 +156,7 @@ public class RenderedText extends Image {
FloatBuffer toOpenGL;
if (buffers.containsKey(count/20)){
toOpenGL = buffers.get(count/20);
toOpenGL.position(0);
((Buffer)toOpenGL).position(0);
} else {
toOpenGL = Quad.createSet(count / 20);
buffers.put(count/20, toOpenGL);
@@ -190,8 +191,8 @@ public class RenderedText extends Image {
toOpenGL.put(vertices);
}
toOpenGL.position(0);
((Buffer)toOpenGL).position(0);
NoosaScript script = NoosaScript.get();

View File

@@ -28,6 +28,7 @@ import com.watabou.glwrap.Vertexbuffer;
import com.watabou.utils.Rect;
import com.watabou.utils.RectF;
import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.util.Arrays;
@@ -136,7 +137,7 @@ public class Tilemap extends Visual {
bottomRightUpdating = pos + 1;
quads.position(pos*16);
((Buffer)quads).position(pos*16);
uv = tileset.get(data[pos]);