From 20ed6e333ccf778ecc8e9fb640674176b16ae09c Mon Sep 17 00:00:00 2001 From: Hannes Janetzek Date: Fri, 28 Jun 2013 04:03:11 +0200 Subject: [PATCH] workaround for libgdx only creating one texture at once.. --- vtm/src/org/oscim/backend/GLAdapter.java | 8 +++++--- vtm/src/org/oscim/utils/GlUtils.java | 25 +++++++++++++++--------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/vtm/src/org/oscim/backend/GLAdapter.java b/vtm/src/org/oscim/backend/GLAdapter.java index 2fb12867..766a1d06 100644 --- a/vtm/src/org/oscim/backend/GLAdapter.java +++ b/vtm/src/org/oscim/backend/GLAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 + * Copyright 2013 Hannes Janetzek * * 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 @@ -14,10 +14,12 @@ */ package org.oscim.backend; -//import com.badlogic.gdx.backends.android.AndroidGL20; public class GLAdapter { - public static GL20 INSTANCE; //= new AndroidGL20(); + public static GL20 INSTANCE; + + public static boolean GDX_WEBGL_QUIRKS; + public static boolean NON_PREMUL_CANVAS; public static GL20 get(){ return INSTANCE; diff --git a/vtm/src/org/oscim/utils/GlUtils.java b/vtm/src/org/oscim/utils/GlUtils.java index fb3c3fe1..bb2dfc27 100644 --- a/vtm/src/org/oscim/utils/GlUtils.java +++ b/vtm/src/org/oscim/utils/GlUtils.java @@ -238,7 +238,7 @@ public class GlUtils { GL = GLAdapter.get(); int error; - while ((error = GL.glGetError()) != 0) { //GL20.GL_NO_ERROR) { + while ((error = GL.glGetError()) != 0) { // GL20.GL_NO_ERROR) { Log.e(TAG, op + ": glError " + error); // throw new RuntimeException(op + ": glError " + error); } @@ -366,15 +366,22 @@ public class GlUtils { public static int[] glGenTextures(int num) { GL = GLAdapter.get(); - - IntBuffer buf = GLRenderer.getIntBuffer(num); - buf.position(0); - buf.limit(num); - GL.glGenTextures(num, buf); int[] ret = new int[num]; - buf.position(0); - buf.limit(num); - buf.get(ret); + IntBuffer buf = GLRenderer.getIntBuffer(num); + + if (GLAdapter.GDX_WEBGL_QUIRKS) { + for (int i = 0; i < num; i++) { + GL.glGenTextures(num, buf); + buf.position(0); + ret[i] = buf.get(); + buf.position(0); + } + } else { + GL.glGenTextures(num, buf); + buf.position(0); + buf.get(ret); + } + return ret; }