The nehe tutorial is a mix of the two points that need attention in this section.

Source: Internet
Author: User

// Gldepthfunc (gl_less );
// Glenable (gl_depth_test); // disable the deep test. Otherwise, the test will fail. The reason is that the uploaded objects cannot pass the test and cannot be mixed.
Gldepthrange (0.0, 1.0 );
Glcleardepth (1.0 );
 
Glclear (gl_color_buffer_bit | gl_depth_buffer_bit );
Glclearcolor (0.0, 0.0, 0.0, 1.0 );

// Glpixelstorei (gl_unpack_alignment, 1 );
 
Aux_rgbimagerec * textureimage [1];
Textureimage [0] = auxdibimageloada (text ("D:/aa.bmp"); // helper function, used to read a texture image

Glblendfunc (gl_dst_alpha, gl_one_minus_dst_alpha); // enable the hybrid test function
Glcolor4f (1.0, 0.0, 0.0, 0.7 );
Glable (gl_blend );

Gluint texture [1];
Glable (gl_texture_2d );
Glgentextures (1, & texture [0]);
Glbindtexture (gl_texture_2d, texture [0]);

Gltexparameteri (gl_texture, gl_texture_min_filter, gl_linear );
Gltexparameteri (gl_texture, gl_texture_mag_filter, gl_linear );
Glubuild2dmipmaps (gl_texture_2d, 3, textureimage [0]-> sizex, textureimage [0]-> sizey, gl_rgb, gl_unsigned_byte, textureimage [0]-> data ); //// Replace the texture generation function in nehe with glubuild2dmipmaps ()

Gltexenvf (gl_texture_env, gl_texture_env_mode, gl_replace );
 

Glbindtexture (gl_texture_2d, texture [0]);
Glmatrixmode (gl_modelview );
Glloadidentity ();
// Glrotatef (Num * 30, 10.0, 10.0, 10.0); // rotate the texture
Glbegin (gl_quads );
Gltexcoord2f (0.0f, 0.0f); glvertex3f (-1000000f,-1000000f, 1000000f); // 0 4 // bottom left of texture and quadrilateral
Gltexcoord2f (1.0f, 0.0f); glvertex3f (1000000f,-1000000f, 1000000f); // 1 5 // bottom right of texture and quadrilateral
Gltexcoord2f (1.0f, 1.0f); glvertex3f (1000000f, 1000000f, 1000000f); // 2 6 // texture and top right of the Quadrilateral
Gltexcoord2f (0.0f, 1.0f); glvertex3f (-1000000f, 1000000f, 1000000f); // 3 7 // top left of texture and quadrilateral

Gltexcoord2f (0.0, 0.0); glvertex3f (-10.0,-10.0, 30.0); // 4
Gltexcoord2f (1.0, 0.0); glvertex3f (10.0,-10.0, 30.0); // 5
Gltexcoord2f (1.0, 1.0); glvertex3f (10.0, 10.0, 30.0); // 6
Gltexcoord2f (0.0, 1.0); glvertex3f (-10.0, 10.0, 30.0); // 7

Gltexcoord2f (0.0, 0.0); glvertex3f (-10.0f,-10.0f, 10.0f );
Gltexcoord2f (1.0, 0.0); glvertex3f (10.0f,-10.0f, 10.0f );
Gltexcoord2f (1.0, 1.0); glvertex3f (-10.0,-10.0, 30.0 );
Gltexcoord2f (0.0, 1.0); glvertex3f (10.0,-10.0, 30.0 );
Glend ();

Glflush ();
Gldisable (gl_texture_2d );

//----------------------------
I tested the hybrid section in the nehe tutorial. There are two points to note: first, we should turn off the deep test. If the deep test is not turned off, the subsequent objects may not be able to pass through directly, the image cannot be painted on the screen. Of course, the mixed effect cannot be generated.
The second is to use the glubuild2dmipmaps () function. The texture generation function in the original tutorial seems to have been discarded and cannot be used.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.