Copiado programa de prueba

parent 3a0fd521
Showing with 72 additions and 2 deletions
......@@ -4,5 +4,14 @@ project(pr01)
set(CMAKE_CXX_STANDARD 17)
file( GLOB MY_FILES *.cpp )
file( GLOB GLAD_FILES GLAD/src/*.c)
add_executable( ${PROJECT_NAME} ${MY_FILES} )
add_executable(
${PROJECT_NAME}
${MY_FILES}
${GLAD_FILES}
)
target_include_directories( ${PROJECT_NAME} PUBLIC GLAD/include )
target_link_libraries( ${PROJECT_NAME} GL glfw )
#include <iostream>
#include <cstdlib>
// IMPORTANTE: GLAD se ha de incluir antes que GLFW
#include <glad/glad.h>
#include <GLFW/glfw3.h>
// Helper que muestra un mensaje y cierra el programa
#define panic(message) { \
std::cout << __FILE__ << ":" << __LINE__ << " : panic!" << std::endl;\
std::cout << __FILE__ << ":" << __LINE__ << " : " << message << std::endl;\
exit(-1);\
}
int main() {
std::cout << "Hello world!" << std::endl;
std::cout << "Starting Application PAG - Prueba 01" << std::endl;
if (glfwInit() != GLFW_TRUE) {
panic("Failed to initialize GLFW");
}
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
GLFWwindow *window;
window = glfwCreateWindow(1024, 576, "PAG Introduction", nullptr, nullptr);
if (window == nullptr) {
glfwTerminate();
panic("Failed to open GLFW window");
}
glfwMakeContextCurrent(window);
if (!gladLoadGLLoader((GLADloadproc) glfwGetProcAddress)) {
glfwDestroyWindow(window);
glfwTerminate();
panic("GLAD initialization failed");
}
std::cout << glGetString(GL_RENDERER) << std::endl;
std::cout << glGetString(GL_VENDOR) << std::endl;
std::cout << glGetString(GL_VERSION) << std::endl;
std::cout << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
glClearColor(0.6, 0.6, 0.6, 1.0);
glEnable(GL_DEPTH_TEST);
while (!glfwWindowShouldClose(window)) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
}
std::cout << "Finishing application pag prueba" << std::endl;
glfwDestroyWindow(window);
glfwTerminate();
}
......@@ -6,6 +6,8 @@ die() {
PROJECT_NAME=pr01
mkdir build
cmake -B build/ .
cd build
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment