HI dude
I have to make the texture dynamically .
i tried to do this with the help of this link : https://developer.vuforia.com/forum/faq/android-how-do-i-add-textures-my-model
but i am getting black texture .
HI dude
I have to make the texture dynamically .
i tried to do this with the help of this link : https://developer.vuforia.com/forum/faq/android-how-do-i-add-textures-my-model
but i am getting black texture .
Hi,
I am trying to achieve quite same thing. I've already done java part and i get texture from bitmap, but when it comes to display it on target it gives me black screen as well, so i checked myTexture->textureId and it's showed up that it returns always 0. I think problem was the same because i was also sending the texture object from java code and trying to create and bind it out of renderFrame or initRendering methods. Then i found this thread, and try to move creation event in renderFrame, but i am somehow unable to do that. Can you help me to find where do i go wrong? Because i am getting this error now:
And on logs, i see "TextureIssue:::textureCreation" message but i never get "TextureIssue:::textureCreated" message.
OK, this error message is clarifying the issue quite a bit:
you need to call your texture creation from within the openGL rendering thread; if you execute the glGenTextures (and any other OpenGL code) out of the OpenGL rendering thread, you will not have a valid OpenGL context and as a consequence OpenGL will not work (as the message says, "no current context").
This is a general rule for OpenGL programming.
In practice, for you this means that you need to create your texture either in your initRendering function, or in the renderFrame function (check the original sample code), as these functions are both guaranteed to be called in the OpenGL rendering thread (because they are called from the Java renderer).
So, you will need to adjust your code so to make that happen.
Hi aless
i am getting the error :
: E/libEGL(32702): call to OpenGL ES API with no current context (logged once per thread)
between
Ok, good, so we now know that the texture has not been created properly;
if you look at your code:
if (textureObjectNew != NULL) { myTexture = Texture::create(env, textureObjectNew);
this is where the problem is (probably) occurring; you should print out some LOG from inside the Texture::create() function and see what goes wrong in that function.
If everything goes well inside that function, then it means that the something goes wrong in glGenTextures(1, &(myTexture->mTextureID));
If that's the case, this means that your image has some problems with being transformed into an OpenGL texture (let me know if that's the case..)
Hi Aless..
I checked all three cases ..
the last two cases are fine. but always i am getting .. myTexture->mTextureID==0 (not greater then 0) .
As you told (if it is == 0, the texture is not valid, so it has not been created for some reasons) . Now i want to know the reason.
or any property of texture thats i miss.pls.
hi, you should check a few things:
If you notice anything wrong with the above, then it means something is wrong with your input images or texture creation.
Hi! I just solved this problem and I'd like to share my methods with you. The key problem is not about the texture size( it doesn't need to be size of power of 2).
I worked on the ImageTargets sample, and I needed to get dynamic textures from a server through TCP link. After I dynamically load the texture into mTexture in ImageTarget.java like this( I referred to the loadTextureFromApk() function and wrote the loadTextureFromByteArray() function ):
mTextures.set(0,Texture.loadTextureFromByteArray(buffer,offset,texLen));
I added the following codes into the begining of renderFrame() function in ImageTargetRenderer.java, to generate a new texture and bind it to GLES20.GL_TEXTURE_2D, and it worked!
GLES20.glGenTextures(1, mTextures.get(0).mTextureID, 0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextures.get(0).mTextureID[0]);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA,
mTextures.get(0).mWidth, mTextures.get(0).mHeight, 0, GLES20.GL_RGBA,
GLES20.GL_UNSIGNED_BYTE, mTextures.get(0).mData);
Before that, I tried to call initRendering() after the texture is loaded, but it didn't work. I also tried to change my texture into 512*512 size, which didn't work either.
I've been searching for the solution for almost two days and finally I fixed it with myself! Hope this can help you.
This solution may cost lots of CPU time and I'm looking for a faster solution.