Home > Back-end >  Flash background is not a opengl rendering window
Flash background is not a opengl rendering window

Time:12-02

Use opengl rendering 3 d model of a strip, and now want to add a background to the render window, created a plane to use opencv to read out the background of the corresponding, but display background just for a moment and then turned back to the black background,,, ask the great spirit action Orz

Background code:
Void background ()
{
CV: : Mat bg=CV: : imread (" test. JPG ");
GLuint bgtexture=matToTexture (bg);

GlPushMatrix ();
GlOrtho (0, bg cols, bg. Rows, 0, 150.0, 150.0);
GlBindTexture (GL_TEXTURE_2D bgtexture);
GlBegin (GL_QUADS);
GlTexCoord2f (0, 0); GlVertex2f (1, 1);
GlTexCoord2f (1, 0); GlVertex2f (1, 1);
GlTexCoord2f (1, 1); GlVertex2f (1, 1);
GlTexCoord2f (0, 1); GlVertex2f (1, 1);
GlEnd ();
GlPopMatrix ();
}
Generate background map:
GLuint matToTexture (CV: : Mat & amp; Im)
{
if (! Im. Empty ())
{
CV: : Mat temp (im);
CV: : flip (temp, im, 0);
GLuint textureID;
GlGenTextures (1, & amp; TextureID);
GlBindTexture (GL_TEXTURE_2D textureID);

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);

GlTexImage2D (GL_TEXTURE_2D, 0, 3, im cols, im. The rows, 0, GL_RGB, GL_UNSIGNED_BYTE, im, data);
Return textureID;
}
}

CodePudding user response:

Search online tutorial "learning OpenGL 3 d games",

CodePudding user response:

The building Lord solved Orz
  • Related