简体   繁体   English

在两个不同的位置渲染OpenGL场景

[英]Render OpenGL scene at two different locations

I am writing an application that renders an OpenGL scene. 我正在编写一个渲染OpenGL场景的应用程序。 This application has two windows: 该应用程序有两个窗口:

  1. A large window that shows only the rendered scene 一个只显示渲染场景的大窗口
  2. A "control window" that offers several settings and a preview of the rendered scene 提供多个设置和渲染场景预览的“控制窗口”

This application is written in .NET (for the control window part) and uses a native C++ DLL to create the rendering window and do the actual OpenGL rendering. 此应用程序用.NET编写(用于控制窗口部分),并使用本机C ++ DLL创建渲染窗口并进行实际的OpenGL渲染。

This works fine, but one important part is still missing: getting a live preview of the rendered scene into my .NET control window. 这可以正常工作,但是仍然缺少一个重要的部分:将渲染场景的实时预览放入我的.NET控制窗口中。

So far I could think of two solutions: 到目前为止,我可以想到两种解决方案:

  1. Render the scene not only to the screen, but also to memory. 不仅将场景渲染到屏幕,还渲染到内存。 Then shove that blob of memory to my .NET WinForm. 然后将那一堆内存推到我的.NET WinForm中。 Finally draw the image to a PictureBox or something. 最后将图像绘制到PictureBox或其他东西上。 <- This sounds horribly slow! <-这听起来太慢了!
  2. Make my native OpenGL renderer render the scene twice, once to the native full size window, once to a control (panel?) on my .NET form. 使我的本机OpenGL渲染器两次渲染场景,一次渲染到本机全尺寸窗口,一次渲染到.NET窗体上的控件(面板?)。

Option 2 sounds faster, but I have no idea if/how that even works. 选项2听起来更快,但我不知道它是否/如何工作。 Can this be done? 能做到吗? Are there better alternatives? 有更好的选择吗?

Look into the documentation on framebuffers . 查看有关framebuffers的文档。 It is basically the destination of your rendering, by default it's your viewport (or the backbuffer , which switches with the displayed buffer once it's ready). 它基本上是渲染的目标,默认情况下是您的视口(或backbuffer ,一旦准备好,它将与显示的缓冲区一起切换)。

The first option should generally be faster as you render the scene once and then just basically copy a texture. 通常,第一个选项应该更快,因为您一次渲染场景,然后基本上只复制纹理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM