A
A
Andrey Antropov2020-06-05 22:20:58
OpenGL
Andrey Antropov, 2020-06-05 22:20:58

Why is OpenGl not working?

Just a black window

#include <iostream>
#include <GLFW/glfw3.h>
int main()
{
  try
  {
    if (!glfwInit())
    {
      throw std::exception("GLFW Init error!");
    }

    GLFWwindow* window = glfwCreateWindow(800, 600, "Engine", nullptr, nullptr);

    while (!glfwWindowShouldClose(window))
    {
      glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
      glClear(GL_COLOR_BUFFER_BIT);
      glfwSwapBuffers(window);
      glfwPollEvents();
    }

    glfwDestroyWindow(window);
    glfwTerminate();
  } catch (const std::exception& e)
  {
    std::cout << "Error: " << e.what() << std::endl;
  }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Antropov, 2020-06-05
@SanceiLaks

I decided.
I'm not tied to the flow

E
Evgeny Petryaev, 2020-06-05
@Gremlin92

Because you need to draw something in after glclear add for example

glBegin(GL_LINES);
glVertex3d(1.0,0.0,0.0);
glVertex3d(-1.0,0.0,0.0);
glEnd();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question