I'm trying to render the data coming from the Perceptual Computing SDK into a mesh. It is probably important to know I am using OpenGL (and it might be helpful to know I'm using openFrameworks). Currently I do the following:
- grab the depth, UV, and color data into buffers
- run through the UV buffer and create a new color buffer which matches the depth buffer dimensions and puts the colors in the right place.
- push the depth and pre-processed, down-sampled color buffers to textures
- use a vertex shader to deform a plane based on the depth texture, and a fragment shader to apply the appropriate color.
What I would like to do is not pre-process and down-sample the color feed, so I'm imagining I would:
- push the raw depth, UV, and color data to textures
- use a vertex shader to deform a plane based on the depth texture, and a fragment shader to lookup in the UV texture and apply the appropriate color from the color texture.
What I am having trouble with is figuring out how to get the data from the UV buffer into a OpenGL texture. Since the SDK returns the UV data as a byte array, but the data needs to be interpreted as a 32-bit floating point number, I thought I might:
//initialize the texture mTexUV.allocate(mDimsDepth, mDimsDepth, GL_RG, GL_RG, GL_DOUBLE); //load the data from the SDK straight into the texture mTexUV.loadData(cData.planes, mDimsDepth, mDimsDepth, GL_RG, GL_DOUBLE);
for those not familiar with openFramework's texture methods, the first uses the arguments (width, height, gl_internal_type, gl_incoming_format, gl_incoming_type), and the second uses the format (const void *data, width, height, gl_incoming_format, gl_incoming_type).
This doesn't seem to be working, and in fact when I even have the following line in my fragment shader without even using the value of uv_:
vec4 uv_ = texture2DRect(uvTex, referencePosition);
I get blackness (but no logged errors about the shader not compiling or crashing...) I know this is not a complete self-contained code snippet, but I'm hoping someone knows OpenGL well enough, or experience in getting this kind of data wrangled into a texture to help me out.