PDA

View Full Version : Drawing on more than one form at a time.



John Jenkins
09-24-2002, 06:36 AM
I want to have two or mor opengl graphs going at the same time. How can I do this?

mikael_aronsson
09-24-2002, 09:44 AM
Hi !

Depends on what you mean, if you want many "views" in one single windows, then you can do that by changing the glViewport, draw one "graph" then change the viewport again and draw the next and so on.

If you mean draing in more then one window, then it depends on what kind of environment you are developing in, but each windows has an OpenGL context, when you want to draw to a specific window you must first activate the context that is owned by that window, by switching to another context you can then draw to another window.

Mikael

John Jenkins
09-24-2002, 10:30 AM
How do you change the viewport? Do you just reset it with different values? I looked it up in my book. Can I just divide a form into several areas and then draw separate viewports using glviewport?

Also, our program will need the ability to draw onto different forms. I knew I had to change the context but I am having trouble changing it, or I am just doing it wrong. Any suggestions?

mikael_aronsson
09-24-2002, 11:26 AM
Hi !

Say you have a window that has a width of 400 pixels a height of 300 pixels, if you want to split this into to parts (a vertical split) so you get two viewports side by side.

glViewport( 0, 0, 200, 300);
... render into this viewport now
glViewport( 200,0, 200, 300);
... render into this viewport now

You can look at the viewport as a subwindow inside the actual window, so by changing the viewport you define what area to render into.

I hope that helps a bit.

Mikael

mikael_aronsson
09-24-2002, 11:30 AM
Hi again !

What kind of problem do you have with the context switching ?

In C (on windows) you activate the context with:
wglMakeCurrent( hDC, hRC);

That's all, make sure you don't get NULL handles or error messages from wglCreateContext and so on of course.

Mikael

John Jenkins
09-24-2002, 11:44 AM
Thanks I think I understand. I will give it a try.

John Jenkins
09-25-2002, 04:59 AM
The glviewport works. I have a special note for the other VB programmers out there. Don't use the parenthesis. Use it like this: glViewPort 100,100,50,40

Deiussum
09-25-2002, 06:17 AM
Originally posted by John Jenkins:
The glviewport works. I have a special note for the other VB programmers out there. Don't use the parenthesis. Use it like this: glViewPort 100,100,50,40

That's because in VB, parenthesis are only used when you are getting a returned value, such as this:

someVal = SomeFunction(parameters)

That same function is used like so when not getting the return value:

SomeFunction parameters

Or if are like me and like using parenthesis, you can also do this:

call SomeFunction(parameters)

Just one of those stupid little VB quirks.