View Full Version : WinAPI with OpenGL

08-28-2010, 01:46 PM
Hello Everyone.
i was wondering if it is possible to integrate the WinAPI functions withe the OpenGL functions.
By integrate, i mean use them together.

Well, i tried this, and for the WM_LBUTTONDOWN message, i just gave
glVertex2d(100, 100);

But nothing happened. But since OpenGL uses the native windowing system, is there a way i can do


Also, can i have an OpenGL callback as well as the Windows callback mechanisms(im referring to the

Window procedure)?

i need to do this in order to use the rich Graphic library of OpenGL for 3D graphics. i do not have

any knowledge about D3D.

Can anyone please tell me if i can do this?
Thanks in advance.

Ilian Dinev
08-28-2010, 02:50 PM
:S 70+ posts, 5-stars?

Just have this:

void OnRender(){
//------[ render SCENE ]------[

And call it from wherever you like: after processing a WM_ message, or a loop (with a PeekMessage() pump).

Without double-buffering, you're in for some trouble.

08-29-2010, 03:02 AM
And make your GL context current.
If you are mixing different APIs or several rendering threads with the same context, or using the same context for multiple windows, you should bind and release GL context with every drawing call.

08-30-2010, 03:44 AM
Thanks a lot Aleksandar, Ilian Dinev.

@Ilian Dinev
i have no idea how i had got those 5 stars! :D
it has become 3 now.

08-30-2010, 04:23 AM
The problem with stars is that the statistic depends on the number of people that have been voting for you. If there is only one and he/she gave you 5 stars, you will have 5 starts. But if the next one gives you one star, you'll have 3. But don't wary, having more votes it will be harder to change. :)

Nevertheless, this way of voting is not appropriate. Neither do I deserve (now) four stars. ;)

08-31-2010, 11:45 AM
Yeah it is not appropriate. i have taken more a lot from the forum than i have contributed. i dont deserve a single star.

Anyways i guess the thread is going off topic now.