Skip to content

Commit d25f4ba

Browse files
committed
Revert commits after 14b1cda (snap output window changes)
1 parent 822f9b9 commit d25f4ba

File tree

3 files changed

+16
-111
lines changed

3 files changed

+16
-111
lines changed

platforms/shared/desktop/gui.cpp

Lines changed: 10 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,6 @@ static void main_window(void)
454454

455455
int w = (int)ImGui::GetIO().DisplaySize.x;
456456
int h = (int)ImGui::GetIO().DisplaySize.y - (application_show_menu ? gui_main_menu_height : 0);
457-
ImGuiIO& io = ImGui::GetIO();
458-
float fb_scale_x = io.DisplayFramebufferScale.x > 0.0f ? io.DisplayFramebufferScale.x : 1.0f;
459-
float fb_scale_y = io.DisplayFramebufferScale.y > 0.0f ? io.DisplayFramebufferScale.y : 1.0f;
460-
bool fractional_fb_scale = (fabsf(fb_scale_x - roundf(fb_scale_x)) > 0.001f) || (fabsf(fb_scale_y - roundf(fb_scale_y)) > 0.001f);
461457

462458
int selected_ratio = config_debug.debug ? 0 : config_video.ratio;
463459
float ratio = 0;
@@ -514,22 +510,8 @@ static void main_window(void)
514510
{
515511
case 0:
516512
{
517-
int factor_w;
518-
int factor_h;
519-
520-
if (fractional_fb_scale)
521-
{
522-
int available_w_fb = (int)floorf((float)w * fb_scale_x);
523-
int available_h_fb = (int)floorf((float)h * fb_scale_y);
524-
factor_w = available_w_fb / w_corrected;
525-
factor_h = available_h_fb / h_corrected;
526-
}
527-
else
528-
{
529-
factor_w = w / w_corrected;
530-
factor_h = h / h_corrected;
531-
}
532-
513+
int factor_w = w / w_corrected;
514+
int factor_h = h / h_corrected;
533515
scale_multiplier = (factor_w < factor_h) ? factor_w : factor_h;
534516
break;
535517
}
@@ -552,26 +534,8 @@ static void main_window(void)
552534
}
553535
}
554536

555-
float window_width = 0.0f;
556-
float window_height = 0.0f;
557-
558-
if (!config_debug.debug && fractional_fb_scale && ((config_video.scale == 0) || (config_video.scale == 1)))
559-
{
560-
int window_width_fb = w_corrected * scale_multiplier;
561-
int window_height_fb = h_corrected * scale_multiplier;
562-
window_width = (float)window_width_fb / fb_scale_x;
563-
window_height = (float)window_height_fb / fb_scale_y;
564-
}
565-
else
566-
{
567-
window_width = (float)(w_corrected * scale_multiplier);
568-
window_height = (float)(h_corrected * scale_multiplier);
569-
window_width = roundf(window_width * fb_scale_x) / fb_scale_x;
570-
window_height = roundf(window_height * fb_scale_y) / fb_scale_y;
571-
}
572-
573-
gui_main_window_width = (int)roundf(window_width);
574-
gui_main_window_height = (int)roundf(window_height);
537+
gui_main_window_width = w_corrected * scale_multiplier;
538+
gui_main_window_height = h_corrected * scale_multiplier;
575539

576540
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
577541
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
@@ -590,14 +554,11 @@ static void main_window(void)
590554
}
591555
else
592556
{
593-
float window_x = ((float)w - window_width) * 0.5f;
594-
float window_y = (((float)h - window_height) * 0.5f) + (application_show_menu ? (float)gui_main_menu_height : 0.0f);
595-
596-
window_x = roundf(window_x * fb_scale_x) / fb_scale_x;
597-
window_y = roundf(window_y * fb_scale_y) / fb_scale_y;
557+
int window_x = (w - (w_corrected * scale_multiplier)) / 2;
558+
int window_y = ((h - (h_corrected * scale_multiplier)) / 2) + (application_show_menu ? gui_main_menu_height : 0);
598559

599-
ImGui::SetNextWindowSize(ImVec2(window_width, window_height));
600-
ImGui::SetNextWindowPos(ImGui::GetMainViewport()->Pos + ImVec2(window_x, window_y));
560+
ImGui::SetNextWindowSize(ImVec2((float)gui_main_window_width, (float)gui_main_window_height));
561+
ImGui::SetNextWindowPos(ImGui::GetMainViewport()->Pos + ImVec2((float)window_x, (float)window_y));
601562
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
602563

603564
flags |= ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoBringToFrontOnFocus;
@@ -607,20 +568,9 @@ static void main_window(void)
607568
}
608569

