/usr/share/perl5/Dizzy/TextureManager.pm is in dizzy 0.3-2.
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 | package Dizzy::TextureManager;
use strict;
use warnings;
use OpenGL qw(:all);
use Math::Trig;
use Time::HiRes qw(sleep time);
use Dizzy::TextureGenerator;
use Dizzy::Handlers;
my @textures;
my $current_texture_id = 0;
my $texture_resolution = 0;
my $shader_resolution = 0;
my $cache_paths;
sub add {
my %args = @_;
push(@textures, \%args);
$textures[$#textures]->{gl_texture} = Dizzy::TextureGenerator::new_from_func(
name => $textures[$#textures]->{name},
function => $textures[$#textures]->{function},
shader => $textures[$#textures]->{shader},
texture_resolution => $texture_resolution,
shader_resolution => $shader_resolution,
cache_paths => $cache_paths,
);
delete($textures[$#textures]->{function});
return $#textures;
}
sub set {
my ($id) = @_;
Dizzy::Handlers::invoke("texture_switch",
gl_texture => $textures[$id]->{gl_texture},
old_gl_texture => $textures[$current_texture_id]->{gl_texture},
_texman_new_id => $id,
_texman_old_id => $current_texture_id,
);
}
# -----------------------------------------------------------------------------
# some handlers
# transforms a texture walk request (such as one triggered by cursor keys) into
# something that we all understand: a renderable GL texture ID.
sub handler_walking {
my %args = @_;
if (exists($args{direction})) {
# find out about the next texture
my $id = $current_texture_id + $args{direction};
$id += @textures;
$id %= @textures;
set($id);
return Dizzy::Handlers::STOP;
} else {
return Dizzy::Handlers::GO_ON;
}
}
# this event serves to tell texman that the texture has now changed.
# it is essentially like texture_switch, but this one is needed for texblend
# to work.
sub handler_switched {
my %args = @_;
$current_texture_id = $args{_texman_new_id};
Dizzy::Handlers::invoke("texture_changed",
name => $textures[$current_texture_id]->{name},
);
Dizzy::Handlers::STOP;
}
sub init {
my %args = @_;
$texture_resolution = $args{texture_resolution};
$shader_resolution = $args{shader_resolution};
$cache_paths = $args{cache_disable} ? [] : $args{cache_paths};
Dizzy::Handlers::register(
texture_switch => \&handler_walking,
);
Dizzy::Handlers::register_last(
texture_switched => \&handler_switched,
);
}
1;
|