Shader/GLSL.pm untested

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 5 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 63 SCAR 34.0
CC
5
Cov
0%
TypeVersion
12.0
new
12.0
TypeDescription
2.0
CRAP 30.0
1 ############################################################
2 #
3 # OpenGL::Shader::GLSL - Copyright 2007 Graphcomp - ALL RIGHTS RESERVED
4 # Author: Bob "grafman" Free - grafman@graphcomp.com
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the same terms as Perl itself.
8 #
9 ############################################################
10  
11 package OpenGL::Shader::GLSL;
12  
13 require Exporter;
14  
15 use Carp;
16  
17 use vars qw($VERSION $SHADER_VER $DESCRIPTION @ISA);
18 $VERSION = '1.01';
19  
20 $DESCRIPTION = qq
21 {OpenGL Shader Language};
22  
23 use OpenGL::Shader::Objects;
24 @ISA = qw(Exporter OpenGL::Shader::Objects);
25  
26 use OpenGL(':all');
27  
28  
29  
30 =head1 NAME
31  
32 OpenGL::Shader::GLSL - copyright 2007 Graphcomp - ALL RIGHTS RESERVED
33 Author: Bob "grafman" Free - grafman@graphcomp.com
34  
35 This program is free software; you can redistribute it and/or
36 modify it under the same terms as Perl itself.
37  
38  
39 =head1 DESCRIPTION
40  
41 This is a plug-in module for use with the OpenGL::Shader.
42 While it may be called directly, it will more often be called
43 by the OpenGL::Shader abstraction module.
44  
45 This is a subclass of the OpenGL::Shader::Objects module.
46  
47  
48 =head1 SYNOPSIS
49  
50 ##########
51 # Instantiate a shader
52  
53 use OpenGL::Shader;
54 my $shdr = new OpenGL::Shader('GLSL');
55  
56 # See docs in OpenGL/Shader/Common.pm
57  
58 =cut
59  
60  
61 # Get Version
62 sub TypeVersion
63 {
64 if (!defined($SHADER_VER))
65 {
66 return undef if (OpenGL::glpCheckExtension('GL_ARB_shading_language_100'));
67  
68 # Get GL_SHADING_LANGUAGE_VERSION_ARB
69 my $ver = glGetString(0x8B8C);
70 $ver =~ m|([\d\.]+)|;
71 $SHADER_VER = $1 || '0';
72 }
73 return $SHADER_VER;
74 }
75  
76  
77 # Get Description
78 sub TypeDescription
79 {
80 return $DESCRIPTION;
81 }
82  
83  
84 # Shader constructor
85 sub new
86 {
87 my $this = shift;
88 my $class = ref($this) || $this;
89  
90 # Check for additional required OpenGL extensions
91 my $ver = TypeVersion();
92 return undef if (!$ver);
93  
94 my $self = new OpenGL::Shader::Objects(@_);
95 return undef if (!$self);
96 bless($self,$class);
97  
98 $self->{type} = 'GLSL';
99 $self->{version} = $ver;
100 $self->{description} = $DESCRIPTION;
101  
102 $self->{fragment_const} = GL_FRAGMENT_SHADER;
103 $self->{vertex_const} = GL_VERTEX_SHADER;
104  
105 return $self;
106 }
107  
108  
109 1;
110 __END__