The procedure is as follows:
1.Enable 2D Texture first. If it is not enabled, the texture area is black.
Glable (gl_texture_2d)
2.Generate texture
Glgentextures (1, & m_ntextureid)
Glbindtexture (1, & m_ntextureid)
Glteximage2d (gl_texture_2d, 0, gl_rgba, m_nwidth, m_nheight, 0, gl_rgba, gl_unsigned_byte, m_pdata );
M_pdata pixel data
You can also enable the following filtering methods:
Gltexparameteri (gl_texture_2d, gl_texture_mag_filter, gl_linear );
Gltexparameteri (gl_texture_2d, gl_texture_min_filter, gl_linear );
3.Draw, bind the texture first, and map the texture coordinates and spatial coordinates with the Quadrilateral.
Glbindtexture (gl_texture_2d, m_ntextureid );
Glbegin (gl_quads );
Gltexcoord2f (0, 0 );
Glvertex3f (0, 0, 0.0f );
Gltexcoord2f (1, 0 );
Glvertex3f (m_nwidth, 0, 0.0f );
Gltexcoord2f (1, 1 );
Glvertex3f (m_nwidth, m_nheight, 0.0f );
Gltexcoord2f (0, 1 );
Glvertex3f (0, m_nheight, 0.0f );
Glend ();
4. You can use lib.png and Glaux for BMP.
OpenGL 2D Texture implementation