Home > other >  OpenGL texture map without color
OpenGL texture map without color

Time:09-21

When using the texture map without color, show black and white figure, the texture with a bitmap image color shows the output of the normal
Here is a map code:
GLuint Tex;
GlGenTextures (1, & amp; Tex);
GlBindTexture (GL_TEXTURE_2D, Tex);
GlTexParameterf (GL_TEXTURE_2D GL_TEXTURE_MIN_FILTER, GL_NEAREST);
GlTexParameterf (GL_TEXTURE_2D GL_TEXTURE_MAG_FILTER, GL_NEAREST);
GlTexParameterf (GL_TEXTURE_2D GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
GlTexParameterf (GL_TEXTURE_2D GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
//glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, size, size, 0, GL_RGB, GL_FLOAT, _result);

Unsigned char * BMP=new unsigned char [size * size * 3];
for(int i=0; i{
BMP [I]=(unsigned char) (_result [I] * 255);
}
WxImage img (size, size, BMP, true);
Img. SaveFile (" d: \ \ ABC BMP, "wxBITMAP_TYPE_BMP);

GlTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, size, size, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP);

The delete BMP.



Void icfdRender: : display_texture ()
{
If (_dataset. Points. The empty () | | _dataset. Texture==0) return;

GlBindTexture (GL_TEXTURE_2D, _dataset. Texture);
GlEnable (GL_TEXTURE_2D);
GlEnable (GL_BLEND);

IcfdLICTech: : Instance () - & gt; The Enable (true);
IcfdLICTech: : Instance () - & gt; SetAlpha (0.5);

GlBegin (GL_QUADS);
GlTexCoord2f (0.0, 0.0);
GlVertex3fv (_dataset points [0]. J coord);
GlTexCoord2f (1.0, 0.0);
GlVertex3fv (_dataset points [1]. J coord);
GlTexCoord2f (1.0, 1.0);
GlVertex3fv (_dataset points [2]. J coord);
GlTexCoord2f (0.0, 1.0);
GlVertex3fv (_dataset points [3]. J coord);
glEnd();

IcfdLICTech: : Instance () - & gt; The Enable (false);

GlDisable (GL_BLEND);
GlDisable (GL_TEXTURE_2D);
GlBindTexture (GL_TEXTURE_2D, 0);
}

CodePudding user response:

Problem has been solved, shader
  • Related