Skip to content

Commit

Permalink
add module that allows OpenGL::Image to work with OpenGL::Modern dire…
Browse files Browse the repository at this point in the history
…ctly (#54)
  • Loading branch information
wchristian authored and devel-chm committed Apr 8, 2017
1 parent 88d0906 commit c9bb77f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions cpanfile
@@ -1,4 +1,5 @@
requires 'Carp' => 0;
requires 'Import::Into' => 0;

on configure => sub {
requires 'Capture::Tiny' => 0;
Expand Down
14 changes: 14 additions & 0 deletions lib/OpenGL/Modern.pm
Expand Up @@ -106,6 +106,20 @@ Much of the functionality that used to be accessed via the
extension mechanism in C<OpenGL> now is standardized and
in the OpenGL Core APIs.
=head2 OpenGL::Image
The module OpenGL::Image was written for the original OpenGL.pm, however it can
be made to work seamlessly with OpenGL::Modern. Where-as you previously loaded
it like this:
use OpenGL::Image; # loads OpenGL.pm on its own
You can prepend two use lines, and get this:
use OpenGL::Array; # not part of OpenGL::Modern
use OpenGL::Modern::ImageHack; # sets up a fake OpenGL namespace
use OpenGL::Image; # now safe to do, won't load OpenGL.pm
=head2 EXPORT
None by default.
Expand Down
17 changes: 17 additions & 0 deletions lib/OpenGL/Modern/ImageHack.pm
@@ -0,0 +1,17 @@
package # hide from cpan
OpenGL;
use strict;
use warnings;
use Import::Into;

BEGIN { # prevent the real one from being loaded
die "OpenGL already loaded" if $INC{"OpenGL.pm"};
$INC{"OpenGL.pm"} = "Loaded from OpenGL::Modern";
}

sub import {
my ( undef, @args ) = @_;
$args[0] = ':all' if $args[0] eq ':constants'; # O::M doesn't have :constants yet
my $target = caller;
OpenGL::Modern->import::into( $target, @args );
}

0 comments on commit c9bb77f

Please sign in to comment.