我正在学习Linux上的OpenGL,但我不能让模式切换工作(窗口全屏和后退).
窗口似乎进入全屏但看起来不正确.要切换模式,正在创建一个新窗口,旧窗口将被销毁.
void OpenGLWindow::FullScreen(bool fullScreen, int width, int height)
{
GLFWwindow *oldHandle = m_window;
m_fullscreen = fullScreen;
m_width = width;
m_height = height;
m_window = glfwCreateWindow(width, height, m_caption.c_str(),
fullScreen ? m_monitor : NULL, m_window);
if (m_window == NULL)
{
glfwTerminate();
throw std::runtime_error("Failed to recreate window.");
}
glfwDestroyWindow(oldHandle);
m_camera->Invalidate();
// Use entire window for rendering.
glViewport(0, 0, width, height);
glfwMakeContextCurrent(m_window);
glfwSwapInterval(1);
if (m_keyboardHandler) SetKeyboardHandler(m_keyboardHandler);
}
Run Code Online (Sandbox Code Playgroud)
更新问题
我已更新代码以使用您的代码并获得相同的问题.在你的建议我现在更新相机,但再次无济于事:(
void OpenGLCamera::Invalidate()
{
RecalculateProjection(m_perspProjInfo->Width(), m_perspProjInfo->Height());
m_recalculateViewMatrix = true;
m_recalculatePerspectiveMatrix = true; …Run Code Online (Sandbox Code Playgroud)