Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question