… | |
… | |
36 | sub gl_init { |
36 | sub gl_init { |
37 | $GL_VERSION = gl_version * 1; |
37 | $GL_VERSION = gl_version * 1; |
38 | %GL_EXT = map +($_ => 1), split /\s+/, gl_extensions; |
38 | %GL_EXT = map +($_ => 1), split /\s+/, gl_extensions; |
39 | |
39 | |
40 | $GL_NPOT = $GL_EXT{GL_ARB_texture_non_power_of_two} || $GL_VERSION >= 2; |
40 | $GL_NPOT = $GL_EXT{GL_ARB_texture_non_power_of_two} || $GL_VERSION >= 2; |
|
|
41 | $GL_NPOT = 0 if gl_vendor =~ /ATI Technologies/; # ATI doesn't get it right... |
41 | |
42 | |
42 | glDisable GL_COLOR_MATERIAL; |
43 | glDisable GL_COLOR_MATERIAL; |
43 | glShadeModel GL_FLAT; |
44 | glShadeModel GL_FLAT; |
44 | glDisable GL_DITHER; |
45 | glDisable GL_DITHER; |
45 | glDisable GL_DEPTH_TEST; |
46 | glDisable GL_DEPTH_TEST; |
|
|
47 | glDepthMask 0; |
46 | glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST; |
48 | glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST; |
47 | |
49 | |
48 | CFClient::Texture::restore_state (); |
50 | CFClient::Texture::restore_state (); |
49 | } |
51 | } |
50 | |
52 | |
51 | sub gl_check { |
53 | sub gl_check { |
52 | return unless $GL_DEBUG; |
54 | return unless $GL_DEBUG; |
53 | |
55 | |
54 | if (my $error = glGetError) { |
56 | if (my $error = glGetError) { |
55 | Carp::cluck sprintf "opengl error %x while %s", $error, sprintf @_; |
57 | Carp::cluck sprintf "opengl error %x while %s", $error, &sprintf(@_); |
56 | } |
58 | } |
57 | } |
59 | } |
58 | |
60 | |
59 | sub find_rcfile($) { |
61 | sub find_rcfile($) { |
60 | my $path; |
62 | my $path; |
… | |
… | |
105 | -Home => "$Crossfire::VARDIR/pclient", |
107 | -Home => "$Crossfire::VARDIR/pclient", |
106 | -Cachesize => 1_000_000, |
108 | -Cachesize => 1_000_000, |
107 | -ErrFile => "$Crossfire::VARDIR/pclient/errorlog.txt", |
109 | -ErrFile => "$Crossfire::VARDIR/pclient/errorlog.txt", |
108 | # -ErrPrefix => "DATABASE", |
110 | # -ErrPrefix => "DATABASE", |
109 | -Verbose => 1, |
111 | -Verbose => 1, |
110 | -Flags => DB_CREATE | DB_RECOVER_FATAL | DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_TXN, |
112 | -Flags => DB_CREATE | DB_RECOVER | DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_TXN, |
111 | or die "unable to create/open database home $Crossfire::VARDIR/pclient: $BerkeleyDB::Error"; |
113 | or die "unable to create/open database home $Crossfire::VARDIR/pclient: $BerkeleyDB::Error"; |
112 | |
114 | |
113 | sub db_table($) { |
115 | sub db_table($) { |
114 | my ($table) = @_; |
116 | my ($table) = @_; |
115 | |
117 | |
… | |
… | |
129 | my ($pom) = @_; |
131 | my ($pom) = @_; |
130 | |
132 | |
131 | $pom->present ("CFClient::PodToPango") |
133 | $pom->present ("CFClient::PodToPango") |
132 | } |
134 | } |
133 | |
135 | |
|
|
136 | sub pod_to_pango_list($) { |
|
|
137 | my ($pom) = @_; |
|
|
138 | |
|
|
139 | [ |
|
|
140 | map s/^(\s*)// && [40 * length $1, length $_ ? $_ : " "], |
|
|
141 | split /\n/, $pom->present ("CFClient::PodToPango") |
|
|
142 | ] |
|
|
143 | } |
|
|
144 | |
134 | package CFClient::PodToPango; |
145 | package CFClient::PodToPango; |
135 | |
146 | |
136 | use base Pod::POM::View::Text; |
147 | use base Pod::POM::View::Text; |
137 | |
148 | |
138 | our $indent = 0; |
149 | our $indent = 0; |
… | |
… | |
166 | |
177 | |
167 | sub view_textblock { |
178 | sub view_textblock { |
168 | ("\t" x ($indent / 2)) . "$_[1]\n\n" |
179 | ("\t" x ($indent / 2)) . "$_[1]\n\n" |
169 | } |
180 | } |
170 | |
181 | |
|
|
182 | sub view_head1 { |
|
|
183 | "<span foreground='#ffff00' size='x-large'>" . $_[1]->title->present ($_[0]) . "</span>\n\n" |
|
|
184 | . $_[1]->content->present ($_[0]) |
|
|
185 | }; |
|
|
186 | |
171 | sub view_head2 { |
187 | sub view_head2 { |
172 | "<big>" . $_[1]->title->present ($_[0]) . "</big>\n\n" |
188 | "<span foreground='#ccccff' size='large'>" . $_[1]->title->present ($_[0]) . "</span>\n\n" |
173 | . $_[1]->content->present ($_[0]) |
189 | . $_[1]->content->present ($_[0]) |
174 | }; |
190 | }; |
175 | |
191 | |
176 | sub view_over { |
192 | sub view_over { |
177 | local $indent = $indent + $_[1]->indent; |
193 | local $indent = $indent + $_[1]->indent; |
… | |
… | |
355 | glGetError; |
371 | glGetError; |
356 | |
372 | |
357 | if (defined $data) { |
373 | if (defined $data) { |
358 | glTexImage2D GL_TEXTURE_2D, 0, |
374 | glTexImage2D GL_TEXTURE_2D, 0, |
359 | $self->{internalformat}, |
375 | $self->{internalformat}, |
360 | $tw, $th, # need to pad texture first |
376 | $tw, $th, |
361 | 0, |
377 | 0, |
362 | $self->{format}, |
378 | $self->{format}, |
363 | $self->{type}, |
379 | $self->{type}, |
364 | $data; |
380 | $data; |
365 | CFClient::gl_check "uploading texture %dx%d if=%x f=%x t=%x", |
381 | CFClient::gl_check "uploading texture %dx%d if=%x f=%x t=%x", |
… | |
… | |
371 | $tw, $th, |
387 | $tw, $th, |
372 | 0; |
388 | 0; |
373 | CFClient::gl_check "copying to texture %dx%d if=%x", |
389 | CFClient::gl_check "copying to texture %dx%d if=%x", |
374 | $tw, $th, $self->{internalformat}; |
390 | $tw, $th, $self->{internalformat}; |
375 | } |
391 | } |
|
|
392 | |
|
|
393 | glBindTexture GL_TEXTURE_2D, 0; # just to be on the safe side |
376 | } |
394 | } |
377 | |
395 | |
378 | sub DESTROY { |
396 | sub DESTROY { |
379 | my ($self) = @_; |
397 | my ($self) = @_; |
380 | |
398 | |
… | |
… | |
382 | |
400 | |
383 | glDeleteTexture delete $self->{name} |
401 | glDeleteTexture delete $self->{name} |
384 | if $self->{name}; |
402 | if $self->{name}; |
385 | } |
403 | } |
386 | |
404 | |
387 | sub restore_state{ |
405 | sub restore_state { |
388 | $_->upload |
406 | $_->upload |
389 | for values %TEXTURES; |
407 | for values %TEXTURES; |
390 | }; |
408 | } |
391 | |
409 | |
392 | 1; |
410 | 1; |
393 | |
411 | |
394 | =back |
412 | =back |
395 | |
413 | |