OGL in Picture Boxes
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
-- wav
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
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
January 17, 2001 04:43 PM
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
http://www.opengl.org/developers/faqs/technical/mswindows.htm#mswi0160
Joel
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement