From ce87e89b4f306e755e49ecfb09085941e2a58148 Mon Sep 17 00:00:00 2001 From: Gustl22 Date: Sat, 26 Jan 2019 21:07:09 +0100 Subject: [PATCH] Complete GL20 interface (#642) --- vtm-android-example/build.gradle | 1 - vtm-android-gdx/build.gradle | 1 + .../src/org/oscim/gdx/AndroidGL.java | 126 ++++++++++++++--- .../src/org/oscim/android/gl/AndroidGL.java | 107 ++++++++++++++- vtm-desktop/src/org/oscim/gdx/LwjglGL20.java | 41 +++++- vtm-ios/src/org/oscim/ios/backend/IosGL.java | 104 +++++++++++++- vtm-web/src/org/oscim/gdx/client/GdxGL.java | 128 ++++++++++++++++-- vtm/src/org/oscim/backend/GL.java | 41 +++++- 8 files changed, 496 insertions(+), 53 deletions(-) diff --git a/vtm-android-example/build.gradle b/vtm-android-example/build.gradle index 616dc592..1a7f9686 100644 --- a/vtm-android-example/build.gradle +++ b/vtm-android-example/build.gradle @@ -20,7 +20,6 @@ dependencies { implementation project(':vtm-android-gdx') implementation project(':vtm-gdx') implementation project(':vtm-gdx-poi3d') - implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion" implementation 'org.mapsforge:mapsforge-poi-android:master-SNAPSHOT' implementation 'org.mapsforge:sqlite-android:master-SNAPSHOT:natives-armeabi-v7a' diff --git a/vtm-android-gdx/build.gradle b/vtm-android-gdx/build.gradle index 4f906c25..364dd5a1 100644 --- a/vtm-android-gdx/build.gradle +++ b/vtm-android-gdx/build.gradle @@ -3,6 +3,7 @@ apply plugin: 'com.github.dcendents.android-maven' dependencies { api project(':vtm') + api "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion" } android { diff --git a/vtm-android-gdx/src/org/oscim/gdx/AndroidGL.java b/vtm-android-gdx/src/org/oscim/gdx/AndroidGL.java index ff7c0070..ac7f3a83 100644 --- a/vtm-android-gdx/src/org/oscim/gdx/AndroidGL.java +++ b/vtm-android-gdx/src/org/oscim/gdx/AndroidGL.java @@ -1,5 +1,6 @@ /* * Copyright 2013 Hannes Janetzek + * Copyright 2019 Gustl22 * * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * @@ -19,6 +20,8 @@ package org.oscim.gdx; import android.annotation.SuppressLint; import android.opengl.GLES20; +import com.badlogic.gdx.backends.android.AndroidGL20; + import org.oscim.backend.GL; import java.nio.Buffer; @@ -28,6 +31,8 @@ import java.nio.IntBuffer; @SuppressLint("NewApi") public class AndroidGL implements GL { + private static final AndroidGL20 androidGL = new AndroidGL20(); + @Override public void attachShader(int program, int shader) { GLES20.glAttachShader(program, shader); @@ -103,11 +108,21 @@ public class AndroidGL implements GL { return GLES20.glCreateShader(type); } + @Override + public void deleteBuffer(int buffer) { + androidGL.glDeleteBuffer(buffer); + } + @Override public void deleteBuffers(int n, IntBuffer buffers) { GLES20.glDeleteBuffers(n, buffers); } + @Override + public void deleteFramebuffer(int framebuffer) { + androidGL.glDeleteFramebuffer(framebuffer); + } + @Override public void deleteFramebuffers(int n, IntBuffer framebuffers) { GLES20.glDeleteFramebuffers(n, framebuffers); @@ -118,6 +133,11 @@ public class AndroidGL implements GL { GLES20.glDeleteProgram(program); } + @Override + public void deleteRenderbuffer(int renderbuffer) { + androidGL.glDeleteRenderbuffer(renderbuffer); + } + @Override public void deleteRenderbuffers(int n, IntBuffer renderbuffers) { GLES20.glDeleteRenderbuffers(n, renderbuffers); @@ -160,6 +180,11 @@ public class AndroidGL implements GL { GLES20.glFramebufferTexture2D(target, attachment, textarget, texture, level); } + @Override + public int genBuffer() { + return androidGL.glGenBuffer(); + } + @Override public void genBuffers(int n, IntBuffer buffers) { GLES20.glGenBuffers(n, buffers); @@ -170,11 +195,21 @@ public class AndroidGL implements GL { GLES20.glGenerateMipmap(target); } + @Override + public int genFramebuffer() { + return androidGL.glGenFramebuffer(); + } + @Override public void genFramebuffers(int n, IntBuffer framebuffers) { GLES20.glGenFramebuffers(n, framebuffers); } + @Override + public int genRenderbuffer() { + return androidGL.glGenRenderbuffer(); + } + @Override public void genRenderbuffers(int n, IntBuffer renderbuffers) { GLES20.glGenRenderbuffers(n, renderbuffers); @@ -187,14 +222,12 @@ public class AndroidGL implements GL { @Override public String getActiveUniform(int program, int index, IntBuffer size, Buffer type) { - //return GLES20.glGetActiveUniform(program, index, bufsize, length, size, type, name); - throw new UnsupportedOperationException("missing implementation"); + return androidGL.glGetActiveUniform(program, index, size, type); } @Override public void getAttachedShaders(int program, int maxcount, Buffer count, IntBuffer shaders) { - throw new UnsupportedOperationException("missing implementation"); - //GLES20.glGetAttachedShaders(program, maxcount, count, shaders); + androidGL.glGetAttachedShaders(program, maxcount, count, shaders); } @Override @@ -204,8 +237,7 @@ public class AndroidGL implements GL { @Override public void getBooleanv(int pname, Buffer params) { - throw new UnsupportedOperationException("missing implementation"); - //GLES20.glGetBooleanv(pname, params); + androidGL.glGetBooleanv(pname, params); } @Override @@ -260,11 +292,6 @@ public class AndroidGL implements GL { GLES20.glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision); } - @Override - public void getShaderSource(int shader, int bufsize, Buffer length, String source) { - throw new UnsupportedOperationException("missing implementation"); - } - @Override public void getTexParameterfv(int target, int pname, FloatBuffer params) { GLES20.glGetTexParameterfv(target, pname, params); @@ -308,8 +335,7 @@ public class AndroidGL implements GL { @Override public void getVertexAttribPointerv(int index, int pname, Buffer pointer) { - //GLES20.glGetVertexAttribPointerv(index, pname, pointer); - throw new UnsupportedOperationException("missing implementation"); + androidGL.glGetVertexAttribPointerv(index, pname, pointer); } @Override @@ -431,6 +457,11 @@ public class AndroidGL implements GL { } + @Override + public void uniform1fv(int location, int count, float[] v, int offset) { + GLES20.glUniform1fv(location, count, v, offset); + } + @Override public void uniform1i(int location, int x) { GLES20.glUniform1i(location, x); @@ -443,6 +474,11 @@ public class AndroidGL implements GL { } + @Override + public void uniform1iv(int location, int count, int[] v, int offset) { + GLES20.glUniform1iv(location, count, v, offset); + } + @Override public void uniform2f(int location, float x, float y) { GLES20.glUniform2f(location, x, y); @@ -455,6 +491,11 @@ public class AndroidGL implements GL { } + @Override + public void uniform2fv(int location, int count, float[] v, int offset) { + GLES20.glUniform2fv(location, count, v, offset); + } + @Override public void uniform2i(int location, int x, int y) { GLES20.glUniform2i(location, x, y); @@ -467,6 +508,11 @@ public class AndroidGL implements GL { } + @Override + public void uniform2iv(int location, int count, int[] v, int offset) { + GLES20.glUniform2iv(location, count, v, offset); + } + @Override public void uniform3f(int location, float x, float y, float z) { GLES20.glUniform3f(location, x, y, z); @@ -479,6 +525,11 @@ public class AndroidGL implements GL { } + @Override + public void uniform3fv(int location, int count, float[] v, int offset) { + GLES20.glUniform3fv(location, count, v, offset); + } + @Override public void uniform3i(int location, int x, int y, int z) { GLES20.glUniform3i(location, x, y, z); @@ -491,6 +542,11 @@ public class AndroidGL implements GL { } + @Override + public void uniform3iv(int location, int count, int[] v, int offset) { + GLES20.glUniform3iv(location, count, v, offset); + } + @Override public void uniform4f(int location, float x, float y, float z, float w) { GLES20.glUniform4f(location, x, y, z, w); @@ -501,6 +557,11 @@ public class AndroidGL implements GL { GLES20.glUniform4fv(location, count, v); } + @Override + public void uniform4fv(int location, int count, float[] v, int offset) { + GLES20.glUniform4fv(location, count, v, offset); + } + @Override public void uniform4i(int location, int x, int y, int z, int w) { GLES20.glUniform4i(location, x, y, z, w); @@ -513,24 +574,44 @@ public class AndroidGL implements GL { } + @Override + public void uniform4iv(int location, int count, int[] v, int offset) { + GLES20.glUniform4iv(location, count, v, offset); + } + @Override public void uniformMatrix2fv(int location, int count, boolean transpose, FloatBuffer value) { GLES20.glUniformMatrix2fv(location, count, transpose, value); } + @Override + public void uniformMatrix2fv(int location, int count, boolean transpose, float[] value, int offset) { + GLES20.glUniformMatrix2fv(location, count, transpose, value, offset); + } + @Override public void uniformMatrix3fv(int location, int count, boolean transpose, FloatBuffer value) { GLES20.glUniformMatrix3fv(location, count, transpose, value); } + @Override + public void uniformMatrix3fv(int location, int count, boolean transpose, float[] value, int offset) { + GLES20.glUniformMatrix3fv(location, count, transpose, value, offset); + } + @Override public void uniformMatrix4fv(int location, int count, boolean transpose, FloatBuffer value) { GLES20.glUniformMatrix4fv(location, count, transpose, value); } + @Override + public void uniformMatrix4fv(int location, int count, boolean transpose, float[] value, int offset) { + GLES20.glUniformMatrix4fv(location, count, transpose, value, offset); + } + @Override public void useProgram(int program) { GLES20.glUseProgram(program); @@ -656,15 +737,13 @@ public class AndroidGL implements GL { @Override public void compressedTexImage2D(int target, int level, int internalformat, int width, int height, int border, int imageSize, Buffer data) { - throw new UnsupportedOperationException("missing implementation"); - + androidGL.glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); } @Override public void compressedTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int imageSize, Buffer data) { - throw new UnsupportedOperationException("missing implementation"); - + androidGL.glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); } @Override @@ -691,6 +770,11 @@ public class AndroidGL implements GL { } + @Override + public void deleteTexture(int texture) { + androidGL.glDeleteTexture(texture); + } + @Override public void depthFunc(int func) { GLES20.glDepthFunc(func); @@ -757,6 +841,11 @@ public class AndroidGL implements GL { } + @Override + public int genTexture() { + return androidGL.glGenTexture(); + } + @Override public int getError() { return GLES20.glGetError(); @@ -837,8 +926,7 @@ public class AndroidGL implements GL { @Override public void texSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int type, Buffer pixels) { - GLES20 - .glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + GLES20.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); } diff --git a/vtm-android/src/org/oscim/android/gl/AndroidGL.java b/vtm-android/src/org/oscim/android/gl/AndroidGL.java index 0fee0650..b6b23739 100644 --- a/vtm-android/src/org/oscim/android/gl/AndroidGL.java +++ b/vtm-android/src/org/oscim/android/gl/AndroidGL.java @@ -1,5 +1,6 @@ /* * Copyright 2013 Hannes Janetzek + * Copyright 2019 Gustl22 * * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * @@ -25,6 +26,9 @@ import java.nio.Buffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; +/** + * TODO Unimplemented methods: https://github.com/libgdx/libgdx/blob/master/gdx/jni/android/AndroidGL20.cpp + */ @SuppressLint("NewApi") public class AndroidGL implements GL { @@ -103,11 +107,21 @@ public class AndroidGL implements GL { return GLES20.glCreateShader(type); } + @Override + public void deleteBuffer(int buffer) { + throw new UnsupportedOperationException("missing implementation"); + } + @Override public void deleteBuffers(int n, IntBuffer buffers) { GLES20.glDeleteBuffers(n, buffers); } + @Override + public void deleteFramebuffer(int framebuffer) { + throw new UnsupportedOperationException("missing implementation"); + } + @Override public void deleteFramebuffers(int n, IntBuffer framebuffers) { GLES20.glDeleteFramebuffers(n, framebuffers); @@ -118,6 +132,11 @@ public class AndroidGL implements GL { GLES20.glDeleteProgram(program); } + @Override + public void deleteRenderbuffer(int renderbuffer) { + throw new UnsupportedOperationException("missing implementation"); + } + @Override public void deleteRenderbuffers(int n, IntBuffer renderbuffers) { GLES20.glDeleteRenderbuffers(n, renderbuffers); @@ -160,6 +179,11 @@ public class AndroidGL implements GL { GLES20.glFramebufferTexture2D(target, attachment, textarget, texture, level); } + @Override + public int genBuffer() { + throw new UnsupportedOperationException("missing implementation"); + } + @Override public void genBuffers(int n, IntBuffer buffers) { GLES20.glGenBuffers(n, buffers); @@ -170,11 +194,21 @@ public class AndroidGL implements GL { GLES20.glGenerateMipmap(target); } + @Override + public int genFramebuffer() { + throw new UnsupportedOperationException("missing implementation"); + } + @Override public void genFramebuffers(int n, IntBuffer framebuffers) { GLES20.glGenFramebuffers(n, framebuffers); } + @Override + public int genRenderbuffer() { + throw new UnsupportedOperationException("missing implementation"); + } + @Override public void genRenderbuffers(int n, IntBuffer renderbuffers) { GLES20.glGenRenderbuffers(n, renderbuffers); @@ -260,11 +294,6 @@ public class AndroidGL implements GL { GLES20.glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision); } - @Override - public void getShaderSource(int shader, int bufsize, Buffer length, String source) { - throw new UnsupportedOperationException("missing implementation"); - } - @Override public void getTexParameterfv(int target, int pname, FloatBuffer params) { GLES20.glGetTexParameterfv(target, pname, params); @@ -431,6 +460,11 @@ public class AndroidGL implements GL { } + @Override + public void uniform1fv(int location, int count, float[] v, int offset) { + GLES20.glUniform1fv(location, count, v, offset); + } + @Override public void uniform1i(int location, int x) { GLES20.glUniform1i(location, x); @@ -443,6 +477,11 @@ public class AndroidGL implements GL { } + @Override + public void uniform1iv(int location, int count, int[] v, int offset) { + GLES20.glUniform1iv(location, count, v, offset); + } + @Override public void uniform2f(int location, float x, float y) { GLES20.glUniform2f(location, x, y); @@ -455,6 +494,11 @@ public class AndroidGL implements GL { } + @Override + public void uniform2fv(int location, int count, float[] v, int offset) { + GLES20.glUniform2fv(location, count, v, offset); + } + @Override public void uniform2i(int location, int x, int y) { GLES20.glUniform2i(location, x, y); @@ -467,6 +511,11 @@ public class AndroidGL implements GL { } + @Override + public void uniform2iv(int location, int count, int[] v, int offset) { + GLES20.glUniform2iv(location, count, v, offset); + } + @Override public void uniform3f(int location, float x, float y, float z) { GLES20.glUniform3f(location, x, y, z); @@ -479,6 +528,11 @@ public class AndroidGL implements GL { } + @Override + public void uniform3fv(int location, int count, float[] v, int offset) { + GLES20.glUniform3fv(location, count, v, offset); + } + @Override public void uniform3i(int location, int x, int y, int z) { GLES20.glUniform3i(location, x, y, z); @@ -491,6 +545,11 @@ public class AndroidGL implements GL { } + @Override + public void uniform3iv(int location, int count, int[] v, int offset) { + GLES20.glUniform3iv(location, count, v, offset); + } + @Override public void uniform4f(int location, float x, float y, float z, float w) { GLES20.glUniform4f(location, x, y, z, w); @@ -501,6 +560,11 @@ public class AndroidGL implements GL { GLES20.glUniform4fv(location, count, v); } + @Override + public void uniform4fv(int location, int count, float[] v, int offset) { + GLES20.glUniform4fv(location, count, v, offset); + } + @Override public void uniform4i(int location, int x, int y, int z, int w) { GLES20.glUniform4i(location, x, y, z, w); @@ -513,24 +577,44 @@ public class AndroidGL implements GL { } + @Override + public void uniform4iv(int location, int count, int[] v, int offset) { + GLES20.glUniform4iv(location, count, v, offset); + } + @Override public void uniformMatrix2fv(int location, int count, boolean transpose, FloatBuffer value) { GLES20.glUniformMatrix2fv(location, count, transpose, value); } + @Override + public void uniformMatrix2fv(int location, int count, boolean transpose, float[] value, int offset) { + GLES20.glUniformMatrix2fv(location, count, transpose, value, offset); + } + @Override public void uniformMatrix3fv(int location, int count, boolean transpose, FloatBuffer value) { GLES20.glUniformMatrix3fv(location, count, transpose, value); } + @Override + public void uniformMatrix3fv(int location, int count, boolean transpose, float[] value, int offset) { + GLES20.glUniformMatrix3fv(location, count, transpose, value, offset); + } + @Override public void uniformMatrix4fv(int location, int count, boolean transpose, FloatBuffer value) { GLES20.glUniformMatrix4fv(location, count, transpose, value); } + @Override + public void uniformMatrix4fv(int location, int count, boolean transpose, float[] value, int offset) { + GLES20.glUniformMatrix4fv(location, count, transpose, value, offset); + } + @Override public void useProgram(int program) { GLES20.glUseProgram(program); @@ -691,6 +775,11 @@ public class AndroidGL implements GL { } + @Override + public void deleteTexture(int texture) { + throw new UnsupportedOperationException("missing implementation"); + } + @Override public void depthFunc(int func) { GLES20.glDepthFunc(func); @@ -757,6 +846,11 @@ public class AndroidGL implements GL { } + @Override + public int genTexture() { + throw new UnsupportedOperationException("missing implementation"); + } + @Override public int getError() { return GLES20.glGetError(); @@ -837,8 +931,7 @@ public class AndroidGL implements GL { @Override public void texSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int type, Buffer pixels) { - GLES20 - .glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + GLES20.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); } diff --git a/vtm-desktop/src/org/oscim/gdx/LwjglGL20.java b/vtm-desktop/src/org/oscim/gdx/LwjglGL20.java index 03eaee0c..e11fddce 100644 --- a/vtm-desktop/src/org/oscim/gdx/LwjglGL20.java +++ b/vtm-desktop/src/org/oscim/gdx/LwjglGL20.java @@ -1,3 +1,19 @@ +/* + * Copyright 2016 devemux86 + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * This program is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ /******************************************************************************* * Copyright 2011 See AUTHORS file. *

@@ -38,6 +54,8 @@ import java.nio.ShortBuffer; /** * An implementation of the {@link GL20} interface based on LWJGL. Note that LWJGL shaders and OpenGL ES shaders will not be 100% * compatible. Some glGetXXX methods are not implemented. + *

+ * See https://github.com/libgdx/libgdx/blob/master/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/lwjgl/LwjglGL20.java * * @author mzechner */ @@ -241,6 +259,7 @@ public class LwjglGL20 implements GL { GL15.glDeleteBuffers(buffers); } + @Override public void deleteBuffer(int buffer) { GL15.glDeleteBuffers(buffer); } @@ -250,6 +269,7 @@ public class LwjglGL20 implements GL { EXTFramebufferObject.glDeleteFramebuffersEXT(framebuffers); } + @Override public void deleteFramebuffer(int framebuffer) { EXTFramebufferObject.glDeleteFramebuffersEXT(framebuffer); } @@ -264,6 +284,7 @@ public class LwjglGL20 implements GL { EXTFramebufferObject.glDeleteRenderbuffersEXT(renderbuffers); } + @Override public void deleteRenderbuffer(int renderbuffer) { EXTFramebufferObject.glDeleteRenderbuffersEXT(renderbuffer); } @@ -278,6 +299,7 @@ public class LwjglGL20 implements GL { GL11.glDeleteTextures(textures); } + @Override public void deleteTexture(int texture) { GL11.glDeleteTextures(texture); } @@ -370,6 +392,7 @@ public class LwjglGL20 implements GL { GL15.glGenBuffers(buffers); } + @Override public int genBuffer() { return GL15.glGenBuffers(); } @@ -379,6 +402,7 @@ public class LwjglGL20 implements GL { EXTFramebufferObject.glGenFramebuffersEXT(framebuffers); } + @Override public int genFramebuffer() { return EXTFramebufferObject.glGenFramebuffersEXT(); } @@ -388,6 +412,7 @@ public class LwjglGL20 implements GL { EXTFramebufferObject.glGenRenderbuffersEXT(renderbuffers); } + @Override public int genRenderbuffer() { return EXTFramebufferObject.glGenRenderbuffersEXT(); } @@ -397,6 +422,7 @@ public class LwjglGL20 implements GL { GL11.glGenTextures(textures); } + @Override public int genTexture() { return GL11.glGenTextures(); } @@ -764,6 +790,7 @@ public class LwjglGL20 implements GL { GL20.glUniform1(location, v); } + @Override public void uniform1fv(int location, int count, float[] v, int offset) { GL20.glUniform1(location, toFloatBuffer(v, offset, count)); } @@ -778,6 +805,7 @@ public class LwjglGL20 implements GL { GL20.glUniform1(location, v); } + @Override public void uniform1iv(int location, int count, int[] v, int offset) { GL20.glUniform1(location, toIntBuffer(v, offset, count)); } @@ -792,6 +820,7 @@ public class LwjglGL20 implements GL { GL20.glUniform2(location, v); } + @Override public void uniform2fv(int location, int count, float[] v, int offset) { GL20.glUniform2(location, toFloatBuffer(v, offset, count << 1)); } @@ -806,6 +835,7 @@ public class LwjglGL20 implements GL { GL20.glUniform2(location, v); } + @Override public void uniform2iv(int location, int count, int[] v, int offset) { GL20.glUniform2(location, toIntBuffer(v, offset, count << 1)); } @@ -820,6 +850,7 @@ public class LwjglGL20 implements GL { GL20.glUniform3(location, v); } + @Override public void uniform3fv(int location, int count, float[] v, int offset) { GL20.glUniform3(location, toFloatBuffer(v, offset, count * 3)); } @@ -834,6 +865,7 @@ public class LwjglGL20 implements GL { GL20.glUniform3(location, v); } + @Override public void uniform3iv(int location, int count, int[] v, int offset) { GL20.glUniform3(location, toIntBuffer(v, offset, count * 3)); } @@ -848,6 +880,7 @@ public class LwjglGL20 implements GL { GL20.glUniform4(location, v); } + @Override public void uniform4fv(int location, int count, float[] v, int offset) { GL20.glUniform4(location, toFloatBuffer(v, offset, count << 2)); } @@ -862,6 +895,7 @@ public class LwjglGL20 implements GL { GL20.glUniform4(location, v); } + @Override public void uniform4iv(int location, int count, int[] v, int offset) { GL20.glUniform4(location, toIntBuffer(v, offset, count << 2)); } @@ -871,6 +905,7 @@ public class LwjglGL20 implements GL { GL20.glUniformMatrix2(location, transpose, value); } + @Override public void uniformMatrix2fv(int location, int count, boolean transpose, float[] value, int offset) { GL20.glUniformMatrix2(location, transpose, toFloatBuffer(value, offset, count << 2)); } @@ -880,6 +915,7 @@ public class LwjglGL20 implements GL { GL20.glUniformMatrix3(location, transpose, value); } + @Override public void uniformMatrix3fv(int location, int count, boolean transpose, float[] value, int offset) { GL20.glUniformMatrix3(location, transpose, toFloatBuffer(value, offset, count * 9)); } @@ -889,6 +925,7 @@ public class LwjglGL20 implements GL { GL20.glUniformMatrix4(location, transpose, value); } + @Override public void uniformMatrix4fv(int location, int count, boolean transpose, float[] value, int offset) { GL20.glUniformMatrix4(location, transpose, toFloatBuffer(value, offset, count << 4)); } @@ -988,8 +1025,4 @@ public class LwjglGL20 implements GL { public void vertexAttribPointer(int indx, int size, int type, boolean normalized, int stride, int ptr) { GL20.glVertexAttribPointer(indx, size, type, normalized, stride, ptr); } - - @Override - public void getShaderSource(int shader, int bufsize, Buffer length, String source) { - } } diff --git a/vtm-ios/src/org/oscim/ios/backend/IosGL.java b/vtm-ios/src/org/oscim/ios/backend/IosGL.java index 9bcdb807..50cfdcc5 100644 --- a/vtm-ios/src/org/oscim/ios/backend/IosGL.java +++ b/vtm-ios/src/org/oscim/ios/backend/IosGL.java @@ -1,5 +1,6 @@ /* * Copyright 2016 Longri + * Copyright 2019 Gustl22 * * This program is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free Software @@ -138,6 +139,11 @@ public class IosGL implements GL { iOSGL.glDeleteTextures(n, textures); } + @Override + public void deleteTexture(int texture) { + iOSGL.glDeleteTexture(texture); + } + @Override public void depthFunc(int func) { iOSGL.glDepthFunc(func); @@ -193,6 +199,11 @@ public class IosGL implements GL { iOSGL.glGenTextures(n, textures); } + @Override + public int genTexture() { + return iOSGL.glGenTexture(); + } + @Override public int getError() { return iOSGL.glGetError(); @@ -338,6 +349,11 @@ public class IosGL implements GL { iOSGL.glDeleteBuffers(n, buffers); } + @Override + public void deleteFramebuffer(int framebuffer) { + iOSGL.glDeleteFramebuffer(framebuffer); + } + @Override public void getBufferParameteriv(int target, int pname, IntBuffer params) { iOSGL.glGetBufferParameteriv(target, pname, params); @@ -443,6 +459,11 @@ public class IosGL implements GL { return iOSGL.glCreateShader(type); } + @Override + public void deleteBuffer(int buffer) { + iOSGL.glDeleteBuffer(buffer); + } + @Override public void deleteFramebuffers(int n, IntBuffer framebuffers) { iOSGL.glDeleteFramebuffers(n, framebuffers); @@ -453,6 +474,11 @@ public class IosGL implements GL { iOSGL.glDeleteProgram(program); } + @Override + public void deleteRenderbuffer(int renderbuffer) { + iOSGL.glDeleteRenderbuffer(renderbuffer); + } + @Override public void deleteRenderbuffers(int n, IntBuffer renderbuffers) { iOSGL.glDeleteRenderbuffers( @@ -501,20 +527,34 @@ public class IosGL implements GL { level); } + @Override + public int genBuffer() { + return iOSGL.glGenBuffer(); + } + @Override public void generateMipmap(int target) { iOSGL.glGenerateMipmap(target); } + @Override + public int genFramebuffer() { + return iOSGL.glGenFramebuffer(); + } + @Override public void genFramebuffers(int n, IntBuffer framebuffers) { iOSGL.glGenFramebuffers(n, framebuffers); } + @Override + public int genRenderbuffer() { + return iOSGL.glGenRenderbuffer(); + } + @Override public void genRenderbuffers(int n, IntBuffer renderbuffers) { - iOSGL - .glGenRenderbuffers(n, renderbuffers); + iOSGL.glGenRenderbuffers(n, renderbuffers); } @Override @@ -602,11 +642,6 @@ public class IosGL implements GL { precision); } - @Override - public void getShaderSource(int shader, int bufsize, Buffer length, String source) { - throw new UnsupportedOperationException("Not implemented"); - } - @Override public void getUniformfv(int program, int location, FloatBuffer params) { iOSGL.glGetUniformfv(program, location, params); @@ -720,6 +755,11 @@ public class IosGL implements GL { iOSGL.glUniform1fv(location, count, v); } + @Override + public void uniform1fv(int location, int count, float[] v, int offset) { + iOSGL.glUniform1fv(location, count, v, offset); + } + @Override public void uniform1i(int location, int x) { iOSGL.glUniform1i(location, x); @@ -730,6 +770,11 @@ public class IosGL implements GL { iOSGL.glUniform1iv(location, count, v); } + @Override + public void uniform1iv(int location, int count, int[] v, int offset) { + iOSGL.glUniform1iv(location, count, v, offset); + } + @Override public void uniform2f(int location, float x, float y) { iOSGL.glUniform2f(location, x, y); @@ -740,6 +785,11 @@ public class IosGL implements GL { iOSGL.glUniform2fv(location, count, v); } + @Override + public void uniform2fv(int location, int count, float[] v, int offset) { + iOSGL.glUniform2fv(location, count, v, offset); + } + @Override public void uniform2i(int location, int x, int y) { iOSGL.glUniform2i(location, x, y); @@ -750,6 +800,11 @@ public class IosGL implements GL { iOSGL.glUniform2iv(location, count, v); } + @Override + public void uniform2iv(int location, int count, int[] v, int offset) { + iOSGL.glUniform2iv(location, count, v, offset); + } + @Override public void uniform3f(int location, float x, float y, float z) { iOSGL.glUniform3f(location, x, y, z); @@ -760,6 +815,11 @@ public class IosGL implements GL { iOSGL.glUniform3fv(location, count, v); } + @Override + public void uniform3fv(int location, int count, float[] v, int offset) { + iOSGL.glUniform3fv(location, count, v, offset); + } + @Override public void uniform3i(int location, int x, int y, int z) { iOSGL.glUniform3i(location, x, y, z); @@ -770,6 +830,11 @@ public class IosGL implements GL { iOSGL.glUniform3iv(location, count, v); } + @Override + public void uniform3iv(int location, int count, int[] v, int offset) { + uniform3iv(location, count, v, offset); + } + @Override public void uniform4f(int location, float x, float y, float z, float w) { iOSGL.glUniform4f(location, x, y, z, w); @@ -780,6 +845,11 @@ public class IosGL implements GL { iOSGL.glUniform4fv(location, count, v); } + @Override + public void uniform4fv(int location, int count, float[] v, int offset) { + iOSGL.glUniform4fv(location, count, v, offset); + } + @Override public void uniform4i(int location, int x, int y, int z, int w) { iOSGL.glUniform4i(location, x, y, z, w); @@ -790,6 +860,11 @@ public class IosGL implements GL { iOSGL.glUniform4iv(location, count, v); } + @Override + public void uniform4iv(int location, int count, int[] v, int offset) { + iOSGL.glUniform4iv(location, count, v, offset); + } + @Override public void uniformMatrix2fv(int location, int count, boolean transpose, FloatBuffer value) { iOSGL.glUniformMatrix2fv( @@ -799,6 +874,11 @@ public class IosGL implements GL { value); } + @Override + public void uniformMatrix2fv(int location, int count, boolean transpose, float[] value, int offset) { + iOSGL.glUniformMatrix2fv(location, count, transpose, value, offset); + } + @Override public void uniformMatrix3fv(int location, int count, boolean transpose, FloatBuffer value) { iOSGL.glUniformMatrix3fv( @@ -808,6 +888,11 @@ public class IosGL implements GL { value); } + @Override + public void uniformMatrix3fv(int location, int count, boolean transpose, float[] value, int offset) { + iOSGL.glUniformMatrix3fv(location, count, transpose, value, offset); + } + @Override public void uniformMatrix4fv(int location, int count, boolean transpose, FloatBuffer value) { iOSGL.glUniformMatrix4fv( @@ -817,6 +902,11 @@ public class IosGL implements GL { value); } + @Override + public void uniformMatrix4fv(int location, int count, boolean transpose, float[] value, int offset) { + iOSGL.glUniformMatrix4fv(location, count, transpose, value, offset); + } + @Override public void useProgram(int program) { iOSGL.glUseProgram(program); diff --git a/vtm-web/src/org/oscim/gdx/client/GdxGL.java b/vtm-web/src/org/oscim/gdx/client/GdxGL.java index 1b2f204a..73931522 100644 --- a/vtm-web/src/org/oscim/gdx/client/GdxGL.java +++ b/vtm-web/src/org/oscim/gdx/client/GdxGL.java @@ -1,5 +1,20 @@ -package org.oscim.gdx.client; - +/* + * Copyright 2014 Hannes Janetzek + * Copyright 2019 Gustl22 + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * This program is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ /******************************************************************************* * Copyright 2011 See AUTHORS file. *

@@ -16,6 +31,8 @@ package org.oscim.gdx.client; * limitations under the License. ******************************************************************************/ +package org.oscim.gdx.client; + import com.badlogic.gdx.backends.gwt.GwtGL20; import com.badlogic.gdx.graphics.Pixmap; import com.google.gwt.typedarrays.client.Uint8ArrayNative; @@ -37,15 +54,10 @@ public class GdxGL extends GwtGL20 implements GL { this.gl = gl; } - // @Override - // public void glGetShaderSource(int shader, int bufsize, Buffer length, String source) { - // - // } - @Override public void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, Buffer pixels) { - + /*glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);*/ if (pixels == null) { gl.texImage2D(target, level, internalformat, width, height, border, format, @@ -165,6 +177,11 @@ public class GdxGL extends GwtGL20 implements GL { glDeleteTextures(n, textures); } + @Override + public void deleteTexture(int texture) { + glDeleteTexture(texture); + } + @Override public void depthFunc(int func) { glDepthFunc(func); @@ -220,6 +237,11 @@ public class GdxGL extends GwtGL20 implements GL { glGenTextures(n, textures); } + @Override + public int genTexture() { + return glGenTexture(); + } + @Override public int getError() { return glGetError(); @@ -356,6 +378,11 @@ public class GdxGL extends GwtGL20 implements GL { glDeleteBuffers(n, buffers); } + @Override + public void deleteFramebuffer(int framebuffer) { + glDeleteFramebuffer(framebuffer); + } + @Override public void getBufferParameteriv(int target, int pname, IntBuffer params) { glGetBufferParameteriv(target, pname, params); @@ -461,6 +488,11 @@ public class GdxGL extends GwtGL20 implements GL { return glCreateShader(type); } + @Override + public void deleteBuffer(int buffer) { + glDeleteBuffer(buffer); + } + @Override public void deleteFramebuffers(int n, IntBuffer framebuffers) { glDeleteFramebuffers(n, framebuffers); @@ -471,6 +503,11 @@ public class GdxGL extends GwtGL20 implements GL { glDeleteProgram(program); } + @Override + public void deleteRenderbuffer(int renderbuffer) { + glDeleteRenderbuffer(renderbuffer); + } + @Override public void deleteRenderbuffers(int n, IntBuffer renderbuffers) { glDeleteRenderbuffers(n, renderbuffers); @@ -508,16 +545,31 @@ public class GdxGL extends GwtGL20 implements GL { glFramebufferTexture2D(target, attachment, textarget, texture, level); } + @Override + public int genBuffer() { + return glGenBuffer(); + } + @Override public void generateMipmap(int target) { glGenerateMipmap(target); } + @Override + public int genFramebuffer() { + return glGenFramebuffer(); + } + @Override public void genFramebuffers(int n, IntBuffer framebuffers) { glGenFramebuffers(n, framebuffers); } + @Override + public int genRenderbuffer() { + return glGenRenderbuffer(); + } + @Override public void genRenderbuffers(int n, IntBuffer renderbuffers) { glGenRenderbuffers(n, renderbuffers); @@ -600,11 +652,6 @@ public class GdxGL extends GwtGL20 implements GL { precision); } - @Override - public void getShaderSource(int shader, int bufsize, Buffer length, String source) { - throw new UnsupportedOperationException("Not implemented"); - } - @Override public void getUniformfv(int program, int location, FloatBuffer params) { glGetUniformfv(program, location, params); @@ -714,6 +761,11 @@ public class GdxGL extends GwtGL20 implements GL { glUniform1fv(location, count, v); } + @Override + public void uniform1fv(int location, int count, float[] v, int offset) { + glUniform1fv(location, count, v, offset); + } + @Override public void uniform1i(int location, int x) { glUniform1i(location, x); @@ -724,6 +776,11 @@ public class GdxGL extends GwtGL20 implements GL { glUniform1iv(location, count, v); } + @Override + public void uniform1iv(int location, int count, int[] v, int offset) { + glUniform1iv(location, count, v, offset); + } + @Override public void uniform2f(int location, float x, float y) { glUniform2f(location, x, y); @@ -734,6 +791,11 @@ public class GdxGL extends GwtGL20 implements GL { glUniform2fv(location, count, v); } + @Override + public void uniform2fv(int location, int count, float[] v, int offset) { + glUniform2fv(location, count, v, offset); + } + @Override public void uniform2i(int location, int x, int y) { glUniform2i(location, x, y); @@ -744,6 +806,11 @@ public class GdxGL extends GwtGL20 implements GL { glUniform2iv(location, count, v); } + @Override + public void uniform2iv(int location, int count, int[] v, int offset) { + glUniform2iv(location, count, v, offset); + } + @Override public void uniform3f(int location, float x, float y, float z) { glUniform3f(location, x, y, z); @@ -754,6 +821,11 @@ public class GdxGL extends GwtGL20 implements GL { glUniform3fv(location, count, v); } + @Override + public void uniform3fv(int location, int count, float[] v, int offset) { + glUniform3fv(location, count, v, offset); + } + @Override public void uniform3i(int location, int x, int y, int z) { glUniform3i(location, x, y, z); @@ -764,6 +836,11 @@ public class GdxGL extends GwtGL20 implements GL { glUniform3iv(location, count, v); } + @Override + public void uniform3iv(int location, int count, int[] v, int offset) { + glUniform3iv(location, count, v, offset); + } + @Override public void uniform4f(int location, float x, float y, float z, float w) { glUniform4f(location, x, y, z, w); @@ -774,6 +851,11 @@ public class GdxGL extends GwtGL20 implements GL { glUniform4fv(location, count, v); } + @Override + public void uniform4fv(int location, int count, float[] v, int offset) { + glUniform4fv(location, count, v, offset); + } + @Override public void uniform4i(int location, int x, int y, int z, int w) { glUniform4i(location, x, y, z, w); @@ -784,21 +866,41 @@ public class GdxGL extends GwtGL20 implements GL { glUniform4iv(location, count, v); } + @Override + public void uniform4iv(int location, int count, int[] v, int offset) { + glUniform4iv(location, count, v, offset); + } + @Override public void uniformMatrix2fv(int location, int count, boolean transpose, FloatBuffer value) { glUniformMatrix2fv(location, count, transpose, value); } + @Override + public void uniformMatrix2fv(int location, int count, boolean transpose, float[] value, int offset) { + glUniformMatrix2fv(location, count, transpose, value, offset); + } + @Override public void uniformMatrix3fv(int location, int count, boolean transpose, FloatBuffer value) { glUniformMatrix3fv(location, count, transpose, value); } + @Override + public void uniformMatrix3fv(int location, int count, boolean transpose, float[] value, int offset) { + glUniformMatrix3fv(location, count, transpose, value, offset); + } + @Override public void uniformMatrix4fv(int location, int count, boolean transpose, FloatBuffer value) { glUniformMatrix4fv(location, count, transpose, value); } + @Override + public void uniformMatrix4fv(int location, int count, boolean transpose, float[] value, int offset) { + glUniformMatrix4fv(location, count, transpose, value, offset); + } + @Override public void useProgram(int program) { glUseProgram(program); diff --git a/vtm/src/org/oscim/backend/GL.java b/vtm/src/org/oscim/backend/GL.java index 60d36753..1980d08c 100644 --- a/vtm/src/org/oscim/backend/GL.java +++ b/vtm/src/org/oscim/backend/GL.java @@ -1,5 +1,6 @@ /* * Copyright 2013 Hannes Janetzek + * Copyright 2019 Gustl22 * * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * @@ -386,6 +387,8 @@ public interface GL { public void deleteTextures(int n, IntBuffer textures); + public void deleteTexture(int texture); + public void depthFunc(int func); public void depthMask(boolean flag); @@ -408,6 +411,8 @@ public interface GL { public void genTextures(int n, IntBuffer textures); + public int genTexture(); + public int getError(); public void getIntegerv(int pname, IntBuffer params); @@ -472,12 +477,18 @@ public interface GL { public int createShader(int type); + public void deleteBuffer(int buffer); + public void deleteBuffers(int n, IntBuffer buffers); + public void deleteFramebuffer(int framebuffer); + public void deleteFramebuffers(int n, IntBuffer framebuffers); public void deleteProgram(int program); + public void deleteRenderbuffer(int renderbuffer); + public void deleteRenderbuffers(int n, IntBuffer renderbuffers); public void deleteShader(int shader); @@ -494,12 +505,18 @@ public interface GL { public void framebufferTexture2D(int target, int attachment, int textarget, int texture, int level); + public int genBuffer(); + public void genBuffers(int n, IntBuffer buffers); public void generateMipmap(int target); + public int genFramebuffer(); + public void genFramebuffers(int n, IntBuffer framebuffers); + public int genRenderbuffer(); + public void genRenderbuffers(int n, IntBuffer renderbuffers); // deviates @@ -534,8 +551,6 @@ public interface GL { public void getShaderPrecisionFormat(int shadertype, int precisiontype, IntBuffer range, IntBuffer precision); - public void getShaderSource(int shader, int bufsize, Buffer length, String source); - public void getTexParameterfv(int target, int pname, FloatBuffer params); public void getTexParameteriv(int target, int pname, IntBuffer params); @@ -595,40 +610,62 @@ public interface GL { public void uniform1fv(int location, int count, FloatBuffer v); + public void uniform1fv(int location, int count, float v[], int offset); + public void uniform1i(int location, int x); public void uniform1iv(int location, int count, IntBuffer v); + public void uniform1iv(int location, int count, int v[], int offset); + public void uniform2f(int location, float x, float y); public void uniform2fv(int location, int count, FloatBuffer v); + public void uniform2fv(int location, int count, float v[], int offset); + public void uniform2i(int location, int x, int y); public void uniform2iv(int location, int count, IntBuffer v); + public void uniform2iv(int location, int count, int[] v, int offset); + public void uniform3f(int location, float x, float y, float z); public void uniform3fv(int location, int count, FloatBuffer v); + public void uniform3fv(int location, int count, float[] v, int offset); + public void uniform3i(int location, int x, int y, int z); public void uniform3iv(int location, int count, IntBuffer v); + public void uniform3iv(int location, int count, int v[], int offset); + public void uniform4f(int location, float x, float y, float z, float w); public void uniform4fv(int location, int count, FloatBuffer v); + public void uniform4fv(int location, int count, float v[], int offset); + public void uniform4i(int location, int x, int y, int z, int w); public void uniform4iv(int location, int count, IntBuffer v); + public void uniform4iv(int location, int count, int v[], int offset); + public void uniformMatrix2fv(int location, int count, boolean transpose, FloatBuffer value); + public void uniformMatrix2fv(int location, int count, boolean transpose, float value[], int offset); + public void uniformMatrix3fv(int location, int count, boolean transpose, FloatBuffer value); + public void uniformMatrix3fv(int location, int count, boolean transpose, float value[], int offset); + public void uniformMatrix4fv(int location, int count, boolean transpose, FloatBuffer value); + public void uniformMatrix4fv(int location, int count, boolean transpose, float value[], int offset); + public void useProgram(int program); public void validateProgram(int program);