2 Texture && PRVShell
来源:互联网 发布:mac上用的无线鼠标 编辑:程序博客网 时间:2024/05/17 03:23
// Fragment and vertex shaders code
const char* pszFragShader = "/
uniform sampler2D sampler2d;/
varying mediump vec2 myTexCoord;/
void main (void)/
{/
gl_FragColor = texture2D(sampler2d,myTexCoord);/
}";
const char* pszVertShader = "/
attribute highp vec4 myVertex;/
attribute mediump vec4 myUV;/
uniform mediump mat4 myPMVMatrix;/
varying mediump vec2 myTexCoord;/
void main(void)/
{/
gl_Position = myPMVMatrix * myVertex;/
myTexCoord = myUV.st;/
}";
1. 顶点数据格式为pos + uv
在link Program object之前需要绑定attribute
// Create the shader program
m_uiProgramObject = glCreateProgram();
// Attach the fragment and vertex shaders to it
glAttachShader(m_uiProgramObject, m_uiFragShader);
glAttachShader(m_uiProgramObject, m_uiVertexShader);
// Bind the custom vertex attribute "myVertex" to location VERTEX_ARRAY
glBindAttribLocation(m_uiProgramObject, VERTEX_ARRAY, "myVertex");
// Bind the custom vertex attribute "myUV" to location TEXCOORD_ARRAY
glBindAttribLocation(m_uiProgramObject, TEXCOORD_ARRAY, "myUV");
// Link the program
glLinkProgram(m_uiProgramObject);
2. 设置使用level 0的图片
// Actually use the created program
glUseProgram(m_uiProgramObject);
// Sets the sampler2D variable to the first texture unit
glUniform1i(glGetUniformLocation(m_uiProgramObject, "sampler2d"), 0);
3. gen texture, gen vbo
4. render loop:
传matrix, pos, uv给shader
about shell:
PowerVR对跨平台进行的封装。
入口程序在PVRShellOS.cpp里面,在windows下面是winmain,它会调用到PVRShellInit,这个是在PVRShellAPI.cpp中的.
应用程序需要继承PVRShell,实现Init/Release App/view,和RenderScene,另外就是一个Shell的NewDemo方法。
ShellOS会先New一个Shell,然后传递给ShellInit,进行初始化,之后将透过ShellInit中的API调用到应用程序.
- 2 Texture && PRVShell
- Texture
- texture
- 二维纹理 Texture 2D
- 二维纹理 Texture 2D
- OpenGL学习:2D texture
- OpenGL之纹理贴图(2):Texture Objects
- AndEngine:关于Texture的质量(2)
- Unity_二维纹理 Texture 2D_1_Properties 属性
- Unity_二维纹理 Texture 2D_1_Properties 属性
- Directx 将2D texture转换成Volume Texture的方法
- WJ的Direct3D简明教程2:Render-To-Texture
- Cocos2d-x3.2下Lua,UserDefault、Texture的使用
- Unity_二维纹理 Texture 2D_2_高级纹理
- Unity_二维纹理 Texture 2D_3_按平台覆盖
- Unity_二维纹理 Texture 2D_4_总结细节
- Unity_二维纹理 Texture 2D_2_高级纹理
- Unity_二维纹理 Texture 2D_3_按平台覆盖
- JAVA反射机制定义
- Javascript在jsp页面的使用(一)
- POJ 3207 2-sat
- SAP ABAP 学习路线图
- live555库
- 2 Texture && PRVShell
- 安装Android SDK时出错解决
- 男生英文名大全
- java的addShutdownHook
- 互加好友 有积分送 兄弟帮忙啊
- 泛型入门
- FAQ of the ucos_ii&ucgui
- jquery方式提交中文乱码问题
- c++创建文件夹