C++ OpenGL两屏
我对OpenGL两屏模式有一个问题,这意味着当我启动程序时,我有一个黑屏,用于错误结束前哨站文本,带有我的OpenGL图形。当我运行程序并只显示图形时,有没有办法取消这个黑屏 我的显示类:C++ OpenGL两屏,c++,visual-studio,opengl,graphics,glfw,C++,Visual Studio,Opengl,Graphics,Glfw,我对OpenGL两屏模式有一个问题,这意味着当我启动程序时,我有一个黑屏,用于错误结束前哨站文本,带有我的OpenGL图形。当我运行程序并只显示图形时,有没有办法取消这个黑屏 我的显示类: #包括 #包括 #包括“display.h” bool Display::toClose() { 返回glfwWindowShouldClose(m_窗口); } void Display::pullervent() { glfwPollEvents(); } 显示::显示(整数宽度、整数高度、常量标准::字
#包括
#包括
#包括“display.h”
bool Display::toClose()
{
返回glfwWindowShouldClose(m_窗口);
}
void Display::pullervent()
{
glfwPollEvents();
}
显示::显示(整数宽度、整数高度、常量标准::字符串和标题)
{
/*初始化库*/
如果(!glfwInit())
误差=-1;
m_window=glfwCreateWindow(640480,title.c_str(),NULL,NULL);
如果(!m_窗口)
{
glfwTerminate();
误差=-1;
}
glfwMakeContextCurrent(m_窗口);
GLenum res=glewInit();
如果(res!=GLEW_OK)
{
std::cerr您需要将属性>链接器>系统中的子系统更改为Windows
,如()所示
执行此操作时,您必须按说明将main
函数更改为WinMain
函数。无需将main
更改为WinMain
。您可以配置为Windows
子系统,并选择mainCRTstartup
作为输入函数(而不是默认的winmainCRTstartup
)。请参阅
#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);
}