implemented collidehash
[sdlgit/SDL_perl.git] / test / OpenGL / test3.pl
CommitLineData
8fde61e3 1#!/usr/bin/env perl
2#
3# Bezier Curve example
4#
5
6use SDL;
7use SDL::App;
8use SDL::Surface;
9use SDL::Event;
10use SDL::OpenGL;
11
12my $app = new SDL::App -w => 800, -h => 600, -d => 16, -gl => 1;
13
14my @points = ( [-4.0, -4.0, 0.0 ],
15 [-2.0, 4.0, 0.0 ],
16 [ 2.0, -4.0, 0.0 ],
17 [ 4.0, 4.0, 0.0 ] );
18
19my $ctrlpoints = pack "d12", map { @$_ } @points;
20
21sub init {
22
23 glViewport(0,0,800,600);
24 glMatrixMode(GL_PROJECTION());
25 glLoadIdentity();
26
27 glFrustum (-0.1,0.1,-0.075,0.075,0.3,100.0 );
28
29 glMatrixMode(GL_MODELVIEW());
30 glLoadIdentity();
31
32 glTranslate(0,0,-30);
33
34 glClearColor(0.0, 0.0, 0.0, 0.0);
35 glShadeModel(GL_FLAT());
36 glMap1(GL_MAP1_VERTEX_3(), 0.0, 1.0, 3, 4, $ctrlpoints);
37 glEnable(GL_MAP1_VERTEX_3());
38}
39
40sub display {
41 glClear(GL_COLOR_BUFFER_BIT);
42 glColor(1.0,1.0,1.0);
43 glBegin(GL_LINE_STRIP);
44 for my $i ( 0 .. 30 ) {
45 glEvalCoord1($i/30);
46 }
47 glEnd();
48
49 glPointSize(5);
50 glColor(1.0,1.0,0);
51 glBegin(GL_POINTS);
52 for my $i ( 0 .. 3 ) {
53 glVertex( @{$points[$i]} );
54 }
55 glEnd();
56 $app->sync();
57}
58
59init();
60display();
61
62$app->loop({ SDL_QUIT() => sub { exit(); } });
63