简体   繁体   中英

How to embed OpenGL into a Win32 application?

First of all, my understanding of both Win32 and OpenGL might be entirely wrong. 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 .

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. 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 ?

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. 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. That application programming interface is then able to embed a "framebuffer" into the Win32 graphical user interface.

According to @Spektre , the GetDC(Handle) method can even bind OpenGL to a component on the graphical user interface itself.

I'd highly suggest anyone to take a look at each linked question - they contain a few examples concerning the use of wgl .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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