Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

perl/TK and OpenGL

by orange (Beadle)
on Feb 27, 2009 at 08:33 UTC ( #746809=perlquestion: print w/replies, xml ) Need Help??
orange has asked for the wisdom of the Perl Monks concerning the following question:

i have tried the example in "mastering perl/tk" book chapter 15 about embedding opengl in tk window as in the following code:
#!/usr/local/bin/perl # Embedding OpenGL in a Tk Toplevel. use Tk; use OpenGL; $mw = MainWindow->new; $mw->Button(-text => 'OpenGL Demo', -command => \&opengl)->pack; $mw->Button(-text => 'Quit', -command => \&exit)->pack; sub opengl { $top = $mw->Toplevel(qw/-width 500 -height 500 -background pink/); $top->title('OpenGL Demo'); $top->waitVisibility; glpOpenWindow(parent=> hex($top->id), width => 450, height => 450); glClearColor(0, 0, 1, 1); glClear(GL_COLOR_BUFFER_BIT); glOrtho(-1, 1, -1, 1, -1, 1); glColor3f(0, 1, 0); glBegin(GL_POLYGON); $pi = 3.141592654; $d2r = $pi / 180.0; $nvert = 8; $dangle = 360 / $nvert; for ($angle = 0; $angle <= 359; $angle += $dangle) { $x = cos($angle * $d2r); $y = sin($angle * $d2r); glVertex2f($x, $y); } glEnd; glFlush; } MainLoop;
it is supposed to draw a polygon, but i get just a cleared window, and in the dos console there is an error message like this picture:
C:\temp>perl opengl1
Tk::Error: Can't locate auto/OpenGL/ in @INC (@INC contains: c:/perl/site/lib c:/perl/lib .) at opengl1 line 16
Carp::croak at c:/perl/lib/ line 44
AutoLoader::AUTOLOAD at c:/perl/lib/ line 47
OpenGL::glpOpenWindow at c:/perl/site/lib/ line 6049
main::opengl at opengl1 line 16
Tk callback for .button
Tk::__ANON__ at c:/perl/site/lib/ line 250
Tk::Button::butUp at c:/perl/site/lib/Tk/ line 175
(command bound to event)
also the tk_demo in the opengl package from cpan give me the same error.
i am running windows xp
i have activestate perl 5.10 with tk version 804.028 from:
and opengl 0.56 from: and it is automatically will install FreeGLUT package
any ideas.
thank you

Replies are listed 'Best First'.
Re: perl/TK and OpenGL
by zentara (Archbishop) on Feb 27, 2009 at 13:24 UTC
    All I can say is getting OpenGL to work properly is a trick in add it to Tk is another high hurdle.....and to do it on MSWindows (which dosn't use OpenGL as standard) is a real high jump. Good Luck.....I've yet to see anyone get that to work, and you might consider other options like SDL, see Use SDL-OpenGL with Gtk2 or Tk

    I'm not really a human, but I play one on earth My Petition to the Great Cosmic Conciousness
Re: perl/TK and OpenGL
by wazoox (Prior) on Feb 27, 2009 at 16:02 UTC
    Perhaps are you ready to try the beautifully impressive TK::Zinc instead?
      thanks for refering to tk-zinc, i have installed it today using the ppm from: for perl 5.10, yes it is beautiful, i have tried successfully the good tutorials from zentara:
      i will send a letter to to make sdl-perl ppm for perl 5.10, they have on their site a ppm for 5.58 best regards

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://746809]
Approved by almut
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2018-06-24 06:09 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.