mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:27:45 +00:00
3DFileViewer: Add checkbox to disable texture
This commit is contained in:
parent
5788a139d8
commit
a4603fbc06
1 changed files with 16 additions and 3 deletions
|
@ -46,6 +46,7 @@ public:
|
||||||
void set_wrap_s_mode(GLint mode) { m_wrap_s_mode = mode; }
|
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_wrap_t_mode(GLint mode) { m_wrap_t_mode = mode; }
|
||||||
void set_texture_scale(float scale) { m_texture_scale = scale; }
|
void set_texture_scale(float scale) { m_texture_scale = scale; }
|
||||||
|
void set_texture_enabled(bool texture_enabled) { m_texture_enabled = texture_enabled; }
|
||||||
void set_mag_filter(GLint filter) { m_mag_filter = filter; }
|
void set_mag_filter(GLint filter) { m_mag_filter = filter; }
|
||||||
|
|
||||||
void toggle_show_frame_rate()
|
void toggle_show_frame_rate()
|
||||||
|
@ -111,6 +112,7 @@ private:
|
||||||
RefPtr<GUI::Label> m_stats;
|
RefPtr<GUI::Label> m_stats;
|
||||||
GLint m_wrap_s_mode = GL_REPEAT;
|
GLint m_wrap_s_mode = GL_REPEAT;
|
||||||
GLint m_wrap_t_mode = GL_REPEAT;
|
GLint m_wrap_t_mode = GL_REPEAT;
|
||||||
|
bool m_texture_enabled { true };
|
||||||
float m_texture_scale = 1.0f;
|
float m_texture_scale = 1.0f;
|
||||||
GLint m_mag_filter = GL_NEAREST;
|
GLint m_mag_filter = GL_NEAREST;
|
||||||
float m_zoom = 1;
|
float m_zoom = 1;
|
||||||
|
@ -173,9 +175,14 @@ void GLContextWidget::timer_event(Core::TimerEvent&)
|
||||||
glRotatef(m_angle_y, 0, 1, 0);
|
glRotatef(m_angle_y, 0, 1, 0);
|
||||||
glRotatef(m_angle_z, 0, 0, 1);
|
glRotatef(m_angle_z, 0, 0, 1);
|
||||||
|
|
||||||
|
if (m_texture_enabled) {
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, m_wrap_s_mode);
|
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_WRAP_T, m_wrap_t_mode);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_mag_filter);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_mag_filter);
|
||||||
|
} else {
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
}
|
||||||
glScalef(m_zoom, m_zoom, m_zoom);
|
glScalef(m_zoom, m_zoom, m_zoom);
|
||||||
|
|
||||||
if (!m_mesh.is_null())
|
if (!m_mesh.is_null())
|
||||||
|
@ -392,6 +399,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
|
|
||||||
auto& texture_menu = window->add_menu("&Texture");
|
auto& texture_menu = window->add_menu("&Texture");
|
||||||
|
|
||||||
|
auto texture_enabled_action = GUI::Action::create_checkable("&Enable Texture", [&widget](auto& action) {
|
||||||
|
widget.set_texture_enabled(action.is_checked());
|
||||||
|
});
|
||||||
|
texture_enabled_action->set_checked(true);
|
||||||
|
texture_menu.add_action(texture_enabled_action);
|
||||||
|
|
||||||
auto& wrap_u_menu = texture_menu.add_submenu("Wrap &S");
|
auto& wrap_u_menu = texture_menu.add_submenu("Wrap &S");
|
||||||
GUI::ActionGroup wrap_s_actions;
|
GUI::ActionGroup wrap_s_actions;
|
||||||
wrap_s_actions.set_exclusive(true);
|
wrap_s_actions.set_exclusive(true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue