summaryrefslogtreecommitdiff
path: root/Userland/Applications/3DFileViewer
diff options
context:
space:
mode:
authorStephan Unverwerth <s.unverwerth@serenityos.org>2021-08-12 20:39:32 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-12 20:57:19 +0200
commit3c509cf2f710fa60180510e1f969b6c265fdf969 (patch)
tree15734d1151f10524bd14fff45aaf5af0811ab607 /Userland/Applications/3DFileViewer
parent00d527bc25838418ae556f3f19df93e061ae8223 (diff)
downloadserenity-3c509cf2f710fa60180510e1f969b6c265fdf969.zip
3DFileViewer: Add magnification filters to texture menu
Diffstat (limited to 'Userland/Applications/3DFileViewer')
-rw-r--r--Userland/Applications/3DFileViewer/main.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/Userland/Applications/3DFileViewer/main.cpp b/Userland/Applications/3DFileViewer/main.cpp
index ba95f1873e..13244e7e6c 100644
--- a/Userland/Applications/3DFileViewer/main.cpp
+++ b/Userland/Applications/3DFileViewer/main.cpp
@@ -42,6 +42,7 @@ public:
void set_wrap_s_mode(GLint mode) { m_wrap_s_mode = mode; }
void set_wrap_t_mode(GLint mode) { m_wrap_t_mode = mode; }
void set_texture_scale(float scale) { m_texture_scale = scale; }
+ void set_mag_filter(GLint filter) { m_mag_filter = filter; }
void toggle_show_frame_rate()
{
@@ -103,6 +104,7 @@ private:
GLint m_wrap_s_mode = GL_REPEAT;
GLint m_wrap_t_mode = GL_REPEAT;
float m_texture_scale = 1.0f;
+ GLint m_mag_filter = GL_NEAREST;
};
void GLContextWidget::paint_event(GUI::PaintEvent& event)
@@ -149,6 +151,7 @@ void GLContextWidget::timer_event(Core::TimerEvent&)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, m_wrap_s_mode);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, m_wrap_t_mode);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_mag_filter);
if (!m_mesh.is_null())
m_mesh->draw(m_texture_scale);
@@ -416,6 +419,26 @@ int main(int argc, char** argv)
texture_scale_1_action->set_checked(true);
+ auto& texture_mag_filter_menu = texture_menu.add_submenu("Mag Filter");
+ GUI::ActionGroup texture_mag_filter_actions;
+ texture_mag_filter_actions.set_exclusive(true);
+
+ auto texture_mag_filter_nearest_action = GUI::Action::create_checkable("&Nearest", [&widget](auto&) {
+ widget.set_mag_filter(GL_NEAREST);
+ });
+
+ auto texture_mag_filter_linear_action = GUI::Action::create_checkable("&Linear", [&widget](auto&) {
+ widget.set_mag_filter(GL_LINEAR);
+ });
+
+ texture_mag_filter_actions.add_action(*texture_mag_filter_nearest_action);
+ texture_mag_filter_actions.add_action(*texture_mag_filter_linear_action);
+
+ texture_mag_filter_menu.add_action(*texture_mag_filter_nearest_action);
+ texture_mag_filter_menu.add_action(*texture_mag_filter_linear_action);
+
+ texture_mag_filter_nearest_action->set_checked(true);
+
auto& help_menu = window->add_menu("&Help");
help_menu.add_action(GUI::CommonActions::make_about_action("3D File Viewer", app_icon, window));