haj has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks,
Occasionally I am playing with 3D graphics. I had some fun doing it in a Tk::Canvas, but ... as the complexity of the 3D objects increases, that's getting painfully slow. So I've been looking for alternatives, starting with OpenGL.
I could not fail noticing that the Perl OpenGL project is a bit stale, with a newsfeed ending in 2007. On the plus side, I succeeded in translating the examples from The Official Guide to Learning OpenGL, Version 1.1 from C to Perl rather easily. Fortunately, this guide is about the same age as the Perl module.
Things get a bit murky when I want to integrate OpenGL drawing into my Tk application. The examples directory in the OpenGL distribution contains a tk_demo.pl script, and hooray, this script works out of the box.
But: This script integrates the OpenGL window with a subroutine glpOpenWindow. This subroutine is part of the Perl module OpenGL, but not exactly documented, and also not part of any OpenGL standard. The C examples in the Guide (and many other examples I found online) use GLUT functions like glutCreateWindow: this function is well documented in OpenGL, and also offered by the OpenGL module. Unfortunately glutCreateWindow creates a top-level window, whereas I would like to use it within my Tk widget. Windows created with glpOpenWindow can use a Tk widget as "parent", but I have no idea how to do the equivalent of GLUT functions like glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); for this window. The call doesn't fail, it just doesn't do anything. Some GLUT functions, e.g. glutFullScreen, bail out with a freeglut message ERROR: Function <glutFullScreen> called with no current window defined.
So that's the question: Has someone a pointer or example how to use the GLUT window subroutines within a Tk widget? Or, as an alternative, how to get a depth buffer activated with a glpOpenWindow window?
BTW: Prima offers Prima::GLWidget which is a direct widget for OpenGL drawing. This works nicely, and I could re-write my Tk applicaton for Prima. Only, I'm not familiar with Prima, and would prefer to avoid the effort.
|
---|