Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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:

hello
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:
http://sites.google.com/site/zak31415/Home/tkOpenglErr.JPG
C:\temp>perl opengl1
Tk::Error: Can't locate auto/OpenGL/glpcOpenWin.al in @INC (@INC contains: c:/perl/site/lib c:/perl/lib .) at opengl1 line 16
Carp::croak at c:/perl/lib/Carp.pm line 44
AutoLoader::AUTOLOAD at c:/perl/lib/AutoLoader.pm line 47
OpenGL::glpOpenWindow at c:/perl/site/lib/OpenGL.pm line 6049
main::opengl at opengl1 line 16
Tk callback for .button
Tk::__ANON__ at c:/perl/site/lib/Tk.pm line 250
Tk::Button::butUp at c:/perl/site/lib/Tk/Button.pm line 175
<ButtonRelease-1>
(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:
http://cpan.uwinnipeg.ca/PPMPackages/10xx/
and opengl 0.56 from:
http://www.bribes.org/perl/ppmdir.html and it is automatically will install FreeGLUT package
any ideas.
thank you

Comment on perl/TK and OpenGL
Download Code
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 itself.....to 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:http://www.bribes.org/perl/ppmdir.html for perl 5.10, yes it is beautiful, i have tried successfully the good tutorials from zentara:
      http://zentara.net/zinc/
      i will send a letter to bribes.org to make sdl-perl ppm for perl 5.10, they have on their site a ppm for 5.58 best regards

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://746809]
Approved by almut
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2014-08-01 10:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (0 votes), past polls