PDA

View Full Version : Open GL Device Context and VB



02-11-2001, 10:38 AM
Hello, I'm David.
I'm adding some other graphics features to a charts engine written with
Visual Basic (ActiveX/COM).
That's the problem:
I used a VB sample that I have downloaded from NeHe website.
It uses the form Device Context (frm.hDC) to draw primitives. these are the
statements:

........ [other init statements]
PixelFormat = ChoosePixelFormat(frm.hDC, pfd)
If PixelFormat = 0 Then ' Did Windows Find A
Matching Pixel Format?
KillGLWindow ' Reset The Display
MsgBox "Can't Find A Suitable PixelFormat.", vbExclamation, "ERROR"
CreateGLWindow = False ' Return FALSE
End If

If SetPixelFormat(frm.hDC, PixelFormat, pfd) = 0 Then ' Are We Able To
Set The Pixel Format?
KillGLWindow ' Reset The Display
MsgBox "Can't Set The PixelFormat.", vbExclamation, "ERROR"
CreateGLWindow = False ' Return FALSE
End If

I don't want to see the image on a form but I would like to build it in
memory.
I tried to create a compatible Device Context: hDCC=CreateCompatibleDC(0)
and then used instead of frm.hDC.
When I Try to set the PixelFormat I get an error (... .can't set the pixel
format.... ) ok....
Why?
Is it not possible to draw with OpenGL on a DC different from the Form DC?

Thanks in advance.
David

brainkiller@progcenter.com

Dire_Avenger
02-13-2001, 07:58 AM
No idea http://www.opengl.org/discussion_boards/ubb/smile.gif
How about creating a (visible) form, rendering the image to it, then hiding it/moving it to 9000x9000/<insert your favourite 'invisible form' method here>
Hope that helps!

DFrey
02-13-2001, 08:22 AM
What you are describing David, is a p-buffer. OpenGL does not currently support p-buffers. They may be available as an extension, but not with any consumer grade video card I don't think (yet anyway). However you can select a pixelformat with PFD_DRAW_TO_BITMAP (in dwFlags). Though if you do get such a pixelformat, the Microsoft software OpenGL rasterizer will likely be used rather than hardware.

02-14-2001, 01:39 AM
Hi Dire_Avenger,
this is an activeX DLL, usually without forms. I said also that this is a server component. I cannot build a form (or invisible form) everytime a user request a web page.... http://www.opengl.org/discussion_boards/ubb/smile.gif
It's a good idea, but it is not possibile in this situation. I noticed also that I cannot use the Autoredraw attribute on a form when I use OpenGL. If I make the form invisible, I lose the image.


Thank You, DFrey....
I tried also with PFD_DRAW_TO_BITAMP, but no change. Finally I found a complex example. I think I need to build a DIB Image (built in memory), applying pixelformat, and then blitting the image on the form or saving it to disk.
Probably, it's the right solution.

Thank you again.