609570
float tex_h = (float)runtime.screen_width / (float)(SYSTEM_TEXTURE_WIDTH);
610-
float tex_v = ((float)runtime.screen_height * (float)ogl_renderer_output_scale) / (float)(FRAME_BUFFER_HEIGHT);
571+
float tex_v = (float)runtime.screen_height / (float)(SYSTEM_TEXTURE_HEIGHT);
611572

612-
if (fractional_fb_scale)
613-
{
614-
float uv_x0 = 0.5f / (float)FRAME_BUFFER_WIDTH;
615-
float uv_y0 = 0.5f / (float)FRAME_BUFFER_HEIGHT;
616-
float uv_x1 = ((float)runtime.screen_width - 0.5f) / (float)FRAME_BUFFER_WIDTH;
617-
float uv_y1 = (((float)runtime.screen_height * (float)ogl_renderer_output_scale) - 0.5f) / (float)FRAME_BUFFER_HEIGHT;
618-
ImGui::Image((ImTextureID)(intptr_t)ogl_renderer_emu_texture, ImVec2(window_width, window_height), ImVec2(uv_x0, uv_y0), ImVec2(uv_x1, uv_y1));
619-
}
620-
else
621-
{
622-
ImGui::Image((ImTextureID)(intptr_t)ogl_renderer_emu_texture, ImVec2(window_width, window_height), ImVec2(0, 0), ImVec2(tex_h, tex_v));
623-
}
573+
ImGui::Image((ImTextureID)(intptr_t)ogl_renderer_emu_texture, ImVec2((float)gui_main_window_width, (float)gui_main_window_height), ImVec2(0, 0), ImVec2(tex_h, tex_v));
624574

625575
if (config_video.fps)
626576
gui_show_fps();

platforms/shared/desktop/ogl_renderer.cpp

Lines changed: 5 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@
2525
#include <glad.h>
2626
#endif
2727

28-
#include <math.h>
29-
3028
#include "imgui.h"
3129
#include "imgui_impl_opengl3.h"
3230
#include "emu.h"
3331
#include "config.h"
34-
#include "gui.h"
3532
#include "geargrafx.h"
3633

3734
#define OGL_RENDERER_IMPORT
@@ -51,7 +48,6 @@ static int quad_uniform_color = -1;
5148
static int quad_uniform_tex_scale = -1;
5249
static int quad_uniform_viewport_size = -1;
5350
static int quad_uniform_use_fragcoord = -1;
54-
static int quad_uniform_scanline_scale = -1;
5551

5652

5753

@@ -69,40 +65,6 @@ static void update_system_texture(void);
6965
static void update_debug_textures(void);
7066
static void update_savestates_texture(void);
7167
static void render_scanlines(void);
72-
static int compute_output_scale(void);
73-
74-
static int compute_output_scale(void)
75-
{
76-
int scale = FRAME_BUFFER_SCALE_DEFAULT;
77-
78-
if (!config_video.scanlines || config_debug.debug)
79-
return scale;
80-
81-
ImGuiIO& io = ImGui::GetIO();
82-
float fb_scale_x = io.DisplayFramebufferScale.x > 0.0f ? io.DisplayFramebufferScale.x : 1.0f;
83-
float fb_scale_y = io.DisplayFramebufferScale.y > 0.0f ? io.DisplayFramebufferScale.y : 1.0f;
84-
bool fractional_fb_scale = (fabsf(fb_scale_x - roundf(fb_scale_x)) > 0.001f) || (fabsf(fb_scale_y - roundf(fb_scale_y)) > 0.001f);
85-
86-
if (!fractional_fb_scale)
87-
return scale;
88-
89-
if (config_video.scale == 1)
90-
{
91-
scale = config_video.scale_manual;
92-
}
93-
else if ((config_video.scale == 0) && (current_runtime.screen_height > 0) && (gui_main_window_height > 0))
94-
{
95-
int physical_height = (int)roundf((float)gui_main_window_height * fb_scale_y);
96-
scale = physical_height / current_runtime.screen_height;
97-
}
98-
99-
if (scale < 1)
100-
scale = 1;
101-
if (scale > FRAME_BUFFER_SCALE)
102-
scale = FRAME_BUFFER_SCALE;
103-
104-
return scale;
105-
}
10668

