相关疑难解决方法(0)

在OpenGL/GLFW 3.2中切换窗口和全屏

我正在学习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)

c++ opengl glfw

5
推荐指数
2
解决办法
4276
查看次数

标签 统计

c++ ×1

glfw ×1

opengl ×1