~ubuntu-branches/ubuntu/lucid/pdl/lucid

« back to all changes in this revision

Viewing changes to Graphics/TriD/OpenGL/test.pl

  • Committer: Bazaar Package Importer
  • Author(s): Ben Gertzfield
  • Date: 2002-04-08 18:47:16 UTC
  • Revision ID: james.westby@ubuntu.com-20020408184716-0hf64dc96kin3htp
Tags: upstream-2.3.2
ImportĀ upstreamĀ versionĀ 2.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
use FileHandle;
 
3
use strict;
 
4
use warnings;
 
5
use Carp;
 
6
 
 
7
$SIG{__DIE__} = sub {print Carp::longmess(@_); 
 
8
                                                        die;};
 
9
 
 
10
 
 
11
STDOUT->autoflush(1);
 
12
STDERR->autoflush(1);
 
13
 
 
14
use PDL::Graphics::OpenGL;
 
15
 
 
16
my $numwins = shift;
 
17
$numwins = 1 unless(defined $numwins);
 
18
my @windows;
 
19
my $opt;
 
20
$opt->{width} = 90;
 
21
$opt->{height} = 90;
 
22
 
 
23
#PDL::Graphics::OpenGL::glpSetDebug(1);
 
24
 
 
25
foreach(0..$numwins-1){
 
26
  $opt->{x} = ($numwins % 10) *100;
 
27
  $opt->{y} = int($numwins / 10) *100;
 
28
 
 
29
  my $win=new PDL::Graphics::OpenGL::OO($opt);
 
30
  push @windows, $win;
 
31
}
 
32
 
 
33
my $angle=0;
 
34
 
 
35
use Data::Dumper;
 
36
my $out = Dumper($windows[0]);
 
37
print "$out\n";
 
38
 
 
39
 
 
40
 
 
41
while(1){
 
42
  $angle++;
 
43
  foreach my $win (@windows){
 
44
         $win->glXMakeCurrent() || die "glXMakeCurrent failed\n";
 
45
    if(PDL::Graphics::OpenGL::XPending($win->{Display})>0){
 
46
                my @ev = PDL::Graphics::OpenGL::glpXNextEvent($win->{Display});
 
47
    
 
48
                if($ev[0] ==  PDL::Graphics::OpenGL::ConfigureNotify){
 
49
                
 
50
                  glFlush();
 
51
                  glViewport(0, 0, $opt->{width}, $opt->{height});
 
52
                  glMatrixMode(GL_PROJECTION);
 
53
                  glLoadIdentity();
 
54
                  glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
 
55
 
 
56
                }        
 
57
         }
 
58
#        my $out = Dumper($win);
 
59
#        print "$out\n";
 
60
 
 
61
         glShadeModel(GL_FLAT);
 
62
 
 
63
 
 
64
    glClearColor(0., 0.5, 0., 1.0); 
 
65
 
 
66
         glClear(GL_COLOR_BUFFER_BIT);
 
67
         
 
68
 
 
69
         glPushMatrix();
 
70
 
 
71
         glRotatef($angle, 0, 0, 1);
 
72
 
 
73
         glBegin(GL_TRIANGLES);
 
74
 
 
75
         # draw pink triangle 
 
76
 
 
77
         glColor3f(1.0, 0.3, 0.5);
 
78
         glVertex2f(0, 0.8);
 
79
         glVertex2f(-0.8, -0.7);
 
80
         glVertex2f(0.7, 0.8);
 
81
         glEnd();
 
82
 
 
83
    glPopMatrix();
 
84
 
 
85
 
 
86
    $win->glXSwapBuffers();
 
87
  }
 
88
}