Archived

This topic is now archived and is closed to further replies.

daryoushj

OpenGL in VB

Recommended Posts

Hi, I am a software developer and recently started working with OpenGL in VB. In doing this, I have a program that draws a simple 3D graph (and rotates it, etc.) based on an input file. But, somehow I haven''t been able to perform any of the folowing three tasks: 1. Print the graph using PrintForm (it prints out an empty form which contains everything else on the form except the drawn graph!?!?!) 2. Save the plot in an image file using SavePicture (it saves a BMP file containing an empty frame) or any other means for any other format (which I do not know!!) 3. Copy the graph to the (Windows) ClipBoard so that it can then be pasted in some other application such as MS-WORD (it behaves just like the SavePicture command! copies an empty frame) Can you please help me on any of the above? My highest appreciation is attached! Daryoush Javan djavan@thundersort.com

Share this post


Link to post
Share on other sites
When drawing on a picture box the autorefresh is set to false, in order to draw correctly. However in order to save you need to have a picture box with the autorefresh set to true.

An easy way to do this is to have a second picture box and then use the api call of:

Private Declare Function BitBlt Lib "GDI32" ( _
ByVal hDCDest As Long, ByVal XDest As Long, _
ByVal YDest As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal hDCSrc As Long, _
ByVal XSrc As Long, ByVal YSrc As Long, ByVal dwRop As Long)As Long

to copy the data from the first picture box to the second, then hide the first box and show the second.

Like this (assuming that

''in the save portion of the vb code

Me.picSave.AutoRedraw = True
Me.picSave.Visible = True

BitBlt Me.picSave.hDC, 0, 0, Me.picMain.ScaleWidth, Me.picMain.ScaleHeight, Me.picMain.hDC, 0, 0, vbSrcCopy

SavePicture Me.picSave.Image, filename

I''ve got a cool demo of saving 3d fonts available at:

http://www.quomation.com/ogl/fonts3d-lesson14.exe

It includes full source of how I saved the opengl rendered image to a bmp file. Printing would be the same way, except you wouldn''t use the "SavePicture" command.

Share this post


Link to post
Share on other sites