OpenGL-Sandbox-V1
view release on metacpan or search on metacpan
lib/OpenGL/Sandbox/V1.pm view on Meta::CPAN
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
$ortho? glOrtho($l, $r, $b, $t, $near, $far)
: glFrustum($l, $r, $b, $t, $near, $far);
glTranslated(-$x, -$y, -$z)
if $x or $y or $z;
glMatrixMode(GL_MODELVIEW);
}
sub local_matrix(&) { goto &_local_matrix }
BEGIN { *load_identity= *glLoadIdentity; }
sub local_gl(&) { goto &_local_gl }
sub lines(&) { goto &_lines }
sub line_strip(&) { goto &_line_strip }
sub quads(&) { goto &_quads }
sub quad_strip(&) { goto &_quad_strip }
sub triangles(&) { goto &_triangles }
sub triangle_strip(&) { goto &_triangle_strip }
sub triangle_fan(&) { goto &_triangle_fan }
our $default_quadric;
sub default_quadric { $default_quadric //= OpenGL::Sandbox::V1::Quadric->new }
sub cylinder { default_quadric->cylinder(@_) }
sub sphere { default_quadric->sphere(@_) }
sub disk { default_quadric->disk(@_) }
sub partial_disk { default_quadric->partial_disk(@_) }
END { undef $default_quadric; } # cleanup before global destruction
sub compile_list(&) { OpenGL::Sandbox::V1::DisplayList->new->compile(shift); }
BEGIN { *call_list= *_displaylist_call; }
sub setup_sunlight {
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
load_identity();
set_light_ambient(GL_LIGHT0, 0.8, 0.8, 0.8, 0);
set_light_diffuse(GL_LIGHT0, 1.0, 1.0, 0.8, 0);
t/90-visual-inspection.t view on Meta::CPAN
);
$ENV{TEST_VISUAL}
or plan skip_all => "Set TEST_VISUAL=1 to run these tests";
my $c= try { make_context; }
or plan skip_all => "Can't test without context";
$res->resource_root_dir(catdir($FindBin::Bin, 'data'));
sub show(&) {
my ($code, $tname)= @_;
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
load_identity;
$code->();
$c->swap_buffers;
sleep .5;
my @e= get_gl_errors;
ok( !@e, $tname )
or diag "GL Errors: ".join(', ', @e);
}
sub spin(&) {
my ($code, $tname)= @_;
load_identity;
for (my $i= 0; $i < 200; $i++) {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
local_matrix {
rotate $i*1, 1, 1, 0;
rotate $i*2, 0, 0, 1;
$code->();
};
$c->swap_buffers;
( run in 0.220 second using v1.01-cache-2.11-cpan-49f99fa48dc )