Setting up OpenGL and Create a Window

This commit is contained in:
GuilhermeWerner
2021-01-08 16:26:30 -03:00
parent c49fee1824
commit 27076c6600
5 changed files with 6451 additions and 3 deletions

View File

@ -1,7 +1,44 @@
#include <iostream>
#include <GLFW/glfw3.h>
int main()
{
std::cout << "OpenGL" << std::endl;
std::cin.get();
GLFWwindow *window;
/* Initialize the library */
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(1280, 720, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glVertex2f(-0.5f, -0.5f);
glVertex2f(0.0f, 0.5f);
glVertex2f(0.5f, -0.5f);
glEnd();
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}