Thanks for the suggestions, I'll try them out when I get home. Night, Thats just the first call to fail, I'd imagine the subsequent calls using the gl functions would fail as well.
- Dan On Thu, Aug 27, 2009 at 10:42 AM, Streets Of Boston <flyingdutc...@gmail.com > wrote: > > You could do the loading of the bitmap in a seperate background thread > and generating the textures in your 'mGl' thread when this separate > background thread has finished. > > I don't think you can use AsyncTask to do this, since the onPostExecute > () needs to be executed on the main GUI thread (which is not your > 'mGl' thread, i assume). Instead you could use ExecutorService in > java.util.concurrent for that. > > > On Aug 27, 9:50 am, Nightwolf <mikh...@gmail.com> wrote: > > If the problem is with glGenTextures then why not to generate texture > > ids pool beforehand? > > > > On Aug 27, 8:59 am, Dan Sherman <impact...@gmail.com> wrote: > > > > > > > > > I'm converting an app I've written from Canvas to OpenGL, and not > having too > > > hard of a time yet. > > > > > However, I've run into one snag that I can't seem to get around. My > old app > > > was threading image loads, because there are a ton of them, however, it > > > looks like the OpenGL implementation protects itself to a single > thread. I > > > have a basic loadBitmap() function as follows: > > > protected static void loadBitmap(GLSprite sprite, int resourceId) { > > > int textureName = -1; > > > if (mContext != null && mGl != null) { > > > mGl.glGenTextures(1, mTextureNameWorkspace, 0); > > > > > textureName = mTextureNameWorkspace[0]; > > > mGl.glBindTexture(GL10.GL_TEXTURE_2D, textureName); > > > > > mGl.glTexParameterf(GL10.GL_TEXTURE_2D, > > > GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST); > > > mGl.glTexParameterf(GL10.GL_TEXTURE_2D, > > > GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); > > > > > mGl.glTexParameterf(GL10.GL_TEXTURE_2D, > GL10.GL_TEXTURE_WRAP_S, > > > GL10.GL_CLAMP_TO_EDGE); > > > mGl.glTexParameterf(GL10.GL_TEXTURE_2D, > GL10.GL_TEXTURE_WRAP_T, > > > GL10.GL_CLAMP_TO_EDGE); > > > > > mGl.glTexEnvf(GL10.GL_TEXTURE_ENV, > GL10.GL_TEXTURE_ENV_MODE, > > > GL10.GL_REPLACE); > > > > > Bitmap bitmap = BitmapFactory.decodeResource(r, > resourceId); > > > > > GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0); > > > > > mCropWorkspace[0] = 0; > > > mCropWorkspace[1] = bitmap.getHeight(); > > > mCropWorkspace[2] = bitmap.getWidth(); > > > mCropWorkspace[3] = -bitmap.getHeight(); > > > > > sprite.setTextureName(textureName); > > > sprite.setSize(bitmap.getWidth(), bitmap.getHeight()); > > > > > bitmap.recycle(); > > > > > ((GL11) mGl).glTexParameteriv(GL10.GL_TEXTURE_2D, > > > GL11Ext.GL_TEXTURE_CROP_RECT_OES, mCropWorkspace, 0); > > > > > int error = mGl.glGetError(); > > > if (error != GL10.GL_NO_ERROR) { > > > // Logging > > > } > > > } > > > > > This is based heavily off of the SpriteMethodTest in apps-for-android. > If I > > > make a call to this function from the thread that mGl was created from, > > > everything goes fine. However, if I thread the calls to this function, > the > > > calls to glGenTextures() fail with a varying error code (changes with > each > > > run). I haven't been able to find any information regarding how to > deal > > > with this... > > > > > Any help? > > > Thanks > > > - Dan- Hide quoted text - > > > > - Show quoted text - > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---