10769
bool ogl_renderer_init(void)
10870
{
@@ -172,7 +134,6 @@ void ogl_renderer_begin_render(void)
172134
void ogl_renderer_render(void)
173135
{
174136
emu_get_runtime(current_runtime);
175-
ogl_renderer_output_scale = compute_output_scale();
176137

177138
if (config_debug.debug)
178139
{
@@ -341,7 +302,7 @@ static void render_emu_mix(void)
341302
update_system_texture();
342303

343304
int viewportWidth = current_runtime.screen_width;
344-
int viewportHeight = current_runtime.screen_height * ogl_renderer_output_scale;
305+
int viewportHeight = current_runtime.screen_height * FRAME_BUFFER_SCALE;
345306

346307
glUseProgram(quad_shader_program);
347308
glUniform2f(quad_uniform_tex_scale, tex_h, tex_v);
@@ -442,7 +403,7 @@ static void update_emu_texture(void)
442403
static void render_quad(float tex_h, float tex_v)
443404
{
444405
int viewportWidth = current_runtime.screen_width;
445-
int viewportHeight = current_runtime.screen_height * ogl_renderer_output_scale;
406+
int viewportHeight = current_runtime.screen_height * FRAME_BUFFER_SCALE;
446407

447408
glUseProgram(quad_shader_program);
448409
glUniform2f(quad_uniform_tex_scale, tex_h, tex_v);
@@ -465,7 +426,7 @@ static void render_scanlines(void)
465426
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
466427

467428
int viewportWidth = current_runtime.screen_width;
468-
int viewportHeight = current_runtime.screen_height * ogl_renderer_output_scale;
429+
int viewportHeight = current_runtime.screen_height * FRAME_BUFFER_SCALE;
469430

470431
float tex_h = (float)current_runtime.screen_width;
471432
float tex_v = (float)current_runtime.screen_height;
@@ -474,7 +435,6 @@ static void render_scanlines(void)
474435
glUniform2f(quad_uniform_tex_scale, tex_h, tex_v);
475436
glUniform2f(quad_uniform_viewport_size, (float)viewportWidth, (float)viewportHeight);
476437
glUniform1i(quad_uniform_use_fragcoord, 2);
477-
glUniform1i(quad_uniform_scanline_scale, ogl_renderer_output_scale);
478438
glUniform4f(quad_uniform_color, 1.0f, 1.0f, 1.0f, config_video.scanlines_intensity);
479439

480440
glViewport(0, 0, viewportWidth, viewportHeight);
@@ -515,11 +475,10 @@ static void init_shaders(void)
515475
"uniform vec2 uTexScale;\n"
516476
"uniform vec2 uViewportSize;\n"
517477
"uniform int uUseFragCoord;\n"
518-
"uniform int uScanlineScale;\n"
519478
"void main() {\n"
520479
" if (uUseFragCoord == 2) {\n"
521-
" float row = mod(floor(gl_FragCoord.y), float(uScanlineScale));\n"
522-
" float mask = row >= (float(uScanlineScale) * 0.5) ? 1.0 : 0.0;\n"
480+
" float row = mod(floor(gl_FragCoord.y), 4.0);\n"
481+
" float mask = row >= 2.0 ? 1.0 : 0.0;\n"
523482
" FragColor = vec4(0.0, 0.0, 0.0, uColor.a * mask);\n"
524483
" return;\n"
525484
" }\n"
@@ -579,12 +538,10 @@ static void init_shaders(void)
579538
quad_uniform_color = glGetUniformLocation(quad_shader_program, "uColor");
580539
quad_uniform_viewport_size = glGetUniformLocation(quad_shader_program, "uViewportSize");
581540
quad_uniform_use_fragcoord = glGetUniformLocation(quad_shader_program, "uUseFragCoord");
582-
quad_uniform_scanline_scale = glGetUniformLocation(quad_shader_program, "uScanlineScale");
583541

584542
glUseProgram(quad_shader_program);
585543
glUniform1i(quad_uniform_texture, 0);
586544
glUniform1i(quad_uniform_use_fragcoord, 0);
587-
glUniform1i(quad_uniform_scanline_scale, FRAME_BUFFER_SCALE_DEFAULT);
588545
glUseProgram(0);
589546

590547
float quad_vertices[] = {

platforms/shared/desktop/ogl_renderer.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
#define EXTERN extern
2929
#endif
3030

31-
#define FRAME_BUFFER_SCALE 10
32-
#define FRAME_BUFFER_SCALE_DEFAULT 4
31+
#define FRAME_BUFFER_SCALE 4
3332
#define SYSTEM_TEXTURE_WIDTH 2048
3433
#define SYSTEM_TEXTURE_HEIGHT 512
3534
#define FRAME_BUFFER_WIDTH (SYSTEM_TEXTURE_WIDTH * 1)
@@ -41,7 +40,6 @@ EXTERN uint32_t ogl_renderer_emu_debug_huc6270_sprites[2][64];
4140
EXTERN uint32_t ogl_renderer_emu_debug_huc6270_tiles[2];
4241
EXTERN uint32_t ogl_renderer_emu_savestates;
4342
EXTERN const char* ogl_renderer_opengl_version;
44-
EXTERN int ogl_renderer_output_scale;
4543

4644
EXTERN bool ogl_renderer_init(void);
4745
EXTERN void ogl_renderer_destroy(void);

0 commit comments

Comments
 (0)