/usr/share/perl5/Dizzy/Render.pm is in dizzy 0.3-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | package Dizzy::Render;
use strict;
use warnings;
use OpenGL qw(:all);
use Math::Trig;
use Time::HiRes qw(sleep time);
use Convert::Color;
use Convert::Color::HSV;
use Dizzy::RotatorManager;
my $debug_show_planes;
my $tex_scale;
sub set_color_from_hsv {
my ($h, $v, $s) = @_;
glColor3f(Convert::Color::HSV->new($h * 360, $s, $v)->rgb());
}
sub render_planes {
my %args = @_;
my $tick = $args{tick};
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
set_color_from_hsv(
($tick * 0.2) - int($tick * 0.2),
cos($tick) * 0.125 + 0.5,
0.5);
foreach my $plane (1, 2) {
glPushMatrix();
if ($debug_show_planes) {
glScalef(0.2, 0.2, 0.2);
}
glMatrixMode(GL_TEXTURE);
foreach my $tex (GL_TEXTURE1, GL_TEXTURE0) {
glActiveTextureARB($tex);
glLoadIdentity();
glScalef(($tex_scale * 0.3 ** (0.75 + 0.25 * sin(($plane == 1 ? 0.4 : 0.3 ) * $tick))) x 3);
}
glMatrixMode(GL_MODELVIEW);
$args{rotator_func}->($tick, $plane);
glBegin(GL_QUADS);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0, 0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0, 0);
glVertex2f(-8, -8);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0, 1);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0, 1);
glVertex2f(-8, 8);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1, 1);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1, 1);
glVertex2f( 8, 8);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1, 0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1, 0);
glVertex2f( 8, -8);
glEnd();
glPopMatrix();
}
}
sub handler_render {
render_planes(
tick => time() - $^T,
rotator_func => Dizzy::RotatorManager::current(),
);
Dizzy::Handlers::GO_ON;
}
sub init_projection {
my $aspect = $_[0] || 1.6;
my $old_matrix = glGetIntegerv_p(GL_MATRIX_MODE);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if ($aspect >= 1.0) {
glOrtho(-3.2, 3.2, -3.2 / $aspect, 3.2 / $aspect, 1, -1);
} else {
glOrtho(-3.2 * $aspect, 3.2 * $aspect, -3.2, 3.2, 1, -1);
}
glMatrixMode($old_matrix);
}
sub init {
my %args = @_;
# initialize GL view
glClearColor(0.0, 0.0, 0.0, 0.0);
init_projection(1.6);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
# render handler registration
$debug_show_planes = $args{debug_show_planes};
$tex_scale = $args{texture_scale};
Dizzy::Handlers::register(
render => \&handler_render
);
if ($debug_show_planes) {
Dizzy::Handlers::register_last(render => sub {
glLineWidth(3);
glColor4f(1.0, 1.0, 1.0, 1.0);
my ($xe, $ye) = (3.2 * 0.2, 2.0 * 0.2);
glBegin(GL_LINE_STRIP);
glVertex2f( $xe, $ye);
glVertex2f(-$xe, $ye);
glVertex2f(-$xe, -$ye);
glVertex2f( $xe, -$ye);
glVertex2f( $xe, $ye);
glEnd();
Dizzy::Handlers::GO_ON;
});
}
}
1;
|