S
S
sanek20052021-05-17 20:00:42
C++ / C#
sanek2005, 2021-05-17 20:00:42

Why does the window immediately close?

I'm trying to program in OpenGL. got into a dead end. The window closes immediately. here is the code that at least somehow touches openGL:

void Render::RenderFrame()
{
  if (!glfwWindowShouldClose(pWindow))
  {
    isClosed = true;
    glfwTerminate();
    return;
  }

  glClearColor(1, 1, 0, 1);

  glClear(GL_COLOR_BUFFER_BIT);

  glfwSwapBuffers(pWindow);

  glfwPollEvents();
}


void Engine::Start()
{
  Logger::GetInstance().PrintMsg("engine is started");

  while (!render->WindowIsClosed()) 
  {
    render->RenderFrame();
  }
}


WindowIsClosed returns the value of the isClosed variable (default is false)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Demin, 2021-05-17
@sanek2005

if (!glfwWindowShouldClose(pWindow))
  {
    isClosed = true;
    glfwTerminate();
    return;
  }

If there was no window close event, exit glfw. Why is the window closed?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question