… | |
… | |
267 | } |
267 | } |
268 | |
268 | |
269 | $self->{s} = $self->{w} / $tw; |
269 | $self->{s} = $self->{w} / $tw; |
270 | $self->{t} = $self->{h} / $th; |
270 | $self->{t} = $self->{h} / $th; |
271 | |
271 | |
272 | glGetError; |
|
|
273 | |
|
|
274 | $self->{name} ||= glGenTexture; |
272 | $self->{name} ||= glGenTexture; |
275 | |
273 | |
276 | glBindTexture GL_TEXTURE_2D, $self->{name}; |
274 | glBindTexture GL_TEXTURE_2D, $self->{name}; |
277 | |
275 | |
278 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP; |
276 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP; |
279 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP; |
277 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP; |
280 | |
278 | |
281 | if ($::FAST) { |
279 | if ($::FAST) { |
282 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST; |
280 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST; |
283 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST; |
281 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST; |
|
|
282 | } elsif ($self->{mipmap} && $GL_VERSION >= 1.4) { |
|
|
283 | # alternatively check for 0x8191 |
|
|
284 | glTexParameter GL_TEXTURE_2D, GL_GENERATE_MIPMAP, 1; |
|
|
285 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR; |
|
|
286 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR; |
284 | } else { |
287 | } else { |
285 | glTexParameter GL_TEXTURE_2D, GL_GENERATE_MIPMAP, $self->{mipmap}; |
288 | glTexParameter GL_TEXTURE_2D, GL_GENERATE_MIPMAP, $self->{mipmap}; |
286 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR; |
289 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR; |
287 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, $self->{mipmap} ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR; |
290 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR; |
288 | } |
291 | } |
289 | |
292 | |
|
|
293 | glGetError; |
|
|
294 | |
290 | if (defined $data) { |
295 | if (defined $data) { |
291 | glTexImage2D GL_TEXTURE_2D, 0, |
296 | glTexImage2D GL_TEXTURE_2D, 0, |
292 | $self->{internalformat}, |
297 | $self->{internalformat}, |
293 | $tw, $th, # need to pad texture first |
298 | $tw, $th, # need to pad texture first |
294 | 0, |
299 | 0, |