1 | initial version |
You must simply use opengGL with openCV and not viceversa. You can build your shape in openGL and apply the texture using the tools that opencv come with. For example this is a function to transform a IplImage into a texture for openGL:
GLuint ConvertIplToTexture(IplImage *image){
GLuint texture;
glGenTextures(1,&texture);
glBindTexture(GL_TEXTURE_2D,texture);
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
gluBuild2DMipmaps(GL_TEXTURE_2D,3,image->width,image->height,
GL_BGR,GL_UNSIGNED_BYTE,image->imageData);
return texture;
}
2 | No.2 Revision |
You must simply use opengGL with openCV and not viceversa. You can build your shape in openGL and apply the texture using the tools that opencv come with. For example this is a function to transform a IplImage into a texture for openGL:
GLuint ConvertIplToTexture(IplImage *image){
GLuint texture;
glGenTextures(1,&texture);
glBindTexture(GL_TEXTURE_2D,texture);
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
gluBuild2DMipmaps(GL_TEXTURE_2D,3,image->width,image->height,
GL_BGR,GL_UNSIGNED_BYTE,image->imageData);
return texture;
}