direct buffers for pixel and texture operations, added GL thread check

This commit is contained in:
codeanticode
2012-12-12 17:42:27 +00:00
parent 289f46ff61
commit a23205d958
6 changed files with 106 additions and 13612 deletions
+11 -3
View File
@@ -325,6 +325,9 @@ public class PGL {
/** The current opengl context */
public static EGLContext context;
/** OpenGL thread */
protected static Thread glThread;
/** The PGraphics object using this interface */
protected PGraphicsOpenGL pg;
@@ -739,6 +742,11 @@ public class PGL {
}
protected static boolean glThreadIsCurrent() {
return Thread.currentThread() == glThread;
}
///////////////////////////////////////////////////////////
// Caps query
@@ -1565,13 +1573,12 @@ public class PGL {
// Doing in patches of 16x16 pixels to avoid creating a (potentially)
// very large transient array which in certain situations (memory-
// constrained android devices) might lead to an out-of-memory error.
int[] texels = new int[16 * 16];
IntBuffer texels = PGL.allocateDirectIntBuffer(16 * 16);
for (int y = 0; y < height; y += 16) {
int h = PApplet.min(16, height - y);
for (int x = 0; x < width; x += 16) {
int w = PApplet.min(16, width - x);
texSubImage2D(target, 0, x, y, w, h, format, UNSIGNED_BYTE,
IntBuffer.wrap(texels));
texSubImage2D(target, 0, x, y, w, h, format, UNSIGNED_BYTE, texels);
}
}
}
@@ -2226,6 +2233,7 @@ public class PGL {
public void onDrawFrame(GL10 igl) {
gl = igl;
glThread = Thread.currentThread();
pg.parent.handleDraw();
}