0

I have an issue with the OpenGL two screen mode, meaning while I launch the program I have a black screen, which is used for errors end outpost text, with my OpenGL graphics. Is there any way to cancel this black screen when I'm running the program and show only the graphics?

my display class:

#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);
}

the two screens

joe_chip
  • 2,468
  • 1
  • 12
  • 23

1 Answers1

1

You need to change SubSystem in Properties > Linker > System to Windows, as shown in this image (source).

When you do this, you'll have to change your main function to WinMain function as described here.

joe_chip
  • 2,468
  • 1
  • 12
  • 23
  • 2
    There's no need to change `main` to `WinMain`. You can configure to `Windows` subsystem *and* select `mainCRTstartup` as entry function (instead of the default `winmainCRTstartup`). See https://stackoverflow.com/a/6882500/524368 – datenwolf Jun 03 '18 at 10:06