Skip to content

Instantly share code, notes, and snippets.

@lccalluchi
Created May 2, 2022 18:43
Show Gist options
  • Select an option

  • Save lccalluchi/25d678093d991777537ee86700f76e3f to your computer and use it in GitHub Desktop.

Select an option

Save lccalluchi/25d678093d991777537ee86700f76e3f to your computer and use it in GitHub Desktop.
#include<iostream>
#include<glad/glad.h>
#include<GLFW/glfw3.h>
int main()
{
// Inicializar GLFW
glfwInit();
// Configuramos declarando la versión de OpenGL
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
// Declarando funciones adicionales para el core de nuestro proyecto
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// Cree una ventana GLFWwindow de 800 por 800 píxeles, nombrándolo "Laboratorio 2 - C.G"
GLFWwindow* window = glfwCreateWindow(800, 800, "Laboratorio 2 - C.G", NULL, NULL);
// Capturamos el error
if (window == NULL)
{
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return -1;
}
// Agregar una nueva ventana dentro del contexto
glfwMakeContextCurrent(window);
// Cargando GLAD para configurar OPENGL
gladLoadGL();
// Fijando los valores de la ventana
glViewport(0, 0, 800, 800);
// Color de fondo
glClearColor(0.07f, 0.13f, 0.17f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
// Ejecucion del programa mientras el programa no cierre
while (!glfwWindowShouldClose(window))
{
glfwPollEvents();
}
// Eliminar ventana
glfwDestroyWindow(window);
// Terminar el prorgama
glfwTerminate();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment