OpenGL ES(二)

2016-04-04  本文已影响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

Name Conventions

EGL

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

EGL

使用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

理论上不使用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

上一篇下一篇

猜你喜欢

热点阅读