1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:07:35 +00:00

LibGL+3DFileViewer: Make glRotatef accept degrees, not radians

This is in accordance with the GL spec. Also adjust rotation values in
3DFileViewer to take the new units into account.
This commit is contained in:
Stephan Unverwerth 2021-08-16 14:01:48 +02:00 committed by Andreas Kling
parent 5a8de62a1a
commit b6373c2aba
2 changed files with 7 additions and 7 deletions

View file

@ -97,7 +97,7 @@ private:
float m_angle_y = 0.0; float m_angle_y = 0.0;
float m_angle_z = 0.0; float m_angle_z = 0.0;
Gfx::IntPoint m_last_mouse; Gfx::IntPoint m_last_mouse;
float m_rotation_speed = 1.f; float m_rotation_speed = 60.f;
bool m_show_frame_rate = false; bool m_show_frame_rate = false;
int m_cycles = 0; int m_cycles = 0;
int m_accumulated_time = 0; int m_accumulated_time = 0;
@ -124,8 +124,8 @@ void GLContextWidget::mousemove_event(GUI::MouseEvent& event)
int delta_x = m_last_mouse.x() - event.x(); int delta_x = m_last_mouse.x() - event.x();
int delta_y = m_last_mouse.y() - event.y(); int delta_y = m_last_mouse.y() - event.y();
m_angle_x -= delta_y / 100.0f; m_angle_x -= delta_y / 2.0f;
m_angle_y -= delta_x / 100.0f; m_angle_y -= delta_x / 2.0f;
} }
m_last_mouse = event.position(); m_last_mouse = event.position();
@ -315,13 +315,13 @@ int main(int argc, char** argv)
widget.set_rotation_speed(0.f); widget.set_rotation_speed(0.f);
}); });
auto slow_rotation_action = GUI::Action::create_checkable("&Slow", [&widget](auto&) { auto slow_rotation_action = GUI::Action::create_checkable("&Slow", [&widget](auto&) {
widget.set_rotation_speed(0.5f); widget.set_rotation_speed(30.f);
}); });
auto normal_rotation_action = GUI::Action::create_checkable("&Normal", [&widget](auto&) { auto normal_rotation_action = GUI::Action::create_checkable("&Normal", [&widget](auto&) {
widget.set_rotation_speed(1.f); widget.set_rotation_speed(60.f);
}); });
auto fast_rotation_action = GUI::Action::create_checkable("&Fast", [&widget](auto&) { auto fast_rotation_action = GUI::Action::create_checkable("&Fast", [&widget](auto&) {
widget.set_rotation_speed(1.5f); widget.set_rotation_speed(90.f);
}); });
rotation_speed_actions.add_action(*no_rotation_action); rotation_speed_actions.add_action(*no_rotation_action);

View file

@ -504,7 +504,7 @@ void SoftwareGLContext::gl_rotate(GLdouble angle, GLdouble x, GLdouble y, GLdoub
FloatVector3 axis = { (float)x, (float)y, (float)z }; FloatVector3 axis = { (float)x, (float)y, (float)z };
axis.normalize(); axis.normalize();
auto rotation_mat = Gfx::rotation_matrix(axis, static_cast<float>(angle)); auto rotation_mat = Gfx::rotation_matrix(axis, static_cast<float>(angle * M_PI * 2 / 360));
if (m_current_matrix_mode == GL_MODELVIEW) if (m_current_matrix_mode == GL_MODELVIEW)
m_model_view_matrix = m_model_view_matrix * rotation_mat; m_model_view_matrix = m_model_view_matrix * rotation_mat;