美文网首页
OpenGL ES(二)

OpenGL ES(二)

作者: 北疆_ | 来源:发表于2016-04-04 17:12 被阅读329次

    OpenGL ES 2.0 Reference Pages
    stackoverflow questions

    OpenGL ES 1.1 Tutorial for Android

    Buffer

    1. IO stream versus NIO blocks
      Process data, IO stream, NIO blocks (packaged and transmitted)
    2. Directbuffer allocate memory space from native, uncontrolled by Garbage collector.
    3. Buffer three state variables
    Buff
    • Capacity: How many memory allocate to buffer ;
    • Position: Like pointer in the C / C++;
    • Limit: control current area w/r, like [0, limit-1] beyond the area throw exception;

    Name Conventions

    • Constant "GL_" as prefix. such as GLES20.GL_COLOR_BUFFER_BIT
    • Instruction "gl" as prefix. Such as gl.glClearColor() ; some instruction end with 3f or 4f, the 3, 4 represent of the number of parameters, "f" represent of parameter type float, Such as gl.glColor4f, (i,x represent of int,Such as gl.glColor4x)
    • End with "v" OpenGL ES instruction, representing of Vector, Such as GLES20.glUniformMatrix4fv.
    • boolean: GL_TRURE, GL_FALSE;

    EGL

    OpenGL ES的javax.microedition.khronos.opengles 包定义了平台无关的GL绘图指令,
    EGL(javax.microedition.khronos.egl )则定义了控制displays ,contexts 以及surfaces 的统一的平台接口。

    EGL
    • Display(EGLDisplay) 是对实际显示设备的抽象。
    • Surface(EGLSurface)是对用来存储图像的内存区域FrameBuffer的抽象,包括Color Buffer, Stencil Buffer ,Depth Buffer.
    • Context (EGLContext) 存储OpenGL ES绘图的一些状态信息。

    使用EGL的绘图的一般步骤:

    1. 获取EGLDisplay对象
    2. 初始化与EGLDisplay 之间的连接。
    3. 获取EGLConfig对象
    4. 创建EGLContext 实例
    5. 创建EGLSurface实例
    6. 连接EGLContext和EGLSurface.
    7. 使用GL指令绘制图形
    8. 断开并释放与EGLSurface关联的EGLContext对象
    9. 删除EGLSurface对象
    10. 删除EGLContext对象
    11. 终止与EGLDisplay之间的连接。

    GLSurfaceView

    • javax.microedition.khronos.opengles GL 绘图指令
    • javax.microedition.khronos.egl EGL 管理Display, surface等
    • android.opengl Android GL辅助类,连接OpenGL 与Android View,Activity
    • javax.nio Buffer类

    理论上不使用android.opengl 包中的类也可以开发Android上OpenGL ES应用,但此时就需要自己使用EGL来管理Display,Context, Surfaces 的创建,释放,捆绑

    OpenGL ES 2 for Android -A Quick-Start Guide

    1. http://www.learnopengles.com/
    2. http://www.khronos.org/
    3. http://www.khronos.org/opengles/sdk/docs/reference_cards/OpenGL-ES-2_0-Reference-card.pdf
    4. http://www.khronos.org/opengles/sdk/docs/man/
    5. http://www.khronos.org/opengles/sdk/docs/manglsl/
    6. http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf
    7. http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf
    8. http://www.khronos.org/registry/egl/
    9. https://pragprog.com/titles/kbogla/source_code

    Getting started

    Checking If the System Supports OpenGL ES 2.0

    final ActivityManager activityManager =
    (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    final ConfigurationInfo configurationInfo =
    activityManager.getDeviceConfigurationInfo();
    final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;
    

    Handling Android's Activity Life Cycle Events

     @Override
        protected void onPause() {
            super.onPause();
            // The following call pauses the rendering thread.
            // If your OpenGL application is memory intensive,
            // you should consider de-allocating objects that
            // consume significant memory here.
            mGLView.onPause();
        }
        @Override
        protected void onResume() {
            super.onResume();
            // The following call resumes a paused rendering thread.
            // If you de-allocated graphic objects for onPause()
            // this is a good place to re-allocate them.
            mGLView.onResume();
        }
    

    Using Static Imports

    import static android.opengl.GLES20.*;
    import static android.opengl.GLUtils.*;
    import static android.opengl.Matrix.*;
    

    Android studio Setting: Settings -> Code Style -> Java -> Imports

    Defining Vertices And Shaders

    相关文章

      网友评论

          本文标题:OpenGL ES(二)

          本文链接:https://www.haomeiwen.com/subject/uzoyhttx.html