| 919 | int Low_vidmem = 0; |
| 920 | |
| 921 | void SetScreenMode(int sm, bool force_res_change) { |
| 922 | static int old_sm = SM_NULL; |
| 923 | static int rend_width = 0, rend_height = 0; |
| 924 | rendering_state rs; |
| 925 | |
| 926 | if (sm == SM_CINEMATIC) { |
| 927 | // force cinematic to menu |
| 928 | sm = SM_MENU; |
| 929 | } |
| 930 | |
| 931 | if (Dedicated_server) |
| 932 | return; |
| 933 | |
| 934 | if (old_sm == sm && !force_res_change) |
| 935 | return; |
| 936 | |
| 937 | // close down any systems previously opened and that must be closed (like software->hardware, etc.) |
| 938 | // make sure renderer is initialized |
| 939 | // also set any preferred renderer states. |
| 940 | if (sm == SM_NULL) { // || (sm == SM_CINEMATIC && Renderer_type == RENDERER_OPENGL)) { |
| 941 | if (rend_initted) { |
| 942 | rend_Close(); |
| 943 | rend_initted = 0; |
| 944 | } |
| 945 | } else if (sm == SM_CINEMATIC) { // && (Renderer_type == RENDERER_OPENGL || Renderer_type == RENDERER_DIRECT3D)) { |
| 946 | if (rend_initted) { |
| 947 | rend_Close(); |
| 948 | rend_initted = 0; |
| 949 | } |
| 950 | } |
| 951 | else { |
| 952 | int scr_width, scr_height, scr_bitdepth; |
| 953 | |
| 954 | if (sm == SM_GAME) { |
| 955 | scr_width = Video_res_list[Game_video_resolution].width; |
| 956 | scr_height = Video_res_list[Game_video_resolution].height; |
| 957 | scr_bitdepth = Render_preferred_bitdepth; |
| 958 | } else { |
| 959 | scr_width = FIXED_SCREEN_WIDTH; |
| 960 | scr_height = FIXED_SCREEN_HEIGHT; |
| 961 | scr_bitdepth = 32; |
| 962 | } |
| 963 | |
| 964 | if (!rend_initted) { |
| 965 | |
| 966 | Render_preferred_state.width = scr_width; |
| 967 | Render_preferred_state.height = scr_height; |
| 968 | Render_preferred_state.bit_depth = scr_bitdepth; |
| 969 | |
| 970 | rend_initted = rend_Init(PreferredRenderer, Descent, &Render_preferred_state); |
| 971 | rend_width = rend_height = 0; |
| 972 | } else { |
| 973 | |
| 974 | // If bitdepth changed but not initting, switch bitdepth |
| 975 | if (Render_preferred_state.bit_depth != scr_bitdepth) { |
| 976 | Render_preferred_state.bit_depth = scr_bitdepth; |
| 977 | rend_SetPreferredState(&Render_preferred_state); |
| 978 | } |
no test coverage detected