【问题标题】:OpenGL two screens [duplicate]OpenGL两个屏幕[重复]
【发布时间】:2018-11-12 20:52:03
【问题描述】:

我的 OpenGL 两屏模式存在问题,这意味着当我启动程序时,我的 OpenGL 图形出现黑屏,用于错误结束前哨文本。当我运行程序并只显示图形时,有什么办法可以取消这个黑屏?

我的展示类:

#include <../GL/glew.h>
#include <iostream>
#include "display.h"

bool Display::toClose()
{
    return glfwWindowShouldClose(m_window);
}

void Display::pullEvent()
{
    glfwPollEvents();
    }

    Display::Display(int width, int height, const std::string& title)
    {
        /* Initialize the library */
        if (!glfwInit())
        error =  -1;

    m_window = glfwCreateWindow(640, 480, title.c_str(), NULL, NULL);
    if(!m_window)
    {
        glfwTerminate();
        error = -1;
    }
    glfwMakeContextCurrent(m_window);

    GLenum res = glewInit();
    if(res != GLEW_OK)
   {
        std::cerr << "Glew failed to initialize!" << std::endl;
    }

    glEnable(GL_DEPTH_TEST);
}

Display::~Display()
{
    glfwDestroyWindow(m_window);
    glfwTerminate();
}

void Display::Clear(float r, float g, float b, float a)
{
    glClearColor(r, g, b, a);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}

void Display::SwapBuffers()
{
    glfwSwapBuffers(m_window);
}

【问题讨论】:

    标签: c++ visual-studio opengl graphics glfw


    【解决方案1】:

    您需要将属性>链接器>系统中的SubSystem更改为Windows,如this image(source)所示。

    执行此操作时,您必须将 main 函数更改为 WinMain 函数,如 here 所述。

    【讨论】:

    • 无需将main 更改为WinMain。您可以配置为Windows 子系统选择mainCRTstartup 作为入口函数(而不是默认的winmainCRTstartup)。见stackoverflow.com/a/6882500/524368
    猜你喜欢
    • 1970-01-01
    • 2019-05-28
    • 1970-01-01
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    • 2012-10-30
    • 2019-05-10
    • 2013-04-06
    相关资源
    最近更新 更多