… | |
… | |
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; |
|
|
1023 | |
|
|
1024 | 0 && do { |
|
|
1025 | # some weird model-drawing code, just a joke right now |
|
|
1026 | use CFClient::OpenGL; |
|
|
1027 | |
|
|
1028 | $demo{t}{eye_auv} ||= new_from_file CFClient::Texture "eye2.png" or die; |
|
|
1029 | $demo{t}{body_auv} ||= new_from_file CFClient::Texture "body_auv3.png" or die; |
|
|
1030 | $demo{r} ||= do { |
|
|
1031 | my $mod = Compress::LZF::sthaw do { local $/; open my $fh, "<:raw:perlio", "dread.lz3"; <$fh> }; |
|
|
1032 | $mod->{v} = pack "f*", @{$mod->{v}}; |
|
|
1033 | $_ = [scalar @$_, pack "S!*", @$_] |
|
|
1034 | for values %{$mod->{g}}; |
|
|
1035 | $mod |
|
|
1036 | }; |
|
|
1037 | |
|
|
1038 | my $r = $demo{r} or die; |
|
|
1039 | |
|
|
1040 | glDepthMask 1; |
|
|
1041 | glClear GL_DEPTH_BUFFER_BIT; |
|
|
1042 | glEnable GL_TEXTURE_2D; |
|
|
1043 | glEnable GL_DEPTH_TEST; |
|
|
1044 | glDisable GL_CULL_FACE; |
|
|
1045 | glShadeModel GL_SMOOTH; |
|
|
1046 | |
|
|
1047 | glMatrixMode GL_PROJECTION; |
|
|
1048 | glLoadIdentity; |
|
|
1049 | glOrtho 0, $::WIDTH, 0, $::HEIGHT, -10000, 10000; |
|
|
1050 | glMatrixMode GL_MODELVIEW; |
|
|
1051 | glLoadIdentity; |
|
|
1052 | |
|
|
1053 | glPushMatrix; |
|
|
1054 | glTranslate $::WIDTH * 0.5, $::HEIGHT * 0.5; |
|
|
1055 | glRotate $NOW * 1000 % 36000 / 20, 0, 1, 0; |
|
|
1056 | glScale 50, 50, 50; |
|
|
1057 | |
|
|
1058 | glInterleavedArrays GL_T2F_N3F_V3F, 0, $r->{v}; |
|
|
1059 | while (my ($k, $v) = each %{$r->{g}}) { |
|
|
1060 | glBindTexture GL_TEXTURE_2D, ($demo{t}{$k}{name} or die); |
|
|
1061 | glDrawElements GL_TRIANGLES, $v->[0], GL_UNSIGNED_SHORT, $v->[1]; |
|
|
1062 | } |
|
|
1063 | glPopMatrix; |
|
|
1064 | |
|
|
1065 | glShadeModel GL_FLAT; |
|
|
1066 | glDisable GL_DEPTH_TEST; |
|
|
1067 | glDisable GL_TEXTURE_2D; |
|
|
1068 | glDepthMask 0; |
|
|
1069 | |
|
|
1070 | $WANT_REFRESH++; |
|
|
1071 | }; |
|
|
1072 | |
1021 | CFClient::SDL_GL_SwapBuffers; |
1073 | CFClient::SDL_GL_SwapBuffers; |
1022 | |
1074 | |
1023 | $WANT_REFRESH = 0; |
1075 | $WANT_REFRESH = 0; |
1024 | $CAN_REFRESH = 0; |
1076 | $CAN_REFRESH = 0; |
1025 | $LAST_REFRESH = $NOW; |
1077 | $LAST_REFRESH = $NOW; |