Advertisement

OGL in Picture Boxes

Started by January 15, 2001 05:35 PM
3 comments, last by gareththomas1 23 years, 10 months ago
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
Yeah, just get the handle of the picture box, and then generate a rendering context for it.

-- wav
Advertisement
Sounds good. But how exactly?
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
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

This topic is closed to new replies.

Advertisement