Shader/CG.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::CG - 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::CG;
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 {nVidia's Cg 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::CG - 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('CG');
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_EXT_Cg_shader'));
67  
68 # Get GL_SHADING_LANGUAGE_VERSION_ARB
69 my $ver = glGetString(0x8B8C);
70 $ver =~ m|Cg ([\d\.]+)|i;
71  
72 # Some drivers do not report Cg version
73 $SHADER_VER = $1 || '1.00';
74 }
75 return $SHADER_VER;
76 }
77  
78  
79 # Get Description
80 sub TypeDescription
81 {
82 return $DESCRIPTION;
83 }
84  
85  
86 # Shader constructor
87 sub new
88 {
89 my $this = shift;
90 my $class = ref($this) || $this;
91  
92 # Check for additional required OpenGL extensions
93 my $ver = TypeVersion();
94 return undef if (!$ver);
95  
96 my $self = new OpenGL::Shader::Objects(@_);
97 return undef if (!$self);
98 bless($self,$class);
99  
100 $self->{type} = 'CG';
101 $self->{version} = $ver;
102 $self->{description} = $DESCRIPTION;
103  
104 $self->{fragment_const} = GL_CG_FRAGMENT_SHADER_EXT;
105 $self->{vertex_const} = GL_CG_VERTEX_SHADER_EXT;
106  
107 return $self;
108 }
109  
110  
111 1;
112 __END__