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.6 by root, Thu Apr 6 21:15:11 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_DECAL; 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
46 glLoadIdentity; 48 glLoadIdentity;
47 glOrtho 0, $WIDTH / 32, $HEIGHT / 32, 0, -1 , 1; 49 glOrtho 0, $WIDTH / 32, $HEIGHT / 32, 0, -1 , 1;
48 50
49 # re-bind all textures 51 # re-bind all textures
50} 52}
51 53
52sub refresh { 54sub refresh {
53 glClearColor 0.5, 0.5, 0.7, 0; 55 glClearColor 0, 0, 0, 0;
54 glClear GL_COLOR_BUFFER_BIT; 56 glClear GL_COLOR_BUFFER_BIT;
55 57
56 my $map = $conn->{map}; 58 my $map = $conn->{map};
57 59
58 for my $x (0 .. $conn->{mapw} - 1) { 60 for my $x (0 .. $conn->{mapw} - 1) {
59 for my $y (0 .. $conn->{maph} - 1) { 61 for my $y (0 .. $conn->{maph} - 1) {
60 62
61 my $cell = $map->[$x][$y] 63 my $cell = $map->[$x][$y]
62 or next; 64 or next;
65
66 my $darkness = $cell->[3] * (1 / 255);
67 my $darkness = 0.8 + 0.2*rand;
68 glColor $darkness, $darkness, $darkness;
63 69
64 for my $num (grep $_, $cell->[0], $cell->[1], $cell->[2]) { 70 for my $num (grep $_, $cell->[0], $cell->[1], $cell->[2]) {
65 my $tex = $conn->{face}[$num]{texture} || 0; 71 my $tex = $conn->{face}[$num]{texture} || 0;
66 72
67 glBindTexture GL_TEXTURE_2D, $tex; 73 glBindTexture GL_TEXTURE_2D, $tex;
68 74
69 glColor 1,0.2,0.7;
70 glBegin GL_QUADS; 75 glBegin GL_QUADS;
71 glTexCoord 0, 0; glVertex $x, $y; 76 glTexCoord 0, 0; glVertex $x, $y;
72 glTexCoord 0, 1; glVertex $x, $y + 0.9; 77 glTexCoord 0, 1; glVertex $x, $y + 1;
73 glTexCoord 1, 1; glVertex $x + 0.9, $y + 0.9; 78 glTexCoord 1, 1; glVertex $x + 1, $y + 1;
74 glTexCoord 1, 0; glVertex $x + 0.9, $y; 79 glTexCoord 1, 0; glVertex $x + 1, $y;
75 glEnd; 80 glEnd;
76 } 81 }
77 } 82 }
78 } 83 }
79 84
149 154
150sub conn::face_update { 155sub conn::face_update {
151 my ($self, $num, $face) = @_; 156 my ($self, $num, $face) = @_;
152 157
153 warn "up face $self,$num,$face\n";#d# 158 warn "up face $self,$num,$face\n";#d#
154 #TODO 159 use Gtk2;
155 open my $fh, ">:raw", "/tmp/x~"; 160
161 my $pb = new Gtk2::Gdk::PixbufLoader;
156 syswrite $fh, $face->{image}; 162 $pb->write ($face->{image});
157 close $fh; 163 $pb->close;
158 164
159 my $surface = new SDL::Surface -name => "/tmp/x~"; 165 $pb = $pb->get_pixbuf;
166 $pb = $pb->add_alpha (0, 0, 0, 0);
160 167
161 unlink "/tmp/x~"; 168 glGetError();
162
163 my ($tex) = @{glGenTextures 1}; 169 my ($tex) = @{glGenTextures 1};
164 glGetError();
165 170
166 $face->{texture} = $tex; 171 $face->{texture} = $tex;
167 172
168 glBindTexture GL_TEXTURE_2D, $tex; 173 glBindTexture GL_TEXTURE_2D, $tex;
169 my $glerr=glGetError(); die "a: ".gluErrorString($glerr)."\n" if $glerr; 174 my $glerr=glGetError(); die "a: ".gluErrorString($glerr)."\n" if $glerr;
170 175
171 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR; 176 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR;
172 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;
173 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP; 178 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP;
174 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP; 179 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP;
175 180
176 $surface->rgba;
177
178 glTexImage2D GL_TEXTURE_2D, 0, 181 glTexImage2D GL_TEXTURE_2D, 0,
179 4, # components 182 GL_RGBA8,
180 $surface->width, $surface->height, 183 $pb->get_width, $pb->get_height,
181 0, 184 0,
182 GL_RGBA, 185 GL_RGBA,
183 GL_UNSIGNED_BYTE, 186 GL_UNSIGNED_BYTE,
184 $surface->pixels; 187 $pb->get_pixels;
185 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;
186} 189}
187 190
188############################################################################# 191#############################################################################
189 192

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines