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.15 by elmex, Fri Apr 7 17:18:22 2006 UTC vs.
Revision 1.16 by elmex, Fri Apr 7 17:37:11 2006 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2
3use strict; 2use strict;
4 3
5use Glib; 4use Glib;
6use Gtk2 -init; 5use Gtk2 -init;
7 6
84 83
85sub refresh { 84sub refresh {
86 glClearColor 0, 0, 0, 0; 85 glClearColor 0, 0, 0, 0;
87 glClear GL_COLOR_BUFFER_BIT; 86 glClear GL_COLOR_BUFFER_BIT;
88 87
89 my $map = $CONN->{map}; 88 for (values %Client::Widget::ACTIVE_WIDGETS) {
90 89 $_->draw
91 for my $x (0 .. $CONN->{mapw} - 1) {
92 for my $y (0 .. $CONN->{maph} - 1) {
93
94 my $cell = $map->[$x][$y]
95 or next;
96
97 my $darkness = $cell->[3] * (1 / 255);
98 glColor $darkness, $darkness, $darkness;
99
100 for my $num (grep $_, $cell->[0], $cell->[1], $cell->[2]) {
101 my $tex = $CONN->{face}[$num]{texture} || 0;
102
103 glBindTexture GL_TEXTURE_2D, $tex;
104
105 glBegin GL_QUADS;
106 glTexCoord 0, 0; glVertex $x, $y;
107 glTexCoord 0, 1; glVertex $x, $y + 1;
108 glTexCoord 1, 1; glVertex $x + 1, $y + 1;
109 glTexCoord 1, 0; glVertex $x + 1, $y;
110 glEnd;
111 }
112 }
113 } 90 }
114 91
115 SDL::GLSwapBuffers; 92 SDL::GLSwapBuffers;
116} 93}
117 94
124 }, 101 },
125 SDL_VIDEOEXPOSE() => sub { 102 SDL_VIDEOEXPOSE() => sub {
126 refresh; 103 refresh;
127 }, 104 },
128 SDL_KEYDOWN() => sub { 105 SDL_KEYDOWN() => sub {
129# Client::Widget::feed_sdl_key_down_event ($SDL_EV); 106 Client::Widget::feed_sdl_key_down_event ($SDL_EV);
130 }, 107 },
131 SDL_KEYUP() => sub { 108 SDL_KEYUP() => sub {
132# Client::Widget::feed_sdl_key_up_event ($SDL_EV); 109 Client::Widget::feed_sdl_key_up_event ($SDL_EV);
133 }, 110 },
134 SDL_MOUSEMOTION() => sub { 111 SDL_MOUSEMOTION() => sub {
135 warn "sdl motion\n";#d# 112 warn "sdl motion\n";#d#
136 }, 113 },
137 SDL_MOUSEBUTTONDOWN() => sub { 114 SDL_MOUSEBUTTONDOWN() => sub {
138# Client::Widget::feed_sdl_button_down_event ($SDL_EV); 115 Client::Widget::feed_sdl_button_down_event ($SDL_EV);
139 }, 116 },
140 SDL_MOUSEBUTTONUP() => sub { 117 SDL_MOUSEBUTTONUP() => sub {
141# Client::Widget::feed_sdl_button_up_event ($SDL_EV); 118 Client::Widget::feed_sdl_button_up_event ($SDL_EV);
142 }, 119 },
143 SDL_ACTIVEEVENT() => sub { 120 SDL_ACTIVEEVENT() => sub {
144 warn "active\n";#d# 121 warn "active\n";#d#
145 }, 122 },
146); 123);
198 my $glerr=glGetError(); die "Problem setting up 2d Texture (dimensions not a power of 2?)):".gluErrorString($glerr)."\n" if $glerr; 175 my $glerr=glGetError(); die "Problem setting up 2d Texture (dimensions not a power of 2?)):".gluErrorString($glerr)."\n" if $glerr;
199} 176}
200 177
201############################################################################# 178#############################################################################
202 179
180my $mapwidget = Client::MapWidget->new;
181
182$mapwidget->activate;
183$mapwidget->focus_in;
184
203Client::Util::read_cfg "$Crossfire::VARDIR/pclientrc"; 185Client::Util::read_cfg "$Crossfire::VARDIR/pclientrc";
204 186
205$CFG ||= { 187$CFG ||= {
206 width => 640, 188 width => 640,
207 height => 480, 189 height => 480,
209 host => "crossfire.schmorp.de", 191 host => "crossfire.schmorp.de",
210 port => 13327, 192 port => 13327,
211}; 193};
212 194
213Client::Util::run_config_dialog 195Client::Util::run_config_dialog
214 login => sub { start_game }, 196 login => sub { start_game },
215 logout => sub { stop_game }, 197 logout => sub { stop_game };
216 198
217main Gtk2; 199main Gtk2;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines