refactor: utils.GlUtils -> renderer.GLUtils, utils.Matrix4 -> renderer.GLMatrix

- init 'GL' handle of rendering classes in MapRenderer.onSurfaceCreated,
  at this point handle is safe to use, i.e. GL context is available
- all LayerRenderer share one static 'GL' field now
This commit is contained in:
Hannes Janetzek
2013-09-20 16:28:12 +02:00
parent 83a276becf
commit 7dde869f4a
22 changed files with 219 additions and 234 deletions

View File

@@ -15,19 +15,14 @@
* limitations under the License.
******************************************************************************/
package org.oscim.utils;
package org.oscim.renderer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import org.oscim.backend.GL20;
import org.oscim.backend.GLAdapter;
public class Matrix4 {
private static GL20 GL = GLAdapter.get();
public class GLMatrix {
public static final int M00 = 0;// 0;
public static final int M01 = 4;// 1;
@@ -96,7 +91,7 @@ public class Matrix4 {
*
* @param mat Matrix to copy
*/
public void copy(Matrix4 m) {
public void copy(GLMatrix m) {
if (m == null || m.val.length != 16)
throw new IllegalArgumentException(INVALID_INPUT);
@@ -130,7 +125,7 @@ public class Matrix4 {
*
* @param rhs right hand side
*/
public void multiplyRhs(Matrix4 rhs) {
public void multiplyRhs(GLMatrix rhs) {
matrix4_mul(val, rhs.val);
}
@@ -139,7 +134,7 @@ public class Matrix4 {
*
* @param lhs right hand side
*/
public void multiplyLhs(Matrix4 lhs) {
public void multiplyLhs(GLMatrix lhs) {
System.arraycopy(lhs.val, 0, tmp, 0, 16);
matrix4_mul(tmp, val);
System.arraycopy(tmp, 0, val, 0, 16);
@@ -156,7 +151,7 @@ public class Matrix4 {
* @param lhs left hand side
* @param rhs right hand side
*/
public void multiplyMM(Matrix4 lhs, Matrix4 rhs) {
public void multiplyMM(GLMatrix lhs, GLMatrix rhs) {
System.arraycopy(lhs.val, 0, tmp, 0, 16);
matrix4_mul(tmp, rhs.val);
System.arraycopy(tmp, 0, val, 0, 16);
@@ -167,7 +162,7 @@ public class Matrix4 {
*
* @param mat to transpose
*/
public void transposeM(Matrix4 mat) {
public void transposeM(GLMatrix mat) {
val[M00] = mat.val[M00];
val[M01] = mat.val[M10];
val[M02] = mat.val[M20];
@@ -251,8 +246,7 @@ public class Matrix4 {
buffer.clear();
buffer.put(val, 0, 16);
buffer.position(0);
GL = GLAdapter.get();
GL.glUniformMatrix4fv(location, 1, false, buffer);
MapRenderer.GL.glUniformMatrix4fv(location, 1, false, buffer);
}
/**