WinAPI with OpenGL

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
glBegin(GL_POINTS);
glVertex2d(100, 100);
glEnd();

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

this?

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.

:S 70+ posts, 5-stars?

Just have this:


void OnRender(){
	glClear(...);
	//------[ render SCENE ]------[
	...
	//----------------------------/
	SwapBuffers(hdc);
}

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.

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.

Thanks a lot Aleksandar, Ilian Dinev.

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

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. :slight_smile:

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

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.