简体   繁体   English

如何在openGL中划分窗口?

[英]how to divide a window in openGL?

I want to divide the window into 2 parts. 我想把窗口分成两部分。 Each part I can draw a different thing. 每个部分我都可以画出不同的东西。 How can I do that in openGL ? 我怎么能在openGL中做到这一点?

(Actually, my problem is I already drawn a picture on the window. Now I want to get some "space" out of it so I can draw something else. The original picture already took the whole window). (实际上,我的问题是我已经在窗口上画了一张照片。现在我想从中获取一些“空间”,这样我就可以画出其他内容。原始图片已经占据了整个窗口)。

I appreciate if anybody could help. 如果有人能提供帮助,我感激不尽。

Thanks. 谢谢。

请参阅glViewport的文档: man glViewport

You can use the glScissor command to do that. 您可以使用glScissor命令来执行此操作。 With glScissor, you'd split the screen in window coordinates and render to sub-parts of the screen. 使用glScissor,您可以在窗口坐标中分割屏幕并渲染到屏幕的子部分。 scissors protect parts of the already rendered output from being overwritten. 剪刀保护已渲染输出的部分不被覆盖。

glScissor is made for the case where you know the dimension of your respective sub-images beforehand. glScissor适用于事先知道各个子图像尺寸的情况。 If that is not the case, you'd have to go for a different solution. 如果情况并非如此,那么您必须寻求其他解决方案。

Depending on your specific scenario, you might instead want to render to different windows (although that could be troublesome with GLUT) or use a different approach, such as image-based rendering. 根据您的具体情况,您可能希望渲染到不同的窗口(尽管这可能会对GLUT造成麻烦)或使用不同的方法,例如基于图像的渲染。

There's a tutorial about drawing with multiple viewports on the NeHe site: 有关于在NeHe网站上绘制多个视口的教程:

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=42 http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=42

Hopefully it's somewhat useful. 希望它有点用处。

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

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