OpenGL es1.1.12 Chapter 2 2.10.2

Source: Internet
Author: User

(Draft only, not sorted)

2.10.2 Matrix

You can use multiple commands to set and modify the projection matrix and Model View matrix. The impact matrix is determined by the current matrix mode. Run the following command to set the parameters:

Void matrixmode (Enum mode );

The enumerated types include texture, modelview, and projection. Texture is described in the section after 2.10.2. If the current mode is modelview, a matrix operation is performed on the view model matrix. Similarly, if the mode is projection, a matrix operation is performed on the projection matrix.

There are two basic commands that affect the current matrix:

Void loadmatrix {XF} (t m [16]);

Void multmatrix {XF} (t m [16]);

Loadmatrix is a 4x4 matrix, which is stored in columns. A total of 16 floating point or fixed point values are listed as follows:

(This is different from row-based storage in C. If this form is used, all subsequent conversion equations must be transformed and columns become rows)

The specified matrix should replace the current matrix. It is a matrix pointer to the multmatrix, such as loadmatrix. However, the matrix multiplication is implemented by the matrix to which the replacement is the projection of the current matrix. If C is the current matrix and m is the matrix pointed to by multmatrix, the result of the current matrix is C', that is

C' = c.m

Void loadidentity (void), the Command actually calls the loadmatrix command, but the parameter is the matrix of the Return

There are also many other commands that can operate on the matrix. The rotate, translate, scale, frustum, and ortho commands can all operate on the current matrix. Each of them calculates the matrix, the multmatrix command is also required. Consider the following:

Is the rotation angle value, which is defined by vertex coordinate v. The calculation matrix starts with a given straight-line axis and rotates against the clockwise side (for example, the right-hand rule determines the rotation angle ). In this case, the matrix is


Hypothesis

If

So

Void translatefxfg (t x, t y, t Z); the parameter in is the coordinate conversion vector, and the matrix result is converted by a vector:

Void scale {XF} (t x, t y, t Z); generate an X-, Y-, and Z-axis value. The corresponding matrix is

In the void frustum {XF} (t l, t r, t B, T, T N, t f) command

Maps the points near the editing surface to the lower left and upper right corner of the window.

Position). F indicates the distance between the eyes and the editing face. If n or F is less than or equal to 0, L is equal to R, B is equal to T, or N is equal to F, an invalid_value error is generated. The corresponding matrix is:


Void ortho {XF} (t l, t r, t B, T, T N, t f) command is a matrix to generate parallel projection, coordinates and points near the editing surface are mapped to the lower left corner and the upper right corner of the window (where the eye points are located). F indicates the distance between the eyes and the editing surface. If n or F is less than or equal to 0, L is equal to R, B is equal to T, or N is equal to F, an invalid_value error is generated. The corresponding matrix is:

For each Texture unit, the 4x4 matrix is applied to the corresponding texture coordinates as follows:

The left side shows the current texture matrix. The result of the application is the texture coordinate, which is related to the vertex. If you set the matrix mode to texture, apply the specified matrix operation to the texture matrix.

At the same time, there are texture matrix stacks corresponding to each Texture unit. The matrix operation to change this stack is to set the active Texture unit selector, which is completed by the void activetexture (Enum texture) command.

This selector also affects the texture environment status, texture coordinate generation status, texture binding status, and the value of this status and the current texture coordinate.

Defining an invalid texture will produce an invalid_enum error. The valid value of the texture, which is the same as the multitexcoord value described in section 2.7.

The void pushmatrix (void) command is to press a value into the stack and copy the current matrix at the top and exit of the stack.

The void popmatrix (void) command pops up a value from the stack and replaces the second value at the stack exit with the current matrix. The push-in and pop-up operations are associated with the matrix mode. If there is only one exit, the pop-up operation will produce a stack_underflow error. If you press a full stack, A stack_overflow error will occur.

When the current matrix mode is texture, the texture matrix stack of the active Texture unit is pushed in or out.

The status of conversion requires the following: an integer representing the active Texture unit selector, a 4-value integer

Indicates the current matrix mode. A stack with at least two 4x4 matrices is used to represent projection and Texture unit texture, and a minimum of 16 4x4 matrices represent modelview.

Each matrix Stack has an associated Stack pointer. In the initial state, each stack has only one matrix. All matrices are set to normalized matrices. The active Texture unit selector is texture0 and the matrix mode is modelview.

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.