1
votes

I am developing a plug-in in C++ inside a 3rd party program and need to display a window with OpenGL. I want to program in Win32 directly (ie. not use MFC or other wrappers).

I downloaded NeHes Win32 tutorial and compiled and ran it succesfully on my machine.

However this is a main program that loops and calls PeekMessage and then TranslateMessage and DispatchMessage if there was any message and redraws the OpenGL if not.

I want to "spawn-off" a Win32 OpenGL window and then return control to the 3rd party program:

void DisplayOpenGLWindow_ButtonPressed() {
 CreateWindowEx(...);
 InitOpenGL(...);
 return;
}

But how do I get the new window to redraw the OpenGL scene? I tried to add a call to redraw OpenGL inside the callback function:

case WM_PAINT:
{
   DrawGLScene();   
   return 0;
}

But this is not working; the window is all white even if the clear color is black. Resizing and moving the window does not help.

1
Thanks fen! Looks like a good start.Andy
Why do you not want to use any wrappers? I strongly recommend using GLFW or some equivalent to do this kind of thing for you.Eric B

1 Answers

0
votes

The answer would be quite large, so I direct you to some tutorials instead :)

links:

Nehe uses Win32 api mostly, so for look for MFC tutorials/articles instead.

Another thing: try to fucus on modern opengl, version 3. and above.