Common OpenGL ES APIs

Source: Internet
Author: User

This is a document I have uploaded from http://seya.javaeye.com/blog/542343. it is quite useful!

 

Common OpenGL ES APIs:

 

Glclearcolor (0.f, 0.f, 0.f, 1.f); // set the background color of the mode window. The color is the rgba value.

 

Glviewport (0, 0, iscreenwidth, iscreenheight); // you can specify the size and position of the view,

View: that is, the area where the image is finally displayed to the screen. The first two parameters are the position of the view, and the last two parameters are the width and length of the view.

 

Glmatrixmode (gl_projection); // you can specify the matrix mode as the projection matrix. Subsequent transformations affect the projection matrix.

 

OpenGL is a state management mechanism. For example, after you set the current matrix to a projection matrix, any matrix transformation will affect the projection matrix before you call glmatrixmode () again.

 

Glfrustumf (-1.f, 1.f,-1.f, 1.f, 3.f, 1000.f); // This function creates a perspective projection matrix. The parameters define the visual object, which can be understood as a camera, the visible range of the eye. Just like a triangular pyramid, parameters 1, 3, 5, 2, 4, and 6 define the coordinates of the near-cut surface and the lower left and upper right (x, y, z) of the far-cut surface.

 

OpenGL projection has two modes: Perspective Projection, that is, creating a three-pyramid visual body through the above functions. In this mode, the three-dimensional model of viewing is nearly large and small. The other mode is orthogonal mode. The visual object is a parallel Al, and the distance from the camera does not affect the object size.

 

Glmatrixmode (gl_modelview); // you can specify the current matrix as the mode matrix.

 

Glvertexpointer (3, gl_byte, 0, vertices); // specifies where to access spatial coordinate data

 

OpenGL has a total of eight such functions that can access different coordinate data:

Glcolorpointer ();

Glindexpointer ();

Glnormalpointer ();

Gltexcoordpointer ();

 

Glshademodel (gl_flat); // sets the shadow mode to gl_flat. The default value is gl_smooth.

There are two shadow modes: gl_smooth and gl_flat, which have different effects in case of care.

 

Glclear (gl_color_buffer_bit); // clear the color Cache

Glloadidentity (); // you can specify the current matrix as the unit matrix.

 

The positions and sizes in OpenGL are expressed in matrices. For example, glscanf () is used to zoom in or out. In fact, a matrix is used to multiply the current matrix, in order to make the transformation not affected by the current matrix, set the current matrix as the unit matrix.

 

Gltranslatex (0, 0,-100 <16); // move the coordinates to the negative direction of the Z axis by 100

 

Glcolor4f (1.f, 0.f, 0.f, 1.f); set the color to red.

 

Glscalex (15 <16, 15 <16, 15 <16, 15 <16); // scale up an object by 15 times along XYZ

 

Gldrawelements (gl_triangles, 1*3, gl_unsigned_byte, indices); // draw a graph. gl_triangles indicates that the graph to be drawn is a triangle. 3 indicates that there are three fixed points in total, gl_unsigned_byte indicates the Data Type stored by indices

 

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

Void gltranslatex (glfixed X, glfixed y, glfixed Z)

Function: Pan along X, Y, and Z

 

Void glscalef (glfloat X, glfloat y, glfloat Z) void glscalex (glfixed X, glfixed y, glfixed Z)

Function: zooming in the X, Y, and Z axes. The parameters x, y, and z are the desired size.

 

Void glrotatef (glfloat angle, glfloat X, glfloat y, glfloat Z) void glrotatex (glfixed angle, glfixed X, glfixed y, glfixed Z)

Function: rotate along the X, Y, and Z axes. Angle indicates the angle to be rotated.

 

Void glclear (glbitfield mask)

Function: You can use mask to clear the cache in three modes: gl_color_buffer_bit, gl_depth_buffer_bit, and gl_stencil_buffer_bit.

 

Void glcleardepthf (glclampf depth) void glcleardepthx (glclampx depth)

Function: sets the depth cache. The parameters are 0 to 1. Use glclear to clear the cache. Deep cache is used by OpenGL in 3D scenarios. Its sorting determines that the object is first painted. In this way, you will not draw a square behind a circle to a circle.

 

Void glclearcolor (glclampf red, glclampf green, glclampf blue, glclampf alpha) void glclearcolorx (glclampx red, glclampx green, glclampx blue, glclampx alpha)

Function: Clear the color cache with the specified color value (rgba)

 

Void glcolorpointer (glint size, glenum type, glsizei stride, const glvoid * pointer) function: Specifies the color storage space. The size is 4 by default in OpenGL ES, indicating (rgba ); type is the type of pointer content, stride is the offset of data in Pointer memory, and pointer is the address of the first element.

 

Void glenableclientstate (glenum array) void gldisableclientstate (glenum array)

Function: enable or disable array. array: gl_color_array, gl_matrix_index_array_oes, gl_normal_array, struct, gl_texture_coord_array, gl_vertex_array, and gl_weight_array_oes.

 

Void gldrawelements (glenum mode, glsizei count, glenum type, const glvoid * indices)

Function: draws a graph based on the value specified by the parameter. Mode specifies the type to be drawn: gl_points, gl_line_strip, gl_line_loop, gl_lines, gl_triangle_strip, gl_triangle_fan, and gl_triangles; count indicates; type specifies indices as the first address of the array

 

Reproduced csdn: http://blog.csdn.net/yuyang840/archive/2009/11/18/4827426.aspx

 

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.