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)紋素加權平均值。
複製代碼