… | |
… | |
103 | use AnyEvent::Socket (); |
103 | use AnyEvent::Socket (); |
104 | |
104 | |
105 | use Compress::LZF; |
105 | use Compress::LZF; |
106 | |
106 | |
107 | use DC; |
107 | use DC; |
108 | BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$@" unless $^S } } |
108 | BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$_[0]" unless $^S } } |
109 | use DC::OpenGL (); |
109 | use DC::OpenGL (); |
110 | use DC::Protocol; |
110 | use DC::Protocol; |
111 | use DC::DB; |
111 | use DC::DB; |
112 | use DC::UI; |
112 | use DC::UI; |
113 | use DC::UI::Canvas; |
113 | use DC::UI::Canvas; |
… | |
… | |
142 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
142 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
143 | |
143 | |
144 | our $WANT_REFRESH; |
144 | our $WANT_REFRESH; |
145 | |
145 | |
146 | our @SDL_MODES; |
146 | our @SDL_MODES; |
|
|
147 | our $SDL_REINIT = 1; |
147 | our $WIDTH; |
148 | our $WIDTH; |
148 | our $HEIGHT; |
149 | our $HEIGHT; |
149 | our $FULLSCREEN; |
150 | our $FULLSCREEN; |
150 | our $FONTSIZE; |
151 | our $FONTSIZE; |
151 | |
152 | |
… | |
… | |
864 | state => $CFG->{force_opengl11}, |
865 | state => $CFG->{force_opengl11}, |
865 | tooltip => "Limit Deliantra to use OpenGL 1.1 features only. This will normally result in " |
866 | tooltip => "Limit Deliantra to use OpenGL 1.1 features only. This will normally result in " |
866 | . "higher memory usage and slower performance. It will, however, help tremendously on " |
867 | . "higher memory usage and slower performance. It will, however, help tremendously on " |
867 | . "cards that claim to support a feature but fall back to software rendering. " |
868 | . "cards that claim to support a feature but fall back to software rendering. " |
868 | . "Nvidia Geforce FX cards are known to claim features the hardware doesn't support, " |
869 | . "Nvidia Geforce FX cards are known to claim features the hardware doesn't support, " |
869 | . "but cards and drivers from other vendors (ATI) are often just as bad. <b>If you " |
870 | . "but cards and drivers from other vendors (ATI) are often just as bad. " |
870 | . "experience extremely low framerates and your card should do better, try this option.</b>", |
871 | . "<b>If you experience extremely low framerates and your card should do better, try this option.</b>", |
871 | on_changed => sub { my ($self, $value) = @_; $CFG->{force_opengl11} = $value; 0 } |
872 | on_changed => sub { my ($self, $value) = @_; $CFG->{force_opengl11} = $value; 0 } |
|
|
873 | ); |
|
|
874 | |
|
|
875 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Forbid Alpha"); |
|
|
876 | $table->add_at (1, $row++, new DC::UI::CheckBox |
|
|
877 | state => $CFG->{disable_alpha}, |
|
|
878 | tooltip => "Forbid off the use of the alpha channel. This makes Deliantra look a lot worse " |
|
|
879 | . "by disabling a number of textures and transparency effects. Normally, these " |
|
|
880 | . "effects do not cost a lot of resources, but some graphics cards might fall " |
|
|
881 | . "back to etxremely slow rendering if this is enabled. If disabling this option " |
|
|
882 | . "noticably improves the framerate of the client please report this! " |
|
|
883 | . "<b>If you experience extremely low framerates and your card should do better, try this option.</b>", |
|
|
884 | on_changed => sub { |
|
|
885 | my ($self, $value) = @_; |
|
|
886 | $CFG->{disable_alpha} = $value; |
|
|
887 | $SDL_REINIT = 1; # SDL_SetVideoMode ignores GL attr changes |
|
|
888 | 0 |
|
|
889 | } |
872 | ); |
890 | ); |
873 | |
891 | |
874 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Compress Textures"); |
892 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Compress Textures"); |
875 | $table->add_at (1, $row++, new DC::UI::CheckBox |
893 | $table->add_at (1, $row++, new DC::UI::CheckBox |
876 | state => $CFG->{texture_compression}, |
894 | state => $CFG->{texture_compression}, |
… | |
… | |
2147 | $dialog->show; |
2165 | $dialog->show; |
2148 | }; |
2166 | }; |
2149 | } |
2167 | } |
2150 | |
2168 | |
2151 | sub sdl_init { |
2169 | sub sdl_init { |
2152 | DC::SDL_Init |
2170 | DC::SDL_Init DC::SDL_INIT_AUDIO #| DC::SDL_NOPARACHUTE |
2153 | and die "SDL::Init failed!\n"; |
2171 | and die "SDL::Init failed!\n"; |
2154 | } |
2172 | } |
2155 | |
2173 | |
2156 | sub video_init { |
2174 | sub video_init { |
|
|
2175 | DC::SDL_InitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT; |
|
|
2176 | $SDL_REINIT = 0; |
|
|
2177 | |
|
|
2178 | @SDL_MODES = DC::SDL_ListModes 8, $CFG->{disable_alpha} ? 0 : 8; |
|
|
2179 | @SDL_MODES = DC::SDL_ListModes 8, 8 unless @SDL_MODES; |
|
|
2180 | @SDL_MODES = DC::SDL_ListModes 5, 0 unless @SDL_MODES; |
|
|
2181 | @SDL_MODES or DC::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
|
|
2182 | |
|
|
2183 | @SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES; |
|
|
2184 | |
2157 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} >= @SDL_MODES; |
2185 | if (!exists $CFG->{sdl_mode} or $CFG->{sdl_mode} >= @SDL_MODES) { |
|
|
2186 | $CFG->{sdl_mode} = 0; |
|
|
2187 | for (reverse 0 .. $#SDL_MODES) { |
|
|
2188 | $CFG->{sdl_mode} = $_ if $SDL_MODES[$_][0] * $SDL_MODES[$_][1] >= 800 * 600; |
|
|
2189 | } |
|
|
2190 | } |
2158 | |
2191 | |
2159 | my ($old_w, $old_h) = ($WIDTH, $HEIGHT); |
2192 | my ($old_w, $old_h) = ($WIDTH, $HEIGHT); |
2160 | |
2193 | |
2161 | ($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
2194 | ($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
2162 | $FULLSCREEN = $CFG->{fullscreen}; |
2195 | $FULLSCREEN = $CFG->{fullscreen}; |
… | |
… | |
2351 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
2384 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
2352 | } |
2385 | } |
2353 | |
2386 | |
2354 | sub video_shutdown { |
2387 | sub video_shutdown { |
2355 | DC::OpenGL::shutdown; |
2388 | DC::OpenGL::shutdown; |
|
|
2389 | DC::SDL_QuitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT; |
2356 | |
2390 | |
2357 | undef $SDL_ACTIVE; |
2391 | undef $SDL_ACTIVE; |
2358 | } |
2392 | } |
2359 | |
2393 | |
2360 | my %animate_object; |
2394 | my %animate_object; |
… | |
… | |
2421 | # printf "M\n" if $_[0]{state} & DC::SDL_APPMOUSEFOCUS; |
2455 | # printf "M\n" if $_[0]{state} & DC::SDL_APPMOUSEFOCUS; |
2422 | }, |
2456 | }, |
2423 | DC::SDL_KEYDOWN => sub { |
2457 | DC::SDL_KEYDOWN => sub { |
2424 | if ($_[0]{mod} & DC::KMOD_ALT && $_[0]{sym} == 13) { |
2458 | if ($_[0]{mod} & DC::KMOD_ALT && $_[0]{sym} == 13) { |
2425 | # alt-enter |
2459 | # alt-enter |
|
|
2460 | video_shutdown; |
2426 | $FULLSCREEN_ENABLE->toggle; |
2461 | $FULLSCREEN_ENABLE->toggle; |
2427 | video_shutdown; |
|
|
2428 | video_init; |
2462 | video_init; |
2429 | } else { |
2463 | } else { |
2430 | &DC::UI::feed_sdl_key_down_event; |
2464 | &DC::UI::feed_sdl_key_down_event; |
2431 | } |
2465 | } |
2432 | update_modbox; |
2466 | update_modbox; |
… | |
… | |
2481 | my %DEF_CFG = ( |
2515 | my %DEF_CFG = ( |
2482 | sdl_mode => 0, |
2516 | sdl_mode => 0, |
2483 | fullscreen => 1, |
2517 | fullscreen => 1, |
2484 | fast => 0, |
2518 | fast => 0, |
2485 | force_opengl11 => undef, |
2519 | force_opengl11 => undef, |
|
|
2520 | disable_alpha => 0, |
2486 | texture_compression => 1, |
2521 | texture_compression => 1, |
2487 | map_scale => 1, |
2522 | map_scale => 1, |
2488 | fow_enable => 1, |
2523 | fow_enable => 1, |
2489 | fow_intensity => 0, |
2524 | fow_intensity => 0, |
2490 | map_smoothing => 1, |
2525 | map_smoothing => 1, |
… | |
… | |
2531 | } |
2566 | } |
2532 | } |
2567 | } |
2533 | |
2568 | |
2534 | sdl_init; |
2569 | sdl_init; |
2535 | |
2570 | |
2536 | @SDL_MODES = DC::SDL_ListModes 8, 8; |
|
|
2537 | @SDL_MODES = DC::SDL_ListModes 5, 0 unless @SDL_MODES; |
|
|
2538 | @SDL_MODES or DC::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
|
|
2539 | |
|
|
2540 | @SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES; |
|
|
2541 | |
|
|
2542 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
|
|
2543 | |
|
|
2544 | { |
2571 | { |
2545 | my @fonts = map DC::find_rcfile "fonts/$_", qw( |
2572 | my @fonts = map DC::find_rcfile "fonts/$_", qw( |
2546 | DejaVuSans.ttf |
2573 | DejaVuSans.ttf |
2547 | DejaVuSansMono.ttf |
2574 | DejaVuSansMono.ttf |
2548 | DejaVuSans-Bold.ttf |
2575 | DejaVuSans-Bold.ttf |