<p>GLUT owns the window it creates. It can't share it with WPF, nor can it use a window created by WPF.</p>
<p>If you want to have an OpenGL application render to a window owned by WPF, that may be possible, but you can't use GLUT for that. You'd have to manually attach OpenGL to the window and manage all of the stuff GLUT otherwise does.</p>
<p>Also, most WPF &quot;windows&quot; are not Win32 HWNDs. So OpenGL cannot render to them. You'd need to make sure that the window is an actual HWND.</p>

CC BY-SA 4.0
2022-06-08T14:50:39.473Z
Can you tell me how I can get the HWND in GLFW or some other OpenGL library since GLUT can't do that?
Arjan Singh
CC BY-SA 4.0
2022-06-08T14:54:28.943Z
Would Mouse Input work as if it were running natively in C++ if I render to a form or WPF?
Arjan Singh
CC BY-SA 4.0
2022-06-08T15:17:27.433Z
@ArjanSingh: The GLFW docs have an entire section on native access.
Nicol Bolas
CC BY-SA 4.0
2022-06-08T16:09:57.417Z
I looked at the section and there is only a function to get the HWND and not set it. Am I missing something or is there no option to be able to pass GLFW a handle to render to?
Arjan Singh
CC BY-SA 4.0
2022-06-08T16:20:23.050Z
@ArjanSingh: "*not set it*" Yeah. You can access GLFWs window, but you can't make it *adopt* yours. If you need to control the window's creation, then you're going to have to manage OpenGL *yourself*.
Nicol Bolas
CC BY-SA 4.0
2022-06-07T20:48:35.130Z
2022-06-07T20:48:35.130Z
Nicol Bolas
<p>I want to render my OpenGL GLUT project to a window/control in C# WPF. I have read articles online from Microsoft on how to do it but I am very confused.</p>
<p>Does anyone have any experience with this? Could someone walk me through it with code? What are some other good ways to create a UI?</p>

<opengl><c++><glut><c#>
How to give C++ GLUT project an Editor/UI?
Arjan Singh
# How to give C++ GLUT project an Editor/UI?

(Asked by: username_0 on 2022-06-07)

I want to render my OpenGL GLUT project to a window/control in C# WPF. I have read articles online from Microsoft on how to do it but I am very confused.

Does anyone have any experience with this? Could someone walk me through it with code? What are some other good ways to create a UI?

**Tags:** opengl, c++, glut, c#


---

## 1 answers

### Answer by username_1 on 2022-06-07. Score: 2

GLUT owns the window it creates. It can't share it with WPF, nor can it use a window created by WPF.

If you want to have an OpenGL application render to a window owned by WPF, that may be possible, but you can't use GLUT for that. You'd have to manually attach OpenGL to the window and manage all of the stuff GLUT otherwise does.

Also, most WPF "windows" are not Win32 HWNDs. So OpenGL cannot render to them. You'd need to make sure that the window is an actual HWND.

> **Comments:**
> **username_0**: Can you tell me how I can get the HWND in GLFW or some other OpenGL library since GLUT can't do that?  
> **username_0**: Would Mouse Input work as if it were running natively in C++ if I render to a form or WPF?  
> **username_1**: @username_0: The GLFW docs have an entire section on native access.  
> **username_0**: I looked at the section and there is only a function to get the HWND and not set it. Am I missing something or is there no option to be able to pass GLFW a handle to render to?  
> **username_1**: @username_0: "*not set it*" Yeah. You can access GLFWs window, but you can't make it *adopt* yours. If you need to control the window's creation, then you're going to have to manage OpenGL *yourself*.  

---

