Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling external methods from within openGL class
    text
    copied!<p>I'm attempting to call a method which is outside the class I'm working in from an openGL thread but I'm getting a <code>Can't create handler inside thread that has not called Looper.prepare()</code> runtime exception. Does anyone know of a way around this without putting the method in the same class?</p> <p>Program breaks @ <code>Extract cam = new Extract();</code></p> <pre><code> public void onDrawFrame(GL10 gl) { onDrawFrameCounter++; gl.glEnable(GL10.GL_TEXTURE_2D); gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); bindCameraTexture(gl); System.out.println(Global.bearing); float bear = Global.bearing; gl.glLoadIdentity(); gl.glNormal3f(0,0,1); System.out.println("ARRAY!: " + GLCamTest.array.length); p = 0; gl.glRotatef(bear, 1, 0, 0); int q = 0; int e = 0; if(q &lt; Global.cubes){ Extract cam = new Extract(); Bitmap image = cam.extractimage(q); final int TILE_WIDTH = 512; final int TILE_HEIGHT = 512; final int TILE_SIZE = TILE_WIDTH * TILE_HEIGHT; int[] pixels = new int[TILE_WIDTH]; short[] rgb_565 = new short[TILE_SIZE]; // Convert 8888 to 565, and swap red and green channel position: int i = 0; for (int y = 0; y &lt; TILE_HEIGHT; y++) { image.getPixels(pixels, 0, TILE_WIDTH, 0, y, TILE_WIDTH, 1); for (int x = 0; x &lt; TILE_WIDTH; x++) { int argb = pixels[x]; int r = 0x1f &amp; (argb &gt;&gt; 19); // Take 5 bits from23..19 int g = 0x3f &amp; (argb &gt;&gt; 10); // Take 6 bits from15..10 int b = 0x1f &amp; (argb &gt;&gt; 3); // Take 5 bits from 7.. 3 int rgb = (r &lt;&lt; 11) | (g &lt;&lt; 5) | b; rgb_565[i] = (short) rgb; ++i; } } ShortBuffer textureBuffer = ShortBuffer.wrap (rgb_565, 0, TILE_SIZE); gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGB, 48, 48, 0, GL10.GL_RGB, GL10.GL_UNSIGNED_SHORT_5_6_5, textureBuffer); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, e, 4); e = e + 4; gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, e, 4); e = e + 4; gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, e, 4); e = e + 4; gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, e, 4); e = e + 4; gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, e, 4); e = e + 4; gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, e, 4); e = e + 4; q++; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload