[Prev][Next][Index][Thread]
DUIM and OpenGL
I would like to use Dylan--and specifically DUIM-- to learn about and
experiment with OpenGL. One of the first things you need to be able to do
to use OpenGL on Windows is to set up the pixel format descriptor. In order
to do this you need to know the window handle so that you can then call
getDC to obtain the drawing context. Is there a way to get at the window
handle from DUIM?
I've included a snippet of code from the DUIM-gl-demo project as an
illustration of what Keith Playford (of Harlequin) did. He seems to use
some DUIM internals to obtain what must amount to a window handle using
something called "mirrors". I don't understand this. If I want to use
DUIM, am I then forced to use this DUIM internal stuff? Or is there some
method which I can call in the base DUIM to get a window handle?
Here's how Keith Playford did it:
define method handle-repaint
(pane :: <gl-pane>, medium :: <medium>, region :: <region>) => ()
next-method();
let mirror = sheet-mirror(pane);
let dc = get-DC(mirror);
if (~pane-gl-initialized?(pane))
setup-pixel-format(dc);
// TODO: Destroy this context when this pane is destroyed.
let ghRC = wglCreateContext(dc);
pane-gl-context(pane) := ghRC;
wglMakeCurrent(dc, ghRC);
handle-initialize-scene(pane, medium);
pane-gl-initialized?(pane) := #t;
end;
wglMakeCurrent(dc, pane-gl-context(pane));
handle-repaint-scene(pane, medium);
SwapBuffers(dc);
end method;
Follow-Ups: