skein/hello.cpp

73 lines
1.4 KiB
C++
Raw Normal View History

2023-07-23 16:46:30 +02:00
// To compile on Windows
2023-07-24 23:15:49 +02:00
// Install GLFW 3.3.8
// https://www.glfw.org/download.html
// On Windows:
// extract the downloaded .zip file to "C:/libs"; this is currently expected
// by our CMakeLists.txt.
2023-07-23 16:46:30 +02:00
// Install CMake
// https://cmake.org/download
// Add to PATH for all users
// from project root:
// mkdir build
// cd build
// cmake ..
// cmake --build .
2023-07-23 17:46:53 +02:00
// The last step compiles the executable - this can also be done from Visual
// Studio
2023-07-23 16:46:30 +02:00
2023-07-23 17:46:53 +02:00
// To run in VS
// Set startup project in Solution Explorer
2023-07-24 23:15:49 +02:00
// Press F5 to run
//
// To compile on Arch Linux
//
// Install dependencies
2023-07-24 23:31:58 +02:00
// sudo pacman -S glfw mesa glew
2023-07-24 23:15:49 +02:00
//
// Build
// cmake ..
// cmake --build .
2023-07-23 17:46:53 +02:00
2023-07-24 23:31:58 +02:00
#include <GL/glew.h>
2023-07-23 17:46:53 +02:00
#include <GLFW/glfw3.h>
2023-07-24 23:15:49 +02:00
#include <GL/gl.h>
2023-07-23 16:45:15 +02:00
2023-07-24 23:31:58 +02:00
#include <iostream>
2023-07-23 16:45:15 +02:00
int main()
{
2023-07-23 17:46:53 +02:00
if (!glfwInit())
return -1;
2023-07-23 18:21:44 +02:00
GLFWwindow* window = glfwCreateWindow(640, 480, "Hello GL", NULL, NULL);
2023-07-23 17:46:53 +02:00
if (!window)
{
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
2023-07-24 23:31:58 +02:00
glewExperimental = GL_TRUE;
if (glewInit() != GLEW_OK)
{
std::cerr << "Failed to initialize GLEW" << std::endl;
return -1;
}
2023-07-23 17:46:53 +02:00
while (!glfwWindowShouldClose(window))
{
2023-07-23 18:21:44 +02:00
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
2023-07-23 17:46:53 +02:00
glfwPollEvents();
}
glfwTerminate();
2023-07-23 16:45:15 +02:00
return 0;
2023-07-24 23:15:49 +02:00
}