Hi all,
Regarding to my recent post “glDrawArrays() issue with varying Texture Source” I’ve tried to Implement Image Rotation by using multiple FBO’s. I’m getting better performance in Opengl in PC(50% better performance). But there is reduced No performance improvement in OpenGLES in my OMAP 3 device. Pardon me if I did any silly mistakes.
Here are the problems I’m facing.
- Error in attaching the Texture objects. (Temporarily fixed by generating the Texture during Draw Process)
- NO Performance improvement noticed.
Here is my code snippet. Kindly give me your suggestions.
bool OGLES2Texturing::InitView(){<br />
LoadShaders();<br />
// Sets the clear color<br />
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);<br />
LoadVbos();//Load VBO's to Draw a QUAD with Textures<br />
LoadTextures(); // To Generate 3 Texture objects<br />
LoadImageBuffers();//To Load Source image Buffer(RGBA)<br />
LoadFBO();<br />
DrawOffScreen(0.6);<br />
return true;<br />
}<br />
void OGLES2Texturing::LoadTextures(){ //To Generate 3 Texture objects<br />
glGenTextures(3, m_TextureId);<br />
for (int i = 0; i < 3; i++) {<br />
glBindTexture(GL_TEXTURE_2D, m_TextureId<i>);<br />
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, g_ImageWidth, g_ImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,NULL);<br />
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);<br />
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);<br />
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);<br />
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);<br />
}<br />
glBindTexture(GL_TEXTURE_2D,0);<br />
}<br />
void OGLES2Texturing::LoadFBO(){ //To Generate 3 FrameBuffer objects<br />
glGenFramebuffers(3, m_auiFboId);<br />
for(int Index = 0; Index < 3; Index++) {<br />
glBindFramebuffer(GL_FRAMEBUFFER, m_auiFboId[Index]);<br />
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_TextureId[Index], 0);<br />
glClear(GL_COLOR_BUFFER_BIT);<br />
}<br />
glBindFramebuffer(GL_FRAMEBUFFER,0);<br />
}<br />
bool OGLES2Texturing::DrawOffScreen(GLfloat fAngle)<br />
{<br />
PVRTMat4 mRot,mTrans, mMVP;<br />
mTrans = PVRTMat4::Translation(0,0,0);<br />
mRot = PVRTMat4::RotationZ(fAngle);<br />
mMVP = mTrans * mRot ;<br />
for(int Index = 0; Index < 3; Index++) {<br />
<br />
glBindFramebuffer(GL_FRAMEBUFFER, m_auiFboId[Index]);<br />
glViewport(0,0,g_ImageWidth,g_ImageHeight);<br />
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);<br />
glClear(GL_COLOR_BUFFER_BIT);<br />
<br />
glUseProgram(m_uiProgramObject);<br />
<br />
glBindBuffer(GL_ARRAY_BUFFER, m_ui32VboId);<br />
glEnableVertexAttribArray(VERTEX_ARRAY);<br />
glVertexAttribPointer(VERTEX_ARRAY, 3, GL_FLOAT, GL_FALSE, m_ui32VertexStride, 0);<br />
<br />
glEnableVertexAttribArray(TEXCOORD_ARRAY);<br />
glVertexAttribPointer(TEXCOORD_ARRAY, 2, GL_FLOAT, GL_FALSE, m_ui32VertexStride, (void*) (3 * sizeof(GLfloat)));<br />
<br />
(1)glGenTextures(3, m_TextureId);//->Here is a bug if i didn't generate the Textures again here. the output sreen is Left empty. So I've added this line again. Correct me if i did anything wrong.<br />
<br />
glBindTexture(GL_TEXTURE_2D, m_TextureId[Index]);<br />
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, g_ImageWidth, g_ImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, SourceImageBuffer+(g_ImageSize*Index));<br />
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);<br />
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);<br />
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);<br />
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);<br />
<br />
int i32Location = glGetUniformLocation(m_uiProgramObject, "myPMVMatrix");<br />
glUniformMatrix4fv(i32Location, 1, GL_FALSE, mMVP.ptr());<br />
<br />
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);<br />
}<br />
GLubyte *pOutTexData = new GLubyte[g_ImageSize*g_No_of_Frames];<br />
memset(pOutTexData,0,g_ImageSize * g_No_of_Frames);<br />
for (int Index = 0; Index < 3; Index++) {<br />
glBindFramebuffer(GL_FRAMEBUFFER, m_auiFboId[Index]);<br />
glReadPixels(0,0,g_ImageWidth ,g_ImageHeight,GL_RGBA,GL_UNSIGNED_BYTE,pOutTexData+(g_ImageSize*Index));<br />
}<br />
Write_pOutTexData_to File();<br />
glBindBuffer(GL_ARRAY_BUFFER, 0);<br />
glBindFramebuffer(GL_FRAMEBUFFER, 0);<br />
return true;<br />
}
```<br />
<br />
<br />
<br />
</i>