trying to implement a new texture for the ofFbo i got a really strange problem…
i added the creation of the ofTexture, ofTextureData, and the attach to the fbo in the setup(), and everything seems fine,
but when i launch the app i got a glError on onSurfaceChanged()
code added to setup() :
ofLog() << "HERE SETUP 1";
ofTextureData td;
td.width = vj.outFbo.getWidth();
td.height = vj.outFbo.getHeight();
td.tex_w = td.width;
td.tex_h = td.height;
td.tex_t = 1; // Hack!
td.tex_u = 1;
td.textureTarget = GL_TEXTURE_EXTERNAL_OES;
td.glTypeInternal = GL_RGBA;
td.bFlipTexture = false;
td.useTextureMatrix = true;
// hack to initialize gl resources from outside ofTexture
texture.texData = td;
texture.texData.bAllocated = true;
ofLog() << "HERE SETUP 2 " << texture.texData.textureID;
glGenTextures(1, (GLuint *)&texture.texData.textureID);
ofLog() << "HERE SETUP 2 " << texture.texData.textureID;
glEnable(texture.texData.textureTarget);
glBindTexture(texture.texData.textureTarget, (GLuint)texture.texData.textureID);
glTexParameterf(texture.texData.textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(texture.texData.textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(texture.texData.textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(texture.texData.textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glDisable(texture.texData.textureTarget);
ofLog() << "HERE SETUP 3";
vj.outFbo.attachTexture(texture, GL_RGBA, 0);
texID = vj.outFbo.getTextureReference().getTextureData().textureID;
ofLog() << "KKK OF TEXID: " << texID;
Log of the error:
07-19 04:41:16.992 17306-17503/cc.openframeworks.miumiusic E/KKK1﹕ onSurfaceCreated_E: glGetError: 0x502
07-19 04:41:17.022 17306-17503/cc.openframeworks.miumiusic W/dalvikvm﹕ threadid=11: thread exiting with uncaught exception (group=0x430f6140)
07-19 04:41:17.122 17306-17503/cc.openframeworks.miumiusic E/AndroidRuntime﹕ FATAL EXCEPTION: GLThread 3133
Process: cc.openframeworks.miumiusic, PID: 17306
java.lang.RuntimeException: glGetError encountered (see log)
at cc.openframeworks.GlUtil.checkGlError(GlUtil.java:94)
at cc.openframeworks.OFAndroidWindow.onSurfaceChanged(OFAndroidWindow.java:427)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1516)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1244)
throwed by:
public void onSurfaceChanged(GL10 gl, int w, int h) {
this.w = w;
this.h = h;
if(!setup && OFAndroid.unpackingDone){
try {
setup();
} catch (IOException e) {
e.printStackTrace();
}
}
OFGestureListener.swipe_Min_Distance = (int)(Math.max(w, h)*.04);
OFGestureListener.swipe_Max_Distance = (int)(Math.max(w, h)*.6);
OFAndroid.resize(w, h);
GlUtil.checkGlError("onSurfaceCreated_E");
}
the exact line in setup() that switch on and off the crash in SurfaceChanged() is:
glGenTextures(1, (GLuint *)&texture.texData.textureID);
possible causes? what i’m missing?