OpenGL rendering pipeline Summary

Source: Internet
Author: User

OpenGL rendering pipelines are divided into two parts: modelview transformation and projection transformation ). As a metaphor, computer graphics development is just like taking pictures. The purpose is to present the real scene on a photo paper. The process of observation and transformation is like setting the camera position, selecting the desired object, and setting the shape of the object. The projection transformation is just like the camera displaying real 3D scenes on the photo paper.

Let's first figure out the rendering pipeline in OpenGL. Pipelines are an abstract concept. They are called pipelines because graphics cards process data in a fixed order and strictly follow this order. Like water flowing from one end of a pipe to the other, this order cannot be broken. Shows the rendering pipeline:



The steps for rendering pipelines in OpenGL can also be used to describe:


The order is (in comparison with the camera ):

1. Place the camera on a tripod and align it with the scene (view conversion ).

2. Arrange scene images so that the positions of each object in the photos are what we want (model transformation ).

3. Select the camera lens and adjust the magnification (projection conversion ).

4. determine the size of the final photo (View-view conversion ).



I. View Transformation:

It is equivalent to fixing the camera on a tripod and aligning it with the scene.
Void glulookat (gldouble eyex, gldouble eyey, gldouble Eyez, gldouble
Centerx, gldouble centery, gldouble centerz, gldouble UPX, gldouble upy, gldouble upz );

The parameters indicate the eye position, direction, and direction respectively.


Ii. Model Transformation:

The purpose is to set the model position and direction.

Void glscalef (glfloat X, glfloat y, glfloat Z );

. The parameter specifies the scaling in the above direction.

Void gltranslatef (glfloat X, glfloat y, glfloat Z );

Move the model.

Void glrotatef (glfloat angle, glfloat X, glfloat y, glfloat Z)
Specify the Rotation Angle Based on the straight line from the origin point to the point (x, y, z.

Iii. Projection Transformation:
The purpose is to determine the field of view, which objects should be within the field of view, and the extent to which they will be seen.
It can be divided into perspective projection and orthogonal projection.
(1) Perspective Projection:
Void glfrustum (gldouble left,
Gldouble right,
Gldouble bottom,
Gldouble top,
Gldouble nearval,
Gldouble farval );
The Parameters specify the left and right positions of the vertical cropping plane, the upper and lower positions of the horizontal cropping plane, and the distance between the camera and the deep cropping plane.
Glfrustrum defines a flat header, which computes a matrix used to implement Perspective Projection and multiply it with the current projection matrix (usually in units.
Note: The flat header does not necessarily have to be symmetric, and its axis does not need to be aligned with the Z axis.

Glfrustrum is not intuitive to use. We can use the gluperspective function of the OpenGL tool library.


Void gluperspective (gldouble fovy, gldouble aspect, gldouble znear, gldouble zfar );
The fovy parameter indicates the angle of eye opening. Aspect indicates the aspect ratio x/y. Znear and zfar indicate the distance between the observer and the cropping plane.
Note: gluperspective only allows you to create a heartbeat body that is symmetric along the line of sight along the X axis and Y axis. But what we usually need is this kind of intercept.
(2) positive projection
Void glortho (gldouble left,
Gldouble right,
Gldouble bottom,
Gldouble top,
Gldouble nearval,
Gldouble farval );
Creates an Orthogonal Parallel visual object. The parameter is the same as that of glfrustrum.
To project a two-dimensional image to a two-dimensional screen, you can use the gluortho2d function in the OpenGL tool function library. It is basically the same as its 3D version glortho.

Iv. View-view Transformation:
Determines the shape of the valid screen area mapped by the scenario.
Void glviewport (glint X, glint y, glsizei width, glsizei height );
Set the display area of the view and pixels. The parameter specifies the origin of the valid screen space inside the window (note (0, 0) indicates the lower left corner of the window) and the width and height of the valid screen area.


Reference: http://blog.csdn.net/xiajun07061225/article/details/7330565

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.