PDA

View Full Version : WinAPI with OpenGL



Mukund
08-28-2010, 02: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
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.

Ilian Dinev
08-28-2010, 03:50 PM
: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.

Aleksandar
08-29-2010, 04: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.

Mukund
08-30-2010, 04: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.

Aleksandar
08-30-2010, 05: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. ;)

Mukund
08-31-2010, 12:45 PM
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.