NAME

SDL::Tutorial::3DWorld::Texture - A texture API simple enough for mere mortals

SYNOPSIS

# Create the texture object (validating only the file exists)
my $texture = SDL::Tutorial::3DWorld::Texture->new( file => $file );

# Load the texture into memory, ready for use in your program
$texture->init;

# Make this texture the active OpenGL texture for drawing
$texture->display;

DESCRIPTION

OpenGL textures are a large and complex topic, with a steep learning curve.

Most tutorials on texturing demonstrate a single specific use case, and often implement their own image loaders in the process. Unlike most other basic topics in OpenGL, texturing examples are difficult to translate into working code for your own program (and even then the amount of code can be rather large and crufty).

This module provides a convenient abstraction that streamlines the most obvious case of reading an image file from disk, binding it to the OpenGL environment, and then activating the texture so you can paint it onto something.

METHODS

new

# Load a texture from a shared file texture collection
my $chess = SDL::Tutorial::3DWorld::Texture->new(
    file => File::Spec->catfile(
        File::ShareDir::dist_dir('SDL-Tutorial-3DWorld'),
        'textures',
        'chessboard.png',
    ),
);

The new constructor creates a new texture handle which identifies a texture to be loaded from disk.

It takes a single named file parameter which should be the path to the texture on disk. While the new constructor will validate that the file exists, it will not attempt to load the image. Any image files that are broken, corrupt or unsupported will not be identified until init is called.

file

The file accessor returns the path to the file the texture was originally loaded from.

SUPPORT

Bugs should be reported via the CPAN bug tracker at

http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SDL-Tutorial-3DWorld

AUTHOR

Adam Kennedy <adamk@cpan.org>

SEE ALSO

SDL, OpenGL

COPYRIGHT

Copyright 2010 Adam Kennedy.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 202:

=cut found outside a pod block. Skipping to next block.