I asked a similar question on OF forum (copied here for your convenience). I'd like to ask you the "specifications" of the texture Arena passes to its plugins, it seems there is some mismatch with the format used by OpenFrameworks that is breaking the drawing when binding it with a mesh.
in the effort to write working FFGL plugins with OF080 I am currently struggling with a difficult (for me) problem. The data coming from host app is basically a texture handle with width and height info:
Code: Select all
//FFGLTextureStruct (for ProcessOpenGLStruct)
typedef struct FFGLTextureStructTag
{
DWORD Width, Height;
DWORD HardwareWidth, HardwareHeight;
GLuint Handle; //the actual texture handle, from glGenTextures()
} FFGLTextureStruct;
// ProcessOpenGLStruct
typedef struct ProcessOpenGLStructTag {
DWORD numInputTextures;
FFGLTextureStruct **inputTextures;
//if the host calls ProcessOpenGL with a framebuffer object actively bound
//(as is the case when the host is capturing the plugins output to an offscreen texture)
//the host must provide the GL handle to its EXT_framebuffer_object
//so that the plugin can restore that binding if the plugin
//makes use of its own FBO's for intermediate rendering
GLuint HostFBO;
} ProcessOpenGLStruct;
Code: Select all
for(int i = 0; i < pGL->numInputTextures; i++ )
{
// create texture here if it isnt there...
if( !inputTextures[i] )
inputTextures[i] = new ofTexture();
FFGLTextureStruct &tex = *(pGL->inputTextures[i]);
ofTexture * ofTex = inputTextures[i];
// adapted from ofQC by vade.
ofTex->texData.textureID = tex.Handle;
ofTex->texData.textureTarget = GL_TEXTURE_2D;
ofTex->texData.width = tex.Width;
ofTex->texData.height = tex.Height;
ofTex->texData.bFlipTexture = true;
ofTex->texData.tex_w = tex.HardwareWidth;
ofTex->texData.tex_h = tex.HardwareHeight;
ofTex->texData.tex_t = ((float)tex.Width)/ tex.HardwareWidth;
ofTex->texData.tex_u = ((float)tex.Height)/ tex.HardwareHeight;
ofTex->texData.glTypeInternal = GL_RGBA; // this is just a guess...
//ofTex->texData.glType = GL_RGBA;
ofTex->texData.bAllocated = true;
}
Playing with the code I noticed that writing the texture to an array of pixels (via ofImage) and taking back the texture works, the new texture correctly binds to the mesh and draws.
Code: Select all
ofTexture * tex = inputTextures[0];
fbo.begin();
tex->draw(0, 0);
fbo.end();
fbo.readToPixels(image.getPixelsRef());
image.update();
image.bind();
... draw the mesh ...
image.unbind();
The question is: how can I find out what's wrong with the texture I get from host? Is there some parameter I could try to match it with the ones inside OF code?
By the way this could be related with a known bug of ofxFFGLPlugin and OF 080, where depth testing does not work.
Any help would be greatly appreciated, thanks
Davide