Jump to content
  • Advertisement

Archived

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

gareththomas1

OGL in Picture Boxes

This topic is 6513 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there anyway to get OpenGL graphics in a picture box in VC++ or VB? - or does the OpenGL rendering context HAVE to be in an entire window. If so, is there a work round? The goal is to have a window with controls/buttons/sliderbars etc and a bit where I can render OpenGL into (like most MD2/map viewers etc). Cheers Gareth

Share this post


Link to post
Share on other sites
Advertisement
Well its been ages since i coded in vb, and wouldnt have a clue as to how to even setup openGL in it. But below is some delphi code which is pretty easy to understand:

procedure FormCreate;
var pfd: TPixelFormatDescriptor;
FormatIndex: integer;
begin
fillchar(pfd,SizeOf(pfd),0);
with pfd do
begin
nSize := SizeOf(pfd);
nVersion := 1;
dwFlags := PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER;
iPixelType := PFD_TYPE_RGBA;
cColorBits := 8;
cDepthBits := 32;
iLayerType := PFD_MAIN_PLANE;
end;

glDC := GetDC(Handle);
FormatIndex := ChoosePixelFormat(glDC,@pfd);
SetPixelFormat(glDC,FormatIndex,@pfd);
GLContext := wglCreateContext(glDC);
wglMakeCurrent(glDC,GLContext);
end;

glDC is a global variable, and Handle can be replaced with PictureBox1.Handle in vb.

I think that would work.. Btw: not sure if you knew, but @ represents a pointer

-- Wav

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Try this link. You should be able to download an example by Brian Bailey that can do exactly what you want, but it is MFC though.

http://www.opengl.org/developers/faqs/technical/mswindows.htm#mswi0160

Joel

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!