File: depth.pl

package info (click to toggle)
libopengl-perl 0.66%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,932 kB
  • sloc: perl: 9,796; ansic: 6,279; makefile: 101; sh: 48
file content (39 lines) | stat: -rw-r--r-- 968 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/local/bin/perl
#
#         depth
#
# Simple demo showing effect of Z (depth) buffering.
# I saw a similar demo in the MESA distribution.
#

BEGIN{ unshift(@INC,"../blib"); }  # in case OpenGL is built but not installed
BEGIN{ unshift(@INC,"../blib/arch"); } # 5.002 gamma needs this
BEGIN{ unshift(@INC,"../blib/lib");  } # 5.002 gamma needs this
use OpenGL;

# if you dont ask for a visual with a depth buffer you might not get one
glpOpenWindow(attributes=>[GLX_RGBA,GLX_DEPTH_SIZE,1]);

# enable the important gl feature
glEnable(GL_DEPTH_TEST);
glClearColor(0,0,0,1);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity;

glOrtho(-1.2,1.2,-1.2,1.2,-1,1);
# draw intersecting triangles
glColor3f(1,0,0);
glBegin(GL_POLYGON);
  glVertex3f(-1,1,0);
  glVertex3f(-1,-1,0);
  glVertex3f(0.9,0,0.8);
glEnd();
glColor3f(0,1,0);
glBegin(GL_POLYGON);
  glVertex3f(1,-1,0);
  glVertex3f(1,1,0);
  glVertex3f(-0.9,0,1);
glEnd();
glpFlush();

glpMainLoop;