opengl--Texture zoom In, zoom out, surround mode

Source: Internet
Author: User
Tags border color

Reason, this self study for a while, now do a summary. The filters used here are linear filters, and the same wrapping mode we've set for the s-axis and T-Axis here is what we set here, and here's the WrapMode, which is the pattern set below.

    Gltexparameteri (gl_texture_2d, gl_texture_wrap_s, wrapMode);
    Gltexparameteri (gl_texture_2d, gl_texture_wrap_t, WrapMode);

First we use the Triangle batch class to set the next vertex data and texture data, we are going to draw a square first, the coordinates are as follows

Here is a simple introduction to the vertex data and texture data corresponding, here is to specify the vertex data and texture data corresponding, with four vertices, and then use the Gl_triangle_strip way to join the fill,

  Pyramidbatch.begin (Gl_triangle_strip, 4,1);
    
    PYRAMIDBATCH.MULTITEXCOORD2F (0, 0.0f, 0.0f);
    pyramidbatch.vertex3f ( -1.0f, -1.0f, 0.0f);
    
    PYRAMIDBATCH.MULTITEXCOORD2F (0, 0.5f, 0.0f);
    pyramidbatch.vertex3f (1.0f, -1.0f, 0.0f);
 
    Set vertex corresponding texture coordinates
    //multitexcoord2f (Gluint texture, Glclampf s, Glclampf t);
    Parameter 1: Texture hierarchy
    //Parameters 2:s coordinates
    //parameters 3:t coordinates
    pyramidbatch.multitexcoord2f (0, 0.0f, 0.5f);
    Set vertex coordinates
    pyramidbatch.vertex3f ( -1.0f, 1.0f, 0.0f);
    PYRAMIDBATCH.MULTITEXCOORD2F (0, 0.5f, 0.5f);
    pyramidbatch.vertex3f (1.0f, 1.0f, 0.0f); 
    End Batch setup
    pyramidbatch.end ();

Here we magnified the texture twice times, in fact, the texture coordinates from 1.0 to 0.5 is magnified twice times


If you change the texture coordinate to twice times 1, it is reduced, as shown in the figure below


Note that the Gl_clamp_to_border is used here, so we have a texture coordinate of 2, so we don't have any stretch, because Gl_clamp_to_border's texture coordinates that are not in the [0,1] range are stretched using the user-set border color, if no border is set , then the default color black is used, for example we set the border and set the color of the border, as shown below

Next we test the gl_mirrored_repeat, is to go to the image of the set of repeated to set the texture, for example, we first texture in the lower right corner, this time the lower left corner of the display texture is its mirror, it is also its image


Next, test the next Gl_clamp_to_edge, which is a texture element with texture edges for stretching.


Again to test the next gl_clamp, we still set the red border, as shown below, this pattern is the texture boundary or Texture_border_color

Do not set borders


Repeat gl_repeat as shown in the figure below

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.