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.9 by root, Fri Apr 7 13:53:38 2006 UTC

36 -blue_size => 8, 36 -blue_size => 8,
37 -double_buffer => 1, 37 -double_buffer => 1,
38 -resizeable => 0; 38 -resizeable => 0;
39 39
40 glEnable GL_TEXTURE_2D; 40 glEnable GL_TEXTURE_2D;
41# glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 41 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
42 glShadeModel GL_FLAT; 42 glShadeModel GL_FLAT;
43 glDisable GL_DEPTH_TEST; 43 glDisable GL_DEPTH_TEST;
44 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
45 glEnable GL_BLEND;
46
44 glMatrixMode GL_PROJECTION; 47 glMatrixMode GL_PROJECTION;
45 glBlendFunc GL_SRC_ALPHA, GL_ZERO;
46 glEnable GL_BLEND;
47
48 glLoadIdentity; 48 glLoadIdentity;
49 glOrtho 0, $WIDTH / 32, $HEIGHT / 32, 0, -1 , 1; 49 glOrtho 0, $WIDTH / 32, $HEIGHT / 32, 0, -1 , 1;
50 50
51 # re-bind all textures 51 # re-bind all textures
52} 52}
61 for my $y (0 .. $conn->{maph} - 1) { 61 for my $y (0 .. $conn->{maph} - 1) {
62 62
63 my $cell = $map->[$x][$y] 63 my $cell = $map->[$x][$y]
64 or next; 64 or next;
65 65
66# my $darkness = $cell->[3] * (1 / 255); 66 my $darkness = $cell->[3] * (1 / 255);
67 my $darkness = 0.8 + 0.2*rand;
67# glColor $darkness, $darkness, $darkness; 68 glColor $darkness, $darkness, $darkness;
68 69
69 for my $num (grep $_, $cell->[0], $cell->[1], $cell->[2]) { 70 for my $num (grep $_, $cell->[0], $cell->[1], $cell->[2]) {
70 my $tex = $conn->{face}[$num]{texture} || 0; 71 my $tex = $conn->{face}[$num]{texture} || 0;
71 72
72 glBindTexture GL_TEXTURE_2D, $tex; 73 glBindTexture GL_TEXTURE_2D, $tex;
153 154
154sub conn::face_update { 155sub conn::face_update {
155 my ($self, $num, $face) = @_; 156 my ($self, $num, $face) = @_;
156 157
157 warn "up face $self,$num,$face\n";#d# 158 warn "up face $self,$num,$face\n";#d#
158 #TODO 159 use Gtk2;
159 open my $fh, ">:raw", "/tmp/x~"; 160
161 my $pb = new Gtk2::Gdk::PixbufLoader;
160 syswrite $fh, $face->{image}; 162 $pb->write ($face->{image});
161 close $fh; 163 $pb->close;
162 164
163 my $surface = new SDL::Surface -name => "/tmp/x~"; 165 $pb = $pb->get_pixbuf;
166 $pb = $pb->add_alpha (0, 0, 0, 0);
164 167
165 unlink "/tmp/x~"; 168 glGetError();
166
167 my ($tex) = @{glGenTextures 1}; 169 my ($tex) = @{glGenTextures 1};
168 glGetError();
169 170
170 $face->{texture} = $tex; 171 $face->{texture} = $tex;
171 172
172 glBindTexture GL_TEXTURE_2D, $tex; 173 glBindTexture GL_TEXTURE_2D, $tex;
173 my $glerr=glGetError(); die "a: ".gluErrorString($glerr)."\n" if $glerr; 174 my $glerr=glGetError(); die "a: ".gluErrorString($glerr)."\n" if $glerr;
175 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR; 176 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR;
176 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR;#_MIPMAP_LINEAR; 177 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR;#_MIPMAP_LINEAR;
177 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP; 178 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP;
178 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP; 179 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP;
179 180
180 $surface->rgba;
181
182 glTexImage2D GL_TEXTURE_2D, 0, 181 glTexImage2D GL_TEXTURE_2D, 0,
183 4, # components 182 GL_RGBA8,
184 $surface->width, $surface->height, 183 $pb->get_width, $pb->get_height,
185 0, 184 0,
186 GL_RGBA, 185 GL_RGBA,
187 GL_UNSIGNED_BYTE, 186 GL_UNSIGNED_BYTE,
188 $surface->pixels; 187 $pb->get_pixels;
189 my $glerr=glGetError(); die "Problem setting up 2d Texture (dimensions not a power of 2?)):".gluErrorString($glerr)."\n" if $glerr; 188 my $glerr=glGetError(); die "Problem setting up 2d Texture (dimensions not a power of 2?)):".gluErrorString($glerr)."\n" if $glerr;
190} 189}
191 190
192############################################################################# 191#############################################################################
193 192

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines