[Android] Introduction to OpenGL and OpenGL ES

Source: Internet
Author: User

IntroductionOpenGL

The full name of OpenGL is the Open graphics library, which is a interface to the graphical libraries, which defines a cross-programming language, a cross-platform programming interface, which is mainly used for 3D graphics (2D) programming. OpenGL was formerly the Iris GL developed by SGI for its graphics workstation. Iris RL is an industry-standard 3D graphics software interface that, while powerful, is not well-ported, so SGI developed OpenGL on the basis of IRIS GL.

The OpenGL system is simple and has cross-platform features, unlike Direct3D, which is a graphical interface under the Windows platform developed by Microsoft and can only be run on Windows systems. OpenGL therefore has a wide range of adaptability, not only for large workstations, but also for personal PCs.

OpenGL ES

on the graphics workstation, personal pc, opengl can work very well. But three-dimensional graphics computing needs to deal with a large number of data, so in some mobile phones and other small devices, if continue to use opengl, it seems more difficult. To solve this problem, Khronos Group asked OPENGL provides a subset: opengl ES (opengl for Embedded System, which is opengl ).

< Span style= "font-size:24px" > Khronos is a graphic hardware and software industry association that focuses on open standards in graphics and multimedia, Span style= "font-size:24px" >khronos Association sets OpenGL ES for embedded devices such as mobile phones, PDAs (personal Data Assistants), and game consoles.

< Span style= "font-size:24px" > OpenGL es is a free, cross-platform, full-featured 2D/3D graphics library interface API for a variety of embedded systems (including console, mobile , handheld devices, home appliances, cars) specifically designed, he is a well-extracted < Span style= "COLOR: #ff0000" >opengl subset .

< Span style= "font-size:24px" > OpenGL es culling opengl glbegin/glend, Quadrilateral (gl_quads), Polygon (gl_polygons) and many other non-absolutely necessary characteristics. After years of development, the current opengl es mainly has two versions, opengl ES 1.x for fixed pipeline hardware; opengl ES 2.x for programmable pipeline hardware.

< Span style= "FONT-SIZE:24PX; White-space:pre ">< Span style= "FONT-SIZE:24PX; White-space:pre "> OpenGL ES 1.0 is OPENGL 1.3 specification-based, opengl ES 1.5 specification, which supports common and common lite two profiles respectively. Lite profile only supports fixed-point real numbers, while common profile and support fixed-point numbers support floating-point number.

< Span style= "FONT-SIZE:24PX; White-space:pre ">< Span style= "FONT-SIZE:24PX; White-space:pre ">< Span style= "FONT-SIZE:24PX; White-space:pre "> the Android SDK is now supported opengl ES 2.0 Most features, Encapsulated in the ANDROID.OPENGL package .

< Span style= "font-size:24px" >< Span style= "FONT-SIZE:24PX; White-space:pre ">< Span style= "FONT-SIZE:24PX; White-space:pre ">

< Span style= "font-size:24px" >< Span style= "FONT-SIZE:24PX; White-space:pre ">< Span style= "FONT-SIZE:24PX; White-space:pre "> draw 2D Graphics

< Span style= "font-size:24px" > android opengl es provides Glsurfaceview components, Used to display 3D graphics. glsurfaceview itself provides 3D drawing capabilities, but glsurfaceview.renderer for 3D drawing in Surfaceview.

< Span style= "font-size:24px" >opengl es using steps:

< Span style= "font-size:24px" > 1, create glsurfaceview component, use activity to display glsurfaceview component.

< Span style= "font-size:24px" >< Span style= "FONT-SIZE:24PX; White-space:pre "> 2, glsurfaceview.renderer instance, which, when implemented, requires overriding the three methods of the interface:

  • abstract void Ondrawframe (GL10 gl) : The renderer object calls the method to draw the current frame of the glsurfaceview.
  • abstract void onsurfacechanged (GL10 gl,int width,int height): current glsurfaceview size changes, callback the method.
  • abstract void onsurfacecreated (GL10 gl,eglconfig config): when

< Span style= "FONT-SIZE:24PX; White-space:pre ">< Span style= "FONT-SIZE:24PX; White-space:pre ">< Span style= "White-space:pre" > 3, call The Setrenderer () method of the Glsurfaceview component, which specifies the renderer object, the Renderer object will complete

< Span style= "FONT-SIZE:24PX; White-space:pre ">< Span style= "FONT-SIZE:24PX; White-space:pre ">< Span style= "FONT-SIZE:24PX; White-space:pre ">< Span style= "FONT-SIZE:24PX; White-space:pre "> So, the difficulty of drawing 3D graphics is not how to use glsurface components, but implement renderer classes. The GL10 parameter in the three methods (as above) when implementing the Renderer class is a "brush" for Glopen es, similar to the canvas component in the OnDraw () method when overriding view.

< Span style= "FONT-SIZE:24PX; White-space:pre ">< Span style= "FONT-SIZE:24PX; White-space:pre ">< Span style= "FONT-SIZE:24PX; White-space:pre ">< Span style= "FONT-SIZE:24PX; White-space:pre "> when

< Span style= "White-space:pre" > < Span style= "FONT-SIZE:24PX; White-space:pre ">< Span style= "FONT-SIZE:24PX; White-space:pre ">< Span style= "White-space:pre" >

@Overridepublic void onsurfacecreated (GL10 gl,eglconfig config) {//Turn off anti-jitter gl.dldisable (gl10.gl_dither);// Set the system to correct the perspective Gl.glhint (gl10.gl_perspective_correction_hint,gl10.gl_fastest); Gl.glclearcolor (0,0,0,0);// Set the shadow Smoothing mode Gl.glshademodel (Gl10.gl_smooth);//enable depth test gl.glenable (gl10.gl_depth_text);//Set depth test type Gl.gldepthfunc (GL10. gl_lequal);}

< Span style= "White-space:pre" > < Span style= "FONT-SIZE:24PX; White-space:pre ">< Span style= "FONT-SIZE:24PX; White-space:pre ">< Span style= "White-space:pre" >


[Android] Introduction to OpenGL and OpenGL ES

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.