… | |
… | |
20 | use XSLoader; |
20 | use XSLoader; |
21 | XSLoader::load "CFClient", $VERSION; |
21 | XSLoader::load "CFClient", $VERSION; |
22 | } |
22 | } |
23 | |
23 | |
24 | use Carp (); |
24 | use Carp (); |
25 | use AnyEvent; |
25 | use AnyEvent (); |
26 | use BerkeleyDB; |
26 | use BerkeleyDB; |
|
|
27 | |
27 | use CFClient::OpenGL; |
28 | use CFClient::OpenGL; |
28 | |
29 | |
29 | our %GL_EXT; |
30 | our %GL_EXT; |
30 | our $GL_VERSION; |
31 | our $GL_VERSION; |
31 | |
32 | |
… | |
… | |
35 | sub gl_init { |
36 | sub gl_init { |
36 | $GL_VERSION = gl_version * 1; |
37 | $GL_VERSION = gl_version * 1; |
37 | %GL_EXT = map +($_ => 1), split /\s+/, gl_extensions; |
38 | %GL_EXT = map +($_ => 1), split /\s+/, gl_extensions; |
38 | |
39 | |
39 | $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... |
40 | |
42 | |
41 | glDisable GL_COLOR_MATERIAL; |
43 | glDisable GL_COLOR_MATERIAL; |
42 | glShadeModel GL_FLAT; |
44 | glShadeModel GL_FLAT; |
43 | glDisable GL_DITHER; |
45 | glDisable GL_DITHER; |
44 | glDisable GL_DEPTH_TEST; |
46 | glDisable GL_DEPTH_TEST; |
|
|
47 | glDepthMask 0; |
45 | glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST; |
48 | glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST; |
46 | |
49 | |
47 | CFClient::Texture::restore_state (); |
50 | CFClient::Texture::restore_state (); |
48 | } |
51 | } |
49 | |
52 | |
50 | sub gl_check { |
53 | sub gl_check { |
51 | return unless $GL_DEBUG; |
54 | return unless $GL_DEBUG; |
52 | |
55 | |
53 | if (my $error = glGetError) { |
56 | if (my $error = glGetError) { |
54 | Carp::cluck sprintf "opengl error %x while %s", $error, sprintf @_; |
57 | Carp::cluck sprintf "opengl error %x while %s", $error, &sprintf(@_); |
55 | } |
58 | } |
56 | } |
59 | } |
57 | |
60 | |
58 | sub find_rcfile($) { |
61 | sub find_rcfile($) { |
59 | my $path; |
62 | my $path; |
… | |
… | |
104 | -Home => "$Crossfire::VARDIR/pclient", |
107 | -Home => "$Crossfire::VARDIR/pclient", |
105 | -Cachesize => 1_000_000, |
108 | -Cachesize => 1_000_000, |
106 | -ErrFile => "$Crossfire::VARDIR/pclient/errorlog.txt", |
109 | -ErrFile => "$Crossfire::VARDIR/pclient/errorlog.txt", |
107 | # -ErrPrefix => "DATABASE", |
110 | # -ErrPrefix => "DATABASE", |
108 | -Verbose => 1, |
111 | -Verbose => 1, |
109 | -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, |
110 | 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"; |
111 | |
114 | |
112 | sub db_table($) { |
115 | sub db_table($) { |
113 | my ($table) = @_; |
116 | my ($table) = @_; |
114 | |
117 | |
… | |
… | |
120 | # -Filename => "database", |
123 | # -Filename => "database", |
121 | # -Subname => $table, |
124 | # -Subname => $table, |
122 | -Property => DB_CHKSUM, |
125 | -Property => DB_CHKSUM, |
123 | -Flags => DB_CREATE | DB_UPGRADE, |
126 | -Flags => DB_CREATE | DB_UPGRADE, |
124 | or die "unable to create/open database table $_[0]: $BerkeleyDB::Error"; |
127 | or die "unable to create/open database table $_[0]: $BerkeleyDB::Error"; |
|
|
128 | } |
|
|
129 | |
|
|
130 | sub pod_to_pango($) { |
|
|
131 | my ($pom) = @_; |
|
|
132 | |
|
|
133 | $pom->present ("CFClient::PodToPango") |
|
|
134 | } |
|
|
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 | |
|
|
145 | package CFClient::PodToPango; |
|
|
146 | |
|
|
147 | use base Pod::POM::View::Text; |
|
|
148 | |
|
|
149 | our $indent = 0; |
|
|
150 | |
|
|
151 | *view_seq_code = |
|
|
152 | *view_seq_bold = sub { "<b>$_[1]</b>" }; |
|
|
153 | *view_seq_italic = sub { "<i>$_[1]</i>" }; |
|
|
154 | *view_seq_space = |
|
|
155 | *view_seq_link = |
|
|
156 | *view_seq_index = sub { CFClient::UI::Label::escape ($_[1]) }; |
|
|
157 | |
|
|
158 | sub view_seq_text { |
|
|
159 | my $text = $_[1]; |
|
|
160 | $text =~ s/\s+/ /g; |
|
|
161 | CFClient::UI::Label::escape ($text) |
|
|
162 | } |
|
|
163 | |
|
|
164 | sub view_item { |
|
|
165 | ("\t" x ($indent / 4)) |
|
|
166 | . $_[1]->title->present ($_[0]) |
|
|
167 | . "\n" |
|
|
168 | . $_[1]->content->present ($_[0]) |
|
|
169 | } |
|
|
170 | |
|
|
171 | sub view_verbatim { |
|
|
172 | (join "", |
|
|
173 | map +("\t" x ($indent / 2)) . "$_\n", |
|
|
174 | split /\n/, CFClient::UI::Label::escape ($_[1])) |
|
|
175 | . "\n" |
|
|
176 | } |
|
|
177 | |
|
|
178 | sub view_textblock { |
|
|
179 | ("\t" x ($indent / 2)) . "$_[1]\n\n" |
|
|
180 | } |
|
|
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 | |
|
|
187 | sub view_head2 { |
|
|
188 | "<span foreground='#ccccff' size='large'>" . $_[1]->title->present ($_[0]) . "</span>\n\n" |
|
|
189 | . $_[1]->content->present ($_[0]) |
|
|
190 | }; |
|
|
191 | |
|
|
192 | sub view_over { |
|
|
193 | local $indent = $indent + $_[1]->indent; |
|
|
194 | $_[1]->content->present ($_[0]) |
125 | } |
195 | } |
126 | |
196 | |
127 | package CFClient::Database; |
197 | package CFClient::Database; |
128 | |
198 | |
129 | our @ISA = BerkeleyDB::Btree::; |
199 | our @ISA = BerkeleyDB::Btree::; |
… | |
… | |
301 | glGetError; |
371 | glGetError; |
302 | |
372 | |
303 | if (defined $data) { |
373 | if (defined $data) { |
304 | glTexImage2D GL_TEXTURE_2D, 0, |
374 | glTexImage2D GL_TEXTURE_2D, 0, |
305 | $self->{internalformat}, |
375 | $self->{internalformat}, |
306 | $tw, $th, # need to pad texture first |
376 | $tw, $th, |
307 | 0, |
377 | 0, |
308 | $self->{format}, |
378 | $self->{format}, |
309 | $self->{type}, |
379 | $self->{type}, |
310 | $data; |
380 | $data; |
311 | 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", |
… | |
… | |
317 | $tw, $th, |
387 | $tw, $th, |
318 | 0; |
388 | 0; |
319 | CFClient::gl_check "copying to texture %dx%d if=%x", |
389 | CFClient::gl_check "copying to texture %dx%d if=%x", |
320 | $tw, $th, $self->{internalformat}; |
390 | $tw, $th, $self->{internalformat}; |
321 | } |
391 | } |
|
|
392 | |
|
|
393 | glBindTexture GL_TEXTURE_2D, 0; # just to be on the safe side |
322 | } |
394 | } |
323 | |
395 | |
324 | sub DESTROY { |
396 | sub DESTROY { |
325 | my ($self) = @_; |
397 | my ($self) = @_; |
326 | |
398 | |
… | |
… | |
328 | |
400 | |
329 | glDeleteTexture delete $self->{name} |
401 | glDeleteTexture delete $self->{name} |
330 | if $self->{name}; |
402 | if $self->{name}; |
331 | } |
403 | } |
332 | |
404 | |
333 | sub restore_state{ |
405 | sub restore_state { |
334 | $_->upload |
406 | $_->upload |
335 | for values %TEXTURES; |
407 | for values %TEXTURES; |
336 | }; |
408 | } |
337 | |
409 | |
338 | 1; |
410 | 1; |
339 | |
411 | |
340 | =back |
412 | =back |
341 | |
413 | |