Hi All,
I'm just trying to feed a cvMat a texture that is generated by
fragment shader, there is nothing appears on the screen, I don't know
where is the problem, is this in the driver or glreadPixels.. I just
loaded a TGA Image, to a fragment shader, then textured a quad, I wanted
to feed that texture to a cvMat, so I used glReadPixesl then genereated
a new texture, and drew it on the quad, but nothing appears.
The setup is on OpenGLES on Exynos, Mali400 GPU
Kindly note that the following code is executed at each frame.
glEnableVertexAttribArray( userData->positionloc);
glEnableVertexAttribArray( userData->texCoordLoc);
// use Fragment Shader Texture
glActivateTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE2D, userData->baseMapTexId);
// try to store it into cvMat or GLByte
cv::Mat pixels;
glPixelStorei(GL_PACK_ALIGNMENT, (pixels.step & 3) ? 1 : 4);
glReadPixels(0, 0, 1024, 1024, GL_RGB, GL_UNSIGNED_BYTE, pixels.data);
glEnable(GL_TEXTURE_2D);
GLuint textureID;
glGenTextures(1, &textureID);
// Create the texture
glTexImage2D(GL_TEXTURE_2D, // Type of texture
0, // Pyramid level (for mip-mapping) - 0 is the top level
GL_RGB, // Internal colour format to convert to
1024, // Image width i.e. 640 for Kinect in standard mode
1024, // Image height i.e. 480 for Kinect in standard mode
0, // Border width in pixels (can either be 1 or 0)
GL_RGB, // Input image format (i.e. GL_RGB, GL_RGBA, GL_BGR etc.)
GL_UNSIGNED_BYTE, // Image data type
pixels.data); // The actual image data itself
// try to draw that stored texture into a quad
glActiveTexture ( textureID );
glBindTexture ( GL_TEXTURE_2D,textureID );
glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices );