Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.


In reply to Graphics: OpenGL in Perl/Tk ... with GLUT by haj

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2024-04-24 23:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found