Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add module that allows OpenGL::Image to work with OpenGL::Modern dire…
…ctly
  • Loading branch information
wchristian committed Mar 5, 2017
1 parent f0fd732 commit 662500a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
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
15 changes: 15 additions & 0 deletions lib/OpenGL/Modern/ImageHack.pm
@@ -0,0 +1,15 @@
package # hide from cpan
OpenGL;

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

sub import {
my ( undef, @args ) = @_;
my $caller_package = ( caller )[0];
$args[0] = ":all" if $args[0] eq ":constants";
eval "
package $caller_package;
OpenGL::Modern->import( \@args );
";
return;
}

0 comments on commit 662500a

Please sign in to comment.