… | |
… | |
74 | |
74 | |
75 | sub new { |
75 | sub new { |
76 | my ($class, %data) = @_; |
76 | my ($class, %data) = @_; |
77 | |
77 | |
78 | my $self = bless { |
78 | my $self = bless { |
79 | internalFormat => GL_RGBA, |
79 | internalformat => GL_RGBA, |
80 | format => GL_RGBA8, |
80 | format => GL_RGBA, |
81 | %data, |
81 | %data, |
82 | }, $class; |
82 | }, $class; |
83 | |
83 | |
84 | push @textures, $self; |
84 | push @textures, $self; |
85 | Scalar::Util::weaken $textures[-1]; |
85 | Scalar::Util::weaken $textures[-1]; |
… | |
… | |
124 | |
124 | |
125 | $class->new ( |
125 | $class->new ( |
126 | width => $w, |
126 | width => $w, |
127 | height => $h, |
127 | height => $h, |
128 | data => $data, |
128 | data => $data, |
129 | internalFormat => GL_ALPHA8, |
129 | internalformat => GL_ALPHA8, |
130 | format => GL_ALPHA, |
130 | format => GL_ALPHA, |
131 | ) |
131 | ) |
132 | } |
132 | } |
133 | |
133 | |
134 | sub new_from_opengl { |
134 | sub new_from_opengl { |
… | |
… | |
180 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP; |
180 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP; |
181 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP; |
181 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP; |
182 | |
182 | |
183 | if (defined $data) { |
183 | if (defined $data) { |
184 | glTexImage2D GL_TEXTURE_2D, 0, |
184 | glTexImage2D GL_TEXTURE_2D, 0, |
185 | $self->{internalFormat}, |
185 | $self->{internalformat}, |
186 | $self->{width}, $self->{height}, |
186 | $self->{width}, $self->{height}, |
187 | 0, |
187 | 0, |
188 | $self->{format}, |
188 | $self->{format}, |
189 | GL_UNSIGNED_BYTE, |
189 | GL_UNSIGNED_BYTE, |
190 | $data; |
190 | $data; |
191 | } else { |
191 | } else { |
192 | glCopyTexImage2D GL_TEXTURE_2D, 0, |
192 | glCopyTexImage2D GL_TEXTURE_2D, 0, |
193 | $self->{internalFormat}, |
193 | $self->{internalformat}, |
194 | 0, 0, |
194 | 0, 0, |
195 | $self->{width}, $self->{height}, |
195 | $self->{width}, $self->{height}, |
196 | 0; |
196 | 0; |
197 | glPopmatrix; |
197 | glPopmatrix; |
198 | #SDL::GLSwapBuffers; |
198 | #SDL::GLSwapBuffers; |