Click here to Skip to main content
15,895,142 members
Articles / Desktop Programming / WPF

OpenGL and WPF: Integrating an OpenGL Window inside a WPF Window

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
1 Mar 2024CPOL18 min read 2.6K   57   5  
Shows how to use OpenGL in a .NET WPF application by directly incorporating an OpenGL window as a child of the main WPF window, making it behave more like a control
This is an unconventional alternative to using WPF controls that are specifically designed for interoperability with OpenGL (such as OpenTK's GLWpfControl, or SharpGL's OpenGLControl). Instead, it simply creates an OpenGL window and adds it as a child window of the main WPF window, making it look a region of the main window. It stays "glued" to the main window, i.e., it moves with it and even resizes itself with the main window. There are advantages and disadvantages to this approach, which will be discussed in this article, but the undisputable advantage is unhindered performance - you get the original performance of OpenGL, not something that aspires to get close to it.

Views

Daily Counts

Downloads

Weekly Counts

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Retired
Canada Canada
Retired developer living in Vancouver, BC Canada. Still having the coding love.

Comments and Discussions