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

Comparing deliantra/Deliantra-Client/bin/pclient (file contents):
Revision 1.8 by root, Fri Apr 7 08:42:56 2006 UTC vs.
Revision 1.10 by elmex, Fri Apr 7 16:04:03 2006 UTC

3use strict; 3use strict;
4 4
5use Crossfire::Client; 5use Crossfire::Client;
6use Crossfire::Protocol; 6use Crossfire::Protocol;
7 7
8use Client::Util;
9
8package Crossfire::Client; # uh, yeah 10package Crossfire::Client; # uh, yeah
9 11
10use strict; 12use strict;
13
14our $CFG;
15our $VERSION = '0.1';
11 16
12use SDL; 17use SDL;
13use SDL::App; 18use SDL::App;
14use SDL::Event; 19use SDL::Event;
15use SDL::Surface; 20use SDL::Surface;
36 -blue_size => 8, 41 -blue_size => 8,
37 -double_buffer => 1, 42 -double_buffer => 1,
38 -resizeable => 0; 43 -resizeable => 0;
39 44
40 glEnable GL_TEXTURE_2D; 45 glEnable GL_TEXTURE_2D;
41# glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 46 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
42 glShadeModel GL_FLAT; 47 glShadeModel GL_FLAT;
43 glDisable GL_DEPTH_TEST; 48 glDisable GL_DEPTH_TEST;
49 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
50 glEnable GL_BLEND;
51
44 glMatrixMode GL_PROJECTION; 52 glMatrixMode GL_PROJECTION;
45 glBlendFunc GL_SRC_ALPHA, GL_ZERO;
46 glEnable GL_BLEND;
47
48 glLoadIdentity; 53 glLoadIdentity;
49 glOrtho 0, $WIDTH / 32, $HEIGHT / 32, 0, -1 , 1; 54 glOrtho 0, $WIDTH / 32, $HEIGHT / 32, 0, -1 , 1;
50 55
51 # re-bind all textures 56 # re-bind all textures
52} 57}
61 for my $y (0 .. $conn->{maph} - 1) { 66 for my $y (0 .. $conn->{maph} - 1) {
62 67
63 my $cell = $map->[$x][$y] 68 my $cell = $map->[$x][$y]
64 or next; 69 or next;
65 70
66# my $darkness = $cell->[3] * (1 / 255); 71 my $darkness = $cell->[3] * (1 / 255);
72 my $darkness = 0.8 + 0.2*rand;
67# glColor $darkness, $darkness, $darkness; 73 glColor $darkness, $darkness, $darkness;
68 74
69 for my $num (grep $_, $cell->[0], $cell->[1], $cell->[2]) { 75 for my $num (grep $_, $cell->[0], $cell->[1], $cell->[2]) {
70 my $tex = $conn->{face}[$num]{texture} || 0; 76 my $tex = $conn->{face}[$num]{texture} || 0;
71 77
72 glBindTexture GL_TEXTURE_2D, $tex; 78 glBindTexture GL_TEXTURE_2D, $tex;
153 159
154sub conn::face_update { 160sub conn::face_update {
155 my ($self, $num, $face) = @_; 161 my ($self, $num, $face) = @_;
156 162
157 warn "up face $self,$num,$face\n";#d# 163 warn "up face $self,$num,$face\n";#d#
158 #TODO 164 use Gtk2;
159 open my $fh, ">:raw", "/tmp/x~"; 165
166 my $pb = new Gtk2::Gdk::PixbufLoader;
160 syswrite $fh, $face->{image}; 167 $pb->write ($face->{image});
161 close $fh; 168 $pb->close;
162 169
163 my $surface = new SDL::Surface -name => "/tmp/x~"; 170 $pb = $pb->get_pixbuf;
171 $pb = $pb->add_alpha (0, 0, 0, 0);
164 172
165 unlink "/tmp/x~"; 173 glGetError();
166
167 my ($tex) = @{glGenTextures 1}; 174 my ($tex) = @{glGenTextures 1};
168 glGetError();
169 175
170 $face->{texture} = $tex; 176 $face->{texture} = $tex;
171 177
172 glBindTexture GL_TEXTURE_2D, $tex; 178 glBindTexture GL_TEXTURE_2D, $tex;
173 my $glerr=glGetError(); die "a: ".gluErrorString($glerr)."\n" if $glerr; 179 my $glerr=glGetError(); die "a: ".gluErrorString($glerr)."\n" if $glerr;
175 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR; 181 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR;
176 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR;#_MIPMAP_LINEAR; 182 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR;#_MIPMAP_LINEAR;
177 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP; 183 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP;
178 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP; 184 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP;
179 185
180 $surface->rgba;
181
182 glTexImage2D GL_TEXTURE_2D, 0, 186 glTexImage2D GL_TEXTURE_2D, 0,
183 4, # components 187 GL_RGBA8,
184 $surface->width, $surface->height, 188 $pb->get_width, $pb->get_height,
185 0, 189 0,
186 GL_RGBA, 190 GL_RGBA,
187 GL_UNSIGNED_BYTE, 191 GL_UNSIGNED_BYTE,
188 $surface->pixels; 192 $pb->get_pixels;
189 my $glerr=glGetError(); die "Problem setting up 2d Texture (dimensions not a power of 2?)):".gluErrorString($glerr)."\n" if $glerr; 193 my $glerr=glGetError(); die "Problem setting up 2d Texture (dimensions not a power of 2?)):".gluErrorString($glerr)."\n" if $glerr;
190} 194}
191 195
192############################################################################# 196#############################################################################
193 197
194use Event; 198use Event;
199
200Client::Util::read_cfg "$Crossfire::VARDIR/pclient";
195 201
196glinit; 202glinit;
197 203
198$conn = new conn 204$conn = new conn
199 host => "cf.schmorp.de", 205 host => "cf.schmorp.de",
205 } 211 }
206}); 212});
207 213
208Event::loop; 214Event::loop;
209 215
210

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines