mirror of
https://github.com/guilhermewerner/opengl
synced 2025-06-16 13:24:19 +00:00
Setting up OpenGL and Create a Window
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user