mirror of
https://github.com/guilhermewerner/opengl
synced 2025-06-15 21:04:18 +00:00
55 lines
1.1 KiB
C++
55 lines
1.1 KiB
C++
#include <GL/glew.h>
|
|
#include <GLFW/glfw3.h>
|
|
|
|
#include <iostream>
|
|
|
|
int main()
|
|
{
|
|
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);
|
|
|
|
if (glewInit() != GLEW_OK)
|
|
{
|
|
std::cout << "Error!" << std::endl;
|
|
}
|
|
|
|
std::cout << glGetString(GL_VERSION) << std::endl;
|
|
|
|
/* 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;
|
|
}
|