… | |
… | |
41 | |
41 | |
42 | glDisable GL_COLOR_MATERIAL; |
42 | glDisable GL_COLOR_MATERIAL; |
43 | glShadeModel GL_FLAT; |
43 | glShadeModel GL_FLAT; |
44 | glDisable GL_DITHER; |
44 | glDisable GL_DITHER; |
45 | glDisable GL_DEPTH_TEST; |
45 | glDisable GL_DEPTH_TEST; |
|
|
46 | glDepthMask 0; |
46 | glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST; |
47 | glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST; |
47 | |
48 | |
48 | CFClient::Texture::restore_state (); |
49 | CFClient::Texture::restore_state (); |
49 | } |
50 | } |
50 | |
51 | |
51 | sub gl_check { |
52 | sub gl_check { |
52 | return unless $GL_DEBUG; |
53 | return unless $GL_DEBUG; |
53 | |
54 | |
54 | if (my $error = glGetError) { |
55 | if (my $error = glGetError) { |
55 | Carp::cluck sprintf "opengl error %x while %s", $error, sprintf @_; |
56 | Carp::cluck sprintf "opengl error %x while %s", $error, &sprintf(@_); |
56 | } |
57 | } |
57 | } |
58 | } |
58 | |
59 | |
59 | sub find_rcfile($) { |
60 | sub find_rcfile($) { |
60 | my $path; |
61 | my $path; |
… | |
… | |
153 | sub view_item { |
154 | sub view_item { |
154 | ("\t" x ($indent / 4)) |
155 | ("\t" x ($indent / 4)) |
155 | . $_[1]->title->present ($_[0]) |
156 | . $_[1]->title->present ($_[0]) |
156 | . "\n" |
157 | . "\n" |
157 | . $_[1]->content->present ($_[0]) |
158 | . $_[1]->content->present ($_[0]) |
|
|
159 | } |
|
|
160 | |
|
|
161 | sub view_verbatim { |
|
|
162 | (join "", |
|
|
163 | map +("\t" x ($indent / 2)) . "$_\n", |
|
|
164 | split /\n/, CFClient::UI::Label::escape ($_[1])) |
|
|
165 | . "\n" |
158 | } |
166 | } |
159 | |
167 | |
160 | sub view_textblock { |
168 | sub view_textblock { |
161 | ("\t" x ($indent / 2)) . "$_[1]\n\n" |
169 | ("\t" x ($indent / 2)) . "$_[1]\n\n" |
162 | } |
170 | } |
… | |
… | |
348 | glGetError; |
356 | glGetError; |
349 | |
357 | |
350 | if (defined $data) { |
358 | if (defined $data) { |
351 | glTexImage2D GL_TEXTURE_2D, 0, |
359 | glTexImage2D GL_TEXTURE_2D, 0, |
352 | $self->{internalformat}, |
360 | $self->{internalformat}, |
353 | $tw, $th, # need to pad texture first |
361 | $tw, $th, |
354 | 0, |
362 | 0, |
355 | $self->{format}, |
363 | $self->{format}, |
356 | $self->{type}, |
364 | $self->{type}, |
357 | $data; |
365 | $data; |
358 | CFClient::gl_check "uploading texture %dx%d if=%x f=%x t=%x", |
366 | CFClient::gl_check "uploading texture %dx%d if=%x f=%x t=%x", |
… | |
… | |
364 | $tw, $th, |
372 | $tw, $th, |
365 | 0; |
373 | 0; |
366 | CFClient::gl_check "copying to texture %dx%d if=%x", |
374 | CFClient::gl_check "copying to texture %dx%d if=%x", |
367 | $tw, $th, $self->{internalformat}; |
375 | $tw, $th, $self->{internalformat}; |
368 | } |
376 | } |
|
|
377 | |
|
|
378 | glBindTexture GL_TEXTURE_2D, 0; # just to be on the safe side |
369 | } |
379 | } |
370 | |
380 | |
371 | sub DESTROY { |
381 | sub DESTROY { |
372 | my ($self) = @_; |
382 | my ($self) = @_; |
373 | |
383 | |
… | |
… | |
375 | |
385 | |
376 | glDeleteTexture delete $self->{name} |
386 | glDeleteTexture delete $self->{name} |
377 | if $self->{name}; |
387 | if $self->{name}; |
378 | } |
388 | } |
379 | |
389 | |
380 | sub restore_state{ |
390 | sub restore_state { |
381 | $_->upload |
391 | $_->upload |
382 | for values %TEXTURES; |
392 | for values %TEXTURES; |
383 | }; |
393 | } |
384 | |
394 | |
385 | 1; |
395 | 1; |
386 | |
396 | |
387 | =back |
397 | =back |
388 | |
398 | |