Demo的Github仓库地址:https://github.com/filelife/FLVRPlayer html
GLfloat squareVertexData[] =
{
0.5, -0.5, 0.0f, 1.0f, 0.0f, //右下
-0.5, 0.5, 0.0f, 0.0f, 1.0f, //左上
-0.5, -0.5, 0.0f, 0.0f, 0.0f, //左下
0.5, 0.5, -0.0f, 1.0f, 1.0f, //右上
};
复制代码
//顶点索引
GLuint indices[] ={
0, 1, 2,
1, 3, 0
};
复制代码
//顶点数据,前三个是顶点坐标, 中间三个是顶点颜色, 最后两个是纹理坐标
GLfloat attrArr[] =
{
-0.5f, 0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 1.0f,//左上
0.5f, 0.5f, 0.0f, 0.0f, 0.5f, 0.0f, 1.0f, 1.0f,//右上
-0.5f, -0.5f, 0.0f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f,//左下
0.5f, -0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 1.0f, 0.0f,//右下
-0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 0.5f, 0.0f, 1.0f,//后方左上
0.5f, 0.5f, 1.0f, 0.0f, 0.5f, 0.0f, 1.0f, 1.0f,//后方右上
-0.5f, -0.5f, 1.0f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f,//后方左下
0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 0.5f, 1.0f, 0.0f,//后方右下
};
复制代码
//顶点索引
GLuint indices[] =
{
0, 3, 2,
0, 1, 3,
0, 4, 1,
5, 4, 1,
1, 5, 3,
7, 5, 3,
2, 6, 3,
6, 7, 3,
0, 6, 2,
0, 4, 6,
4, 5, 7,
4, 6, 7,
};
复制代码
2.2.1. 坐标系(笛卡尔坐标系):OpeGLES坐标系没有单位,点{1,0,0}到点{2,0,0}的距离就是沿着X轴的的1单位。 2.2.2. 矢量:矢量是理解现代GPU的关键,由于图形处理器就是大规模矢量处理器。 2.2.3. 点、线、三角形:OpenGLES只渲染顶点、线段和三角形。下图就是一种渲染案例,经过点、线、三角形渲染环形体。git
[图片上传失败...(image-9f3553-1529478576825)]github
纹理放大与缩小以下图
/* TextureParameterName */
//提供纹理放大缩小滤波
#define GL_TEXTURE_MAG_FILTER 0x2800
#define GL_TEXTURE_MIN_FILTER 0x2801
#define GL_TEXTURE_WRAP_S 0x2802
#define GL_TEXTURE_WRAP_T 0x2803
@ glTexParameteri (GLenum target, GLenum pname, GLint param);
//glTexParameterf vs glTexParameteri:不一样点在于 integer和 float类型入参。
//In the case where the pname (second) parameter is GL_TEXTURE_WRAP_S where you are passing an enum you should use glTexParameteri but for other possible values such as GL_TEXTURE_MIN_LOD and GL_TEXTURE_MAX_LOD it makes sense to pass a float parameter using glTexParameterf.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
复制代码
#define GL_TEXTURE_WRAP_S 0x2802
#define GL_TEXTURE_WRAP_T 0x2803
复制代码
点采样方法:最近纹素的纹理值。
线性滤波:最近领域(2x2)纹素加权平均值。
复制代码