访问 ogre 中的视口像素值
我正在使用 C++ 开发 ogre 项目。通常我使用 viewport:setbackground() 但这会导致整个窗口颜色相同。这次我想为每个视口的像素加载不同的 R、G、B 值。我的窗口是 600*600,我必须加载每个像素的 RGB 值。我该如何解决这个问题?
I'm working on ogre project by using C++. Normally I use viewport:setbackground() but this cause whole window same colour. This time I want to load different R, G, B values for each viewport's pixel. My window is 600*600 and I have to load RGB values for each pixel. How can I solve this question ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果要设置背景,可以执行以下操作:
创建一个填充所有视口的矩形
创建材质和纹理
现在您可以将 RGB 数据直接复制到纹理帧缓冲区:
编辑 2011-11-10
< strong>data 必须是指向原始 RGB 帧缓冲区的有效指针。您可以初始化它:
然后将黄色直接写入位置 x,y 处的像素。
或者直接写入 texture->getBuffer() ( Ogre API:HardwarePixelBuffer)
...直接写入pixelbuffer ...
这个例子可以推广到其他宽度、长度、格式等...
您可以使用更优化的代码来查找缓冲区内的像素,这只是一个示例。
If you want to set a background you can do this:
Create a rectangle that fill all viewport
Create a material and texture
Now you can copy your RGB data directly to texture framebuffer:
EDIT 2011-11-10
data must be a valid pointer to a framebuffer of raw RGB. You can initialize it:
And than write yellow directly to pixel at position x,y.
Or write directly to texture->getBuffer() (Ogre API: HardwarePixelBuffer)
... write directly to pixelbuffer ...
This example can be generalized for other width, length, format etc...
You can use more optimized code to find pixel inside the buffer, this is just an example.