diff --git a/ps3/menu.c b/ps3/menu.c index 75dddeecd2..f258fcd975 100644 --- a/ps3/menu.c +++ b/ps3/menu.c @@ -901,11 +901,23 @@ static void select_directory(uint32_t menu_id) old_state = state; } - - - -static void apply_scaling(void) +static void apply_scaling (unsigned init_mode) { + switch(init_mode) + { + case FBO_DEINIT: + gl_deinit_fbo(g_gl); + break; + case FBO_INIT: + gl_init_fbo(g_gl, SSNES_SCALE_BASE * (unsigned)(g_settings.video.fbo_scale_x), + SSNES_SCALE_BASE * (unsigned)(g_settings.video.fbo_scale_y)); + break; + case FBO_REINIT: + gl_deinit_fbo(g_gl); + gl_init_fbo(g_gl, SSNES_SCALE_BASE * (unsigned)(g_settings.video.fbo_scale_x), + SSNES_SCALE_BASE * (unsigned)(g_settings.video.fbo_scale_y)); + break; + } } static void producesettingentry(menu * menu_obj, uint64_t switchvalue) @@ -1076,47 +1088,59 @@ static void producesettingentry(menu * menu_obj, uint64_t switchvalue) { g_settings.video.render_to_texture = !g_settings.video.render_to_texture; - #if 0 if(g_settings.video.render_to_texture) - ps3graphics_set_fbo_scale(1, Settings.ScaleFactor); + apply_scaling(FBO_INIT); else - ps3graphics_set_fbo_scale(0, 0); - #endif + { + set_text_message("", 7); + apply_scaling(FBO_DEINIT); + } set_text_message("", 7); + } if(CTRL_START(state)) { - g_settings.video.render_to_texture = 2; - //ps3graphics_set_fbo_scale(1, Settings.ScaleFactor); + g_settings.video.render_to_texture = true; + g_settings.video.fbo_scale_x = 2.0f; + g_settings.video.fbo_scale_y = 2.0f; + apply_scaling(FBO_DEINIT); + apply_scaling(FBO_INIT); } break; case SETTING_SCALE_FACTOR: if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state)) { - if((g_settings.video.fbo_scale_x > 1.0f)) + if(g_settings.video.render_to_texture) { - g_settings.video.fbo_scale_x -= 1.0f; - g_settings.video.fbo_scale_y -= 1.0f; - apply_scaling(); + if((g_settings.video.fbo_scale_x > MIN_SCALING_FACTOR)) + { + g_settings.video.fbo_scale_x -= 1.0f; + g_settings.video.fbo_scale_y -= 1.0f; + apply_scaling(FBO_REINIT); + } + set_text_message("", 7); } - set_text_message("", 7); } if(CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) { - if((g_settings.video.fbo_scale_x < 5.0f)) + if(g_settings.video.render_to_texture) { - g_settings.video.fbo_scale_x += 1.0f; - g_settings.video.fbo_scale_y += 1.0f; - apply_scaling(); + if((g_settings.video.fbo_scale_x < MAX_SCALING_FACTOR)) + { + g_settings.video.fbo_scale_x += 1.0f; + g_settings.video.fbo_scale_y += 1.0f; + apply_scaling(FBO_REINIT); + } + set_text_message("", 7); } - set_text_message("", 7); } if(CTRL_START(state)) { g_settings.video.fbo_scale_x = 2.0f; g_settings.video.fbo_scale_y = 2.0f; - apply_scaling(); + apply_scaling(FBO_DEINIT); + apply_scaling(FBO_INIT); } break; case SETTING_HW_OVERSCAN_AMOUNT: @@ -1767,6 +1791,40 @@ static void ingame_menu(uint32_t menu_id) ps3graphics_set_orientation(g_console.screen_orientation); } strcpy(comment, "Press LEFT or RIGHT to change the [Orientation] settings.\nPress START to reset back to default values."); + case MENU_ITEM_SCALE_FACTOR: + if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state)) + { + if(g_settings.video.render_to_texture) + { + if((g_settings.video.fbo_scale_x > MIN_SCALING_FACTOR)) + { + g_settings.video.fbo_scale_x -= 1.0f; + g_settings.video.fbo_scale_y -= 1.0f; + apply_scaling(FBO_REINIT); + } + set_text_message("", 7); + } + } + if(CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state) || CTRL_CROSS(state)) + { + if(g_settings.video.render_to_texture) + { + if((g_settings.video.fbo_scale_x < MAX_SCALING_FACTOR)) + { + g_settings.video.fbo_scale_x += 1.0f; + g_settings.video.fbo_scale_y += 1.0f; + apply_scaling(FBO_REINIT); + } + set_text_message("", 7); + } + } + if(CTRL_START(state)) + { + g_settings.video.fbo_scale_x = 2.0f; + g_settings.video.fbo_scale_y = 2.0f; + apply_scaling(FBO_REINIT); + } + strcpy(comment, "Press LEFT or RIGHT to change the [Scaling] settings.\nPress START to reset back to default values."); break; case MENU_ITEM_FRAME_ADVANCE: if(CTRL_CROSS(state) || CTRL_R2(state) || CTRL_L2(state)) @@ -1908,6 +1966,9 @@ static void ingame_menu(uint32_t menu_id) cellDbgFontPrintf (x_position, (ypos+(ypos_increment*MENU_ITEM_ORIENTATION)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_ORIENTATION), "Orientation: %s", msg_temp); cellDbgFontDraw(); + cellDbgFontPrintf (x_position, (ypos+(ypos_increment*MENU_ITEM_SCALE_FACTOR)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_SCALE_FACTOR), "Scale Factor: %d", (int)(g_settings.video.fbo_scale_x)); + cellDbgFontDraw(); + cellDbgFontPrintf(x_position, (ypos+(ypos_increment*MENU_ITEM_RESIZE_MODE)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_RESIZE_MODE), "Resize Mode"); cellDbgFontPuts(x_position, (ypos+(ypos_increment*MENU_ITEM_FRAME_ADVANCE)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_FRAME_ADVANCE), "Frame Advance"); diff --git a/ps3/ps3_video_psgl.c b/ps3/ps3_video_psgl.c index bf3135fa57..893c5035d6 100644 --- a/ps3/ps3_video_psgl.c +++ b/ps3/ps3_video_psgl.c @@ -196,7 +196,7 @@ static void gl_create_fbo_textures(gl_t *gl) glBindTexture(GL_TEXTURE_2D, 0); } -static void gl_deinit_fbo(gl_t *gl) +void gl_deinit_fbo(gl_t *gl) { if (gl->fbo_inited) { @@ -211,7 +211,7 @@ static void gl_deinit_fbo(gl_t *gl) } // Horribly long and complex FBO init :D -static void gl_init_fbo(gl_t *gl, unsigned width, unsigned height) +void gl_init_fbo(gl_t *gl, unsigned width, unsigned height) { if (!g_settings.video.render_to_texture && gl_shader_num() == 0) return; diff --git a/ps3/ps3_video_psgl.h b/ps3/ps3_video_psgl.h index 7314c68dfb..a43541e4a6 100644 --- a/ps3/ps3_video_psgl.h +++ b/ps3/ps3_video_psgl.h @@ -25,11 +25,22 @@ #include "menu-port-defines.h" #include +#define FBO_DEINIT 0 +#define FBO_INIT 1 +#define FBO_REINIT 2 + #define MAX_SHADERS 16 #define TEXTURES 8 #define TEXTURES_MASK (TEXTURES - 1) +#define MIN_SCALING_FACTOR (1.0f) +#define MAX_SCALING_FACTOR (4.0f) + +#define IS_TIMER_NOT_EXPIRED() (g_frame_count < g_console.timer_expiration_frame_count) +#define IS_TIMER_EXPIRED() (!(IS_TIMER_NOT_EXPIRED())) +#define SET_TIMER_EXPIRATION(value) g_console.timer_expiration_frame_count = g_frame_count + value; + enum { ASPECT_RATIO_4_3, @@ -89,14 +100,13 @@ typedef struct gl void *empty_buf; } gl_t; -#define IS_TIMER_NOT_EXPIRED() (g_frame_count < g_console.timer_expiration_frame_count) -#define IS_TIMER_EXPIRED() (!(IS_TIMER_NOT_EXPIRED())) -#define SET_TIMER_EXPIRATION(value) g_console.timer_expiration_frame_count = g_frame_count + value; bool ps3_setup_texture(void); const char * ps3_get_resolution_label(uint32_t resolution); int ps3_check_resolution(uint32_t resolution_id); void gl_frame_menu(void); +void gl_deinit_fbo(gl_t * gl); +void gl_init_fbo(gl_t * gl, unsigned width, unsigned height); void ps3_previous_resolution (void); void ps3_next_resolution (void); void ps3_set_filtering(unsigned index, bool set_smooth); diff --git a/ps3/shared.h b/ps3/shared.h index c646b91c92..74a4b32f4b 100644 --- a/ps3/shared.h +++ b/ps3/shared.h @@ -42,6 +42,7 @@ enum { MENU_ITEM_KEEP_ASPECT_RATIO, MENU_ITEM_OVERSCAN_AMOUNT, MENU_ITEM_ORIENTATION, + MENU_ITEM_SCALE_FACTOR, MENU_ITEM_RESIZE_MODE, MENU_ITEM_FRAME_ADVANCE, MENU_ITEM_SCREENSHOT_MODE,