如何在 OpenGL 中使用橡皮筋
我正在尝试在 OpenGL 和 Visual Studio C++ 中找到一种橡皮筋的方法。我遇到的问题是一些 Win 7 计算机(即我的老板)不允许我读取或绘制到前端缓冲区,从而杀死直接绘制到它的操作。
glDrawBuffer( GL_FRONT );
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp( GL_XOR );
glPolygonMode(GL_FRONT, GL_LINE);
glRecti(X0, Y0, X1, Y1);
X1 = X;
Y1 = Y;
glRecti(X0, Y0, X1, Y1);
*//Doesn't draw lines*
或者将前缓冲区复制到后缓冲区(重新绘制需要很长时间)调用交换缓冲区绘制然后再次交换有
glReadBuffer( GL_FRONT );
glDrawBuffer( GL_BACK );
glCopyPixels(0, 0, Width, Height, GL_COLOR);
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp( GL_XOR );
glPolygonMode(GL_BACK, GL_LINE);
SwapBuffers(hdc);
glRecti(X0, Y0, X1, Y1);
X1 = X;
Y1 = Y;
glRecti(X0, Y0, X1, Y1);
SwapBuffers(hdc);
*//Doesn't display original drawing*
什么想法吗?
I'm trying to find a way to rubber band in OpenGL and Visual Studio C++. The problem I'm coming across is some Win 7 computers (i.e. My boss') won't allow me to read or draw to the front buffer thus killing drawing straight to it.
glDrawBuffer( GL_FRONT );
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp( GL_XOR );
glPolygonMode(GL_FRONT, GL_LINE);
glRecti(X0, Y0, X1, Y1);
X1 = X;
Y1 = Y;
glRecti(X0, Y0, X1, Y1);
*//Doesn't draw lines*
or copying the front buffer to the back buffer (redrawing to it would take to long) calling a swapbuffers drawing and then swaping agian
glReadBuffer( GL_FRONT );
glDrawBuffer( GL_BACK );
glCopyPixels(0, 0, Width, Height, GL_COLOR);
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp( GL_XOR );
glPolygonMode(GL_BACK, GL_LINE);
SwapBuffers(hdc);
glRecti(X0, Y0, X1, Y1);
X1 = X;
Y1 = Y;
glRecti(X0, Y0, X1, Y1);
SwapBuffers(hdc);
*//Doesn't display original drawing*
any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会这样做:
之后,在屏幕上绘制图像,您可以只绘制一个覆盖整个渲染区域的四边形,并使用创建的纹理进行纹理化。这样,在将图像绘制到屏幕上时无需重新渲染实际场景。
现代 OpenGL 实现还可以渲染到纹理,无需将图像移至主内存并返回。话又说回来,如果渲染场景已经很慢,那么这里的性能差异不会很明显。
I'd do it like this:
After this, to draw the image on screen, you can just draw a single quad covering the whole render area, textured with created texture. This way there's no need to re-render the actual scene when drawing the image to screen.
Modern OpenGL implementations can also render to texture, with no need to move the image to main memory and back. Then again, if rendering the scene is already slow, the performance difference here won't be noticeable.