大家好,今天我讲一下Android OpenGL,这个系列是我的学习笔记,希望对大家有所帮助!这一节将给大家简洁的介绍一下术语,以及第一个Android OpenGL程序.

首先让我看们看一下术语:

Vertex (顶点)
A vertex is a point in 3D space and is the building block for many objects. In OpenGL you can specify as few as two coordinates (X,Y) and as many as four (X,Y,Z,W). The w-axis is optional, the default value is set to 1.0. The z-axis is also optional, the default value is set to 0. In this series, we will use the three main coordinates X, Y, and Z, since the W is generally used as a placeholder. The plural of vertex is vertices (mainly important for non native speakers, because it may create confusion). All objects are drawn using vertices as their points, so a point will refer to a vertex.

Triangle (三角)
A triangle requires three points to be created. So in OpenGL, we use three vertices to create one.

Polygon (多边形)
A polygon is an object which has at least three connected points. Therefor a triangle is also a polygon.

Primitives (基本实体)
A primitive is a three-dimensional object created using either triangles or polygons. A bit ironic: A detailed model with 50.000 vertices is also a primitive like a low detailed model with 500 vertices.

下面就是我们的第一个Android OpenGL程序:

我们这里的View是用的GLSurfaceView,但是它要setRenderer()一下,就像我们Activity里面的setContentView()方法一样!

这里的OpenGLRender是我重新写的类,它继承于GLSurfaceView.Renderer,我们要实现其种的三个方法:

onSurfaceCreated(),onSurfaceChanged(),onDrawFrame()。代码如下:

第10行就是相当于我们设置画布颜色RGBA(红绿蓝透),第11行这里是清除深度颜色缓存,不加上一句,第10句不起作用,整个View的颜色

还是黑黑的!

运行效果如下:

更多相关文章

  1. android 程序執行logcat 指令並保存到文件裏
  2. 打电话的应用程序源码以及Android基础-----Android生命周期
  3. Android程序运行中动态加载Lib的方法(一)
  4. android画图——颜色过滤
  5. Professional Android(安卓)2 Development - 7
  6. Android的系统服务一览 .
  7. does not declare uses-library android.test.runner
  8. 捕获android中的Home key
  9. Android(安卓)屏幕保护程序制作及源码

随机推荐

  1. android 自定义ButtonTab , ActivityGrou
  2. 关于android真机测试(linux系统下)
  3. 通过Android Studio3.5.3编译安装App失败
  4. 解决Error inflating class android.supp
  5. Android利用Jpush实现异地登陆下线
  6. Android 类加载机制以及基于类加载机制的
  7. 利用AS(3.0)工具将工程打包成jar
  8. WiFi流程
  9. Android 属性动画(Property Animation) 完
  10. 动画 -- View动画 -- 缩放动画