简体   繁体   English

如何将OpenGL嵌入到Win32应用程序中?

[英]How to embed OpenGL into a Win32 application?

First of all, my understanding of both Win32 and OpenGL might be entirely wrong. 首先,我对Win32OpenGL理解可能完全错误。 Because of that, don't hesitate to question any assumption I'll make within my following question. 因此,请毫不犹豫地质疑我将在以下问题中做出的任何假设。

What I'm asking here isn't anything new; 我在这里问的不是什么新东西; there are quite a few popular libraries that are already implementing what I'm talking about! 有很多流行的图书馆已经在实施我正在谈论的内容! A good example would probably be GLFW . 一个很好的例子可能是GLFW

Therefore, I'm explicitly not asking for a recommendation. 因此,我明确没有要求推荐。 I'd like to know instead what these libraries are doing in the background. 我想知道这些库在后台正在做什么。 After looking at the actual implementation of GLFW , I figured that the process of creating and interacting with the actual GUI is completly independent of OpenGL itself. 在查看了GLFW的实际实现GLFW ,我发现创建和与实际GUI交互的过程完全独立于OpenGL本身。 Let me try to express myself better in the following beautiful piece of art. 让我尝试在以下精美的艺术品中更好地表达自己。

在此输入图像描述

Is that assumption correct? 这个假设是否正确? How would you then draw OpenGL onto a texture within the GUI ? 那么你如何将OpenGL绘制到GUI的纹理上呢?

And in the case that it isn't correct, then how in the world is it actually implemented? 如果它不正确,那么世界上它实际上是如何实现的呢?

Alright, first of all, I would like to thank @derhass for providing me with sufficient information to resolve my question. 好吧,首先,我要感谢@derhass为我提供了足够的信息来解决我的问题。 Therefore, all credit is going to him! 因此,一切归功于他!

Let's get straight to the answer: the crucial piece I was missing was the bridge between OpenGL and Win32 itself - wgl , namely. 让我们直接得到答案:我缺少的关键部分是OpenGLWin32本身之间的桥梁-wgl That application programming interface is then able to embed a "framebuffer" into the Win32 graphical user interface. 然后,该应用程序编程接口可以将“帧缓冲区”嵌入Win32图形用户界面。

According to @Spektre , the GetDC(Handle) method can even bind OpenGL to a component on the graphical user interface itself. 根据@SpektreGetDC(Handle)方法甚至可以将OpenGL绑定到图形用户界面本身上的组件。

I'd highly suggest anyone to take a look at each linked question - they contain a few examples concerning the use of wgl . 我强烈建议任何人看看每个链接的问题 - 它们包含一些关于wgl使用的wgl

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

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