如何将从后台缓冲区获取的像素数据绘制回自身?
我正在使用 OpenGLES 开发 Symbian 5 版的移动应用程序。
这个应用程序是一个非常标准的 2D 应用程序,我没有使用 DepthBuffer。
我需要抓取显示的快照,然后将完全相同的快照绘制回后缓冲区。
我正在使用 glReadPixels((GLint)0, (GLint)0, (GLint)n宽度-1, (GLint)n高度-1, GL_RGB、GL_UNSIGNED_BYTE、m_pPixelData)
为了获取我需要的像素数据,但我对 OpenGLES 相当陌生,我不知道如何将数据绘制回后台缓冲区。 (在 OpenGL 中使用 DrawPixels 很容易......)
我读到我应该从数据生成纹理,所以我这样做了。 但现在我不知道如何绘制这个纹理。
我需要将其绘制为矩形元素的纹理吗?如果是这样,我该如何定义这个 rect ? (坐标对我来说没有意义..)
显示尺寸是 480x640,这是我想要用来绘制矩形的代码:
glEnable(GL_TEXTURE_2D);
//displayTex is my texture built out of the pixel data
glBindTexture(GL_TEXTURE_2D, m_pESSharedData->displayTex);
//Bottom
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-2.5f, -2.5f, 2.5f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(2.5f, -2.5f, 2.5f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(2.5f, -2.5f, -2.5f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-2.5f, -2.5f, -2.5f);
glEnd();
请注意,上面的代码是我一路上学到的东西,我想这就是我应该做的事情的概要。请随意让我离开这条轨道。 :)
感谢您抽出时间。
I'm working on a mobile application for Symbian 5th edition using OpenGLES.
This application is a pretty standard 2D app, and I make no use of the DepthBuffer.
I need to grab a snapshot of the display and then draw the very same snapshot back to the backbuffer.
I'm using glReadPixels((GLint)0, (GLint)0,
(GLint)nWidth-1, (GLint)nHeight-1,
GL_RGB, GL_UNSIGNED_BYTE, m_pPixelData)
in order to get the pixel data I need, but I'm rather new to OpenGLES and I don't know how to draw the data back to the backbuffer. (in OpenGL its easy using DrawPixels..)
I've read that I should generate a texture from the data, so I did.
But now I'm not sure how to draw this texture.
Do I need to draw it as a texture of a Rectangular element ? if so than how am I suppose to define this rect ? ( the coordinates just doesn't make sense to me..)
The display size is 480x640 and here is the code I want to use in order to draw the rect:
glEnable(GL_TEXTURE_2D);
//displayTex is my texture built out of the pixel data
glBindTexture(GL_TEXTURE_2D, m_pESSharedData->displayTex);
//Bottom
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-2.5f, -2.5f, 2.5f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(2.5f, -2.5f, 2.5f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(2.5f, -2.5f, -2.5f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-2.5f, -2.5f, -2.5f);
glEnd();
Note that above code is something I've picked up along the way, and I think this is the outline of what I'm suppose to do. feel free to take me off this track. :)
I thank you for your time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您首先需要确保Series60第5版上的OpenGL-ES版本可以处理高度和宽度不是2的幂的纹理。
我建议诺基亚论坛 进行此类查询。
无耻插件:
Symbian OS 快速食谱包含一整章解释 Symbian OS 上 OpenGL-ES 的基础知识。 3D 代码示例位于此处。
You first need to make sure that the version of OpenGL-ES on Series60 5th edition can handle textures whose height and width aren't powers of 2.
I would advise forum nokia for that kind of query.
Shameless plug:
Quick Recipes On Symbian OS contains a whole chapter explaining the basics of OpenGL-ES on Symbian OS. The 3D code samples are here.