c++ - glMatrixMode(GL_MODELVIEW) use giving segmentation fault -
i trying implement camera fps project , having trouble when using camera class on main.cpp when calling glmatrixmode(gl_modelview)
.
here relevant functions:
void camera::init() { m_yaw = 0.0; m_pitch = 0.0; set_pos(0,0,0); } void camera::set_pos(float x, float y, float z) { m_x = x; m_y = y; m_z = z; refresh(); } void camera::refresh() { m_lx = cos(m_yaw) * cos(m_pitch); m_ly = sin(m_pitch); m_lz = sin(m_yaw) * cos(m_pitch); m_strafe_lx = cos(m_yaw - m_pi_2); m_strafe_lz = sin(m_yaw - m_pi_2); glmatrixmode(gl_modelview); glloadidentity(); printf("the segmentation fault above!\n"); glulookat(m_x, m_y, m_z, m_x + m_lx, m_y + m_ly, m_z + m_lz, 0.0, 1.0, 0.0); //printf("camera: %f %f %f direction vector: %f %f %f\n", m_x, m_y, m_z, m_lx, m_ly, m_lz); }
in case if include glew.h, need initialize beforehand, otherwise gl api calls replaced null function pointers , causes segfaults.
Comments
Post a Comment