ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC.pm (file contents):
Revision 1.49 by root, Sun Apr 30 08:09:44 2006 UTC vs.
Revision 1.58 by root, Tue May 23 00:26:17 2006 UTC

20 use XSLoader; 20 use XSLoader;
21 XSLoader::load "CFClient", $VERSION; 21 XSLoader::load "CFClient", $VERSION;
22} 22}
23 23
24use Carp (); 24use Carp ();
25use AnyEvent; 25use AnyEvent ();
26use BerkeleyDB; 26use BerkeleyDB;
27
27use CFClient::OpenGL; 28use CFClient::OpenGL;
28 29
29our %GL_EXT; 30our %GL_EXT;
30our $GL_VERSION; 31our $GL_VERSION;
31 32
40 41
41 glDisable GL_COLOR_MATERIAL; 42 glDisable GL_COLOR_MATERIAL;
42 glShadeModel GL_FLAT; 43 glShadeModel GL_FLAT;
43 glDisable GL_DITHER; 44 glDisable GL_DITHER;
44 glDisable GL_DEPTH_TEST; 45 glDisable GL_DEPTH_TEST;
46 glDepthMask 0;
45 glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST; 47 glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST;
46 48
47 CFClient::Texture::restore_state (); 49 CFClient::Texture::restore_state ();
48} 50}
49 51
50sub gl_check { 52sub gl_check {
51 return unless $GL_DEBUG; 53 return unless $GL_DEBUG;
52 54
53 if (my $error = glGetError) { 55 if (my $error = glGetError) {
54 Carp::cluck sprintf "opengl error %x while %s", $error, sprintf @_; 56 Carp::cluck sprintf "opengl error %x while %s", $error, &sprintf(@_);
55 } 57 }
56} 58}
57 59
58sub find_rcfile($) { 60sub find_rcfile($) {
59 my $path; 61 my $path;
104 -Home => "$Crossfire::VARDIR/pclient", 106 -Home => "$Crossfire::VARDIR/pclient",
105 -Cachesize => 1_000_000, 107 -Cachesize => 1_000_000,
106 -ErrFile => "$Crossfire::VARDIR/pclient/errorlog.txt", 108 -ErrFile => "$Crossfire::VARDIR/pclient/errorlog.txt",
107# -ErrPrefix => "DATABASE", 109# -ErrPrefix => "DATABASE",
108 -Verbose => 1, 110 -Verbose => 1,
109 -Flags => DB_CREATE | DB_RECOVER_FATAL | DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_TXN, 111 -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"; 112 or die "unable to create/open database home $Crossfire::VARDIR/pclient: $BerkeleyDB::Error";
111 113
112sub db_table($) { 114sub db_table($) {
113 my ($table) = @_; 115 my ($table) = @_;
114 116
117 new CFClient::Database 119 new CFClient::Database
118 -Env => $DB_ENV, 120 -Env => $DB_ENV,
119 -Filename => $table, 121 -Filename => $table,
120# -Filename => "database", 122# -Filename => "database",
121# -Subname => $table, 123# -Subname => $table,
124 -Property => DB_CHKSUM,
122 -Flags => DB_CREATE | DB_UPGRADE, 125 -Flags => DB_CREATE | DB_UPGRADE,
123 or die "unable to create/open database table $_[0]: $BerkeleyDB::Error"; 126 or die "unable to create/open database table $_[0]: $BerkeleyDB::Error";
127}
128
129sub pod_to_pango($) {
130 my ($pom) = @_;
131
132 $pom->present ("CFClient::PodToPango")
133}
134
135package CFClient::PodToPango;
136
137use base Pod::POM::View::Text;
138
139our $indent = 0;
140
141*view_seq_code =
142*view_seq_bold = sub { "<b>$_[1]</b>" };
143*view_seq_italic = sub { "<i>$_[1]</i>" };
144*view_seq_space =
145*view_seq_link =
146*view_seq_index = sub { CFClient::UI::Label::escape ($_[1]) };
147
148sub view_seq_text {
149 my $text = $_[1];
150 $text =~ s/\s+/ /g;
151 CFClient::UI::Label::escape ($text)
152}
153
154sub view_item {
155 ("\t" x ($indent / 4))
156 . $_[1]->title->present ($_[0])
157 . "\n"
158 . $_[1]->content->present ($_[0])
159}
160
161sub view_verbatim {
162 (join "",
163 map +("\t" x ($indent / 2)) . "$_\n",
164 split /\n/, CFClient::UI::Label::escape ($_[1]))
165 . "\n"
166}
167
168sub view_textblock {
169 ("\t" x ($indent / 2)) . "$_[1]\n\n"
170}
171
172sub view_head2 {
173 "<big>" . $_[1]->title->present ($_[0]) . "</big>\n\n"
174 . $_[1]->content->present ($_[0])
175};
176
177sub view_over {
178 local $indent = $indent + $_[1]->indent;
179 $_[1]->content->present ($_[0])
124} 180}
125 181
126package CFClient::Database; 182package CFClient::Database;
127 183
128our @ISA = BerkeleyDB::Btree::; 184our @ISA = BerkeleyDB::Btree::;
201#} 257#}
202 258
203sub new_from_layout { 259sub new_from_layout {
204 my ($class, $layout, %arg) = @_; 260 my ($class, $layout, %arg) = @_;
205 261
206 my ($w, $h, $data) = $layout->render; 262 my ($w, $h, $data, $format, $internalformat) = $layout->render;
207 263
208 $class->new ( 264 $class->new (
209 w => $w, 265 w => $w,
210 h => $h, 266 h => $h,
211 data => $data, 267 data => $data,
212 format => GL_ALPHA, 268 format => $format,
213 internalformat => GL_ALPHA, 269 internalformat => $format,
214 type => GL_UNSIGNED_BYTE, 270 type => GL_UNSIGNED_BYTE,
215 %arg, 271 %arg,
216 ) 272 )
217} 273}
218 274
300 glGetError; 356 glGetError;
301 357
302 if (defined $data) { 358 if (defined $data) {
303 glTexImage2D GL_TEXTURE_2D, 0, 359 glTexImage2D GL_TEXTURE_2D, 0,
304 $self->{internalformat}, 360 $self->{internalformat},
305 $tw, $th, # need to pad texture first 361 $tw, $th,
306 0, 362 0,
307 $self->{format}, 363 $self->{format},
308 $self->{type}, 364 $self->{type},
309 $data; 365 $data;
310 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",
316 $tw, $th, 372 $tw, $th,
317 0; 373 0;
318 CFClient::gl_check "copying to texture %dx%d if=%x", 374 CFClient::gl_check "copying to texture %dx%d if=%x",
319 $tw, $th, $self->{internalformat}; 375 $tw, $th, $self->{internalformat};
320 } 376 }
377
378 glBindTexture GL_TEXTURE_2D, 0; # just to be on the safe side
321} 379}
322 380
323sub DESTROY { 381sub DESTROY {
324 my ($self) = @_; 382 my ($self) = @_;
325 383
327 385
328 glDeleteTexture delete $self->{name} 386 glDeleteTexture delete $self->{name}
329 if $self->{name}; 387 if $self->{name};
330} 388}
331 389
332sub restore_state{ 390sub restore_state {
333 $_->upload 391 $_->upload
334 for values %TEXTURES; 392 for values %TEXTURES;
335}; 393}
336 394
3371; 3951;
338 396
339=back 397=back
340 398

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines