Skip to content

Commit

Permalink
Add option to enable filter for scanlines
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Jan 24, 2025
1 parent 073362f commit 6b0e216
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions platforms/shared/desktop/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ void config_read(void)
config_video.mix_frames = read_bool("Video", "MixFrames", true);
config_video.mix_frames_intensity = read_float("Video", "MixFramesIntensity", 0.60f);
config_video.scanlines = read_bool("Video", "Scanlines", true);
config_video.scanlines_filter = read_bool("Video", "ScanlinesFilter", true);
config_video.scanlines_intensity = read_float("Video", "ScanlinesIntensity", 0.10f);

config_video.sync = read_bool("Video", "Sync", true);
Expand Down Expand Up @@ -302,6 +303,7 @@ void config_write(void)
write_bool("Video", "MixFrames", config_video.mix_frames);
write_float("Video", "MixFramesIntensity", config_video.mix_frames_intensity);
write_bool("Video", "Scanlines", config_video.scanlines);
write_bool("Video", "ScanlinesFilter", config_video.scanlines_filter);
write_float("Video", "ScanlinesIntensity", config_video.scanlines_intensity);
write_bool("Video", "Sync", config_video.sync);

Expand Down
1 change: 1 addition & 0 deletions platforms/shared/desktop/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ struct config_Video
bool mix_frames = true;
float mix_frames_intensity = 0.60f;
bool scanlines = true;
bool scanlines_filter = true;
float scanlines_intensity = 0.10f;
bool sync = true;
};
Expand Down
1 change: 1 addition & 0 deletions platforms/shared/desktop/gui_menus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ static void menu_video(void)
if (ImGui::BeginMenu("Scanlines"))
{
ImGui::MenuItem("Enable Scanlines", "", &config_video.scanlines);
ImGui::MenuItem("Enable Scanlines Filter", "", &config_video.scanlines_filter);
ImGui::SliderFloat("##scanlines", &config_video.scanlines_intensity, 0.0f, 1.0f, "Intensity = %.2f");
ImGui::EndMenu();
}
Expand Down
12 changes: 10 additions & 2 deletions platforms/shared/desktop/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,16 @@ static void update_emu_texture(void)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
if (config_video.scanlines && config_video.scanlines_filter)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}
else
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
}

static void render_quad(void)
Expand Down

0 comments on commit 6b0e216

Please sign in to comment.