File: depth.pl

package info (click to toggle)
libopengl-perl 0.7004%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,088 kB
  • sloc: perl: 9,701; ansic: 8,090; makefile: 110
file content (33 lines) | stat: -rw-r--r-- 735 bytes parent folder | download
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
#         depth
#
# Simple demo showing effect of Z (depth) buffering.
# I saw a similar demo in the MESA distribution.

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;