… | |
… | |
831 | |
831 | |
832 | sub make_inventory_window { |
832 | sub make_inventory_window { |
833 | my $invwin = new CFClient::UI::FancyFrame |
833 | my $invwin = new CFClient::UI::FancyFrame |
834 | user_w => $WIDTH * (4/5), user_h => $HEIGHT * (4/5), title => "Inventory"; |
834 | user_w => $WIDTH * (4/5), user_h => $HEIGHT * (4/5), title => "Inventory"; |
835 | |
835 | |
836 | $invwin->add (my $hb = new CFClient::UI::HBox); |
836 | $invwin->add (my $hb = new CFClient::UI::HBox expand => 1); |
837 | |
837 | |
838 | $hb->add (my $vb1 = new CFClient::UI::VBox expand => 1); |
838 | $hb->add (my $vb1 = new CFClient::UI::VBox expand => 1); |
839 | $vb1->add (my $lbl = new CFClient::UI::Label); |
839 | $vb1->add (my $lbl = new CFClient::UI::Label); |
840 | $lbl->set_text ("Player"); |
840 | $lbl->set_text ("Player"); |
841 | $vb1->add ($INV = new CFClient::UI::Inventory expand => 1); |
841 | $vb1->add ($INV = new CFClient::UI::Inventory expand => 1); |
… | |
… | |
861 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
861 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
862 | $FULLSCREEN = $CFG->{fullscreen}; |
862 | $FULLSCREEN = $CFG->{fullscreen}; |
863 | $FAST = $CFG->{fast}; |
863 | $FAST = $CFG->{fast}; |
864 | |
864 | |
865 | CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN |
865 | CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN |
866 | or die "SDL_SetVideoMode failed!\n"; |
866 | or die "SDL_SetVideoMode failed: " . (CFClient::SDL_GetError) . "\n"; |
867 | |
867 | |
868 | $SDL_ACTIVE = 1; |
868 | $SDL_ACTIVE = 1; |
869 | $LAST_REFRESH = time - 0.01; |
869 | $LAST_REFRESH = time - 0.01; |
870 | |
870 | |
871 | CFClient::gl_init; |
871 | CFClient::gl_init; |
… | |
… | |
1011 | my %animate_object; |
1011 | my %animate_object; |
1012 | my $animate_timer; |
1012 | my $animate_timer; |
1013 | |
1013 | |
1014 | my $fps = 9; |
1014 | my $fps = 9; |
1015 | |
1015 | |
|
|
1016 | my %demo;#d# |
|
|
1017 | |
1016 | sub force_refresh { |
1018 | sub force_refresh { |
1017 | $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05; |
1019 | $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05; |
1018 | debug sprintf "%3.2f", $fps; |
1020 | debug sprintf "%3.2f", $fps; |
1019 | |
1021 | |
1020 | $CFClient::UI::ROOT->draw; |
1022 | $CFClient::UI::ROOT->draw; |
1021 | CFClient::SDL_GL_SwapBuffers; |
|
|
1022 | |
1023 | |
1023 | $WANT_REFRESH = 0; |
1024 | $WANT_REFRESH = 0; |
1024 | $CAN_REFRESH = 0; |
1025 | $CAN_REFRESH = 0; |
1025 | $LAST_REFRESH = $NOW; |
1026 | $LAST_REFRESH = $NOW; |
|
|
1027 | |
|
|
1028 | 0 && do { |
|
|
1029 | # some weird model-drawing code, just a joke right now |
|
|
1030 | use CFClient::OpenGL; |
|
|
1031 | |
|
|
1032 | $demo{t}{eye_auv} ||= new_from_file CFClient::Texture "eye2.png" or die; |
|
|
1033 | $demo{t}{body_auv} ||= new_from_file CFClient::Texture "body_auv3.png" or die; |
|
|
1034 | $demo{r} ||= do { |
|
|
1035 | my $mod = Compress::LZF::sthaw do { local $/; open my $fh, "<:raw:perlio", "dread.lz3"; <$fh> }; |
|
|
1036 | $mod->{v} = pack "f*", @{$mod->{v}}; |
|
|
1037 | $_ = [scalar @$_, pack "S!*", @$_] |
|
|
1038 | for values %{$mod->{g}}; |
|
|
1039 | $mod |
|
|
1040 | }; |
|
|
1041 | |
|
|
1042 | my $r = $demo{r} or die; |
|
|
1043 | |
|
|
1044 | glDepthMask 1; |
|
|
1045 | glClear GL_DEPTH_BUFFER_BIT; |
|
|
1046 | glEnable GL_TEXTURE_2D; |
|
|
1047 | glEnable GL_DEPTH_TEST; |
|
|
1048 | glDisable GL_CULL_FACE; |
|
|
1049 | glShadeModel $::FAST ? GL_FLAT : GL_SMOOTH; |
|
|
1050 | |
|
|
1051 | glMatrixMode GL_PROJECTION; |
|
|
1052 | glLoadIdentity; |
|
|
1053 | #glFrustum -100, 100, 100, -100, 1, 1000; |
|
|
1054 | glOrtho 0, $::WIDTH, 0, $::HEIGHT, -10000, 10000; |
|
|
1055 | glMatrixMode GL_MODELVIEW; |
|
|
1056 | glLoadIdentity; |
|
|
1057 | |
|
|
1058 | glPushMatrix; |
|
|
1059 | glTranslate $::WIDTH * 0.5, $::HEIGHT * 0.5, -100; |
|
|
1060 | glRotate $NOW * 1000 % 36000 / 20, 0, 1, 0; |
|
|
1061 | glScale 50, 50, 50; |
|
|
1062 | |
|
|
1063 | glInterleavedArrays GL_T2F_N3F_V3F, 0, $r->{v}; |
|
|
1064 | while (my ($k, $v) = each %{$r->{g}}) { |
|
|
1065 | glBindTexture GL_TEXTURE_2D, ($demo{t}{$k}{name} or die); |
|
|
1066 | glDrawElements GL_TRIANGLES, $v->[0], GL_UNSIGNED_SHORT, $v->[1]; |
|
|
1067 | } |
|
|
1068 | |
|
|
1069 | glPopMatrix; |
|
|
1070 | |
|
|
1071 | glShadeModel GL_FLAT; |
|
|
1072 | glDisable GL_DEPTH_TEST; |
|
|
1073 | glDisable GL_TEXTURE_2D; |
|
|
1074 | glDepthMask 0; |
|
|
1075 | |
|
|
1076 | $WANT_REFRESH++; |
|
|
1077 | }; |
|
|
1078 | |
|
|
1079 | CFClient::SDL_GL_SwapBuffers; |
1026 | } |
1080 | } |
1027 | |
1081 | |
1028 | my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { |
1082 | my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { |
1029 | $NOW = time; |
1083 | $NOW = time; |
1030 | |
1084 | |
… | |
… | |
1617 | sdl_mode => 0, |
1671 | sdl_mode => 0, |
1618 | width => 640, |
1672 | width => 640, |
1619 | height => 480, |
1673 | height => 480, |
1620 | fullscreen => 0, |
1674 | fullscreen => 0, |
1621 | fast => 0, |
1675 | fast => 0, |
1622 | map_scale => 0.5, |
1676 | map_scale => 1, |
1623 | fow_enable => 1, |
1677 | fow_enable => 1, |
1624 | fow_intensity => 0.45, |
1678 | fow_intensity => 0.45, |
1625 | fow_smooth => 0, |
1679 | fow_smooth => 0, |
1626 | gui_fontsize => 1, |
1680 | gui_fontsize => 1, |
1627 | log_fontsize => 1, |
1681 | log_fontsize => 1, |