OpenGL's Hello world
This commit is contained in:
1140
src/glad.c
Normal file
1140
src/glad.c
Normal file
File diff suppressed because it is too large
Load Diff
55
src/main.cpp
Normal file
55
src/main.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <iostream>
|
||||
|
||||
void framebufferSizeCallback(GLFWwindow *window, int width, int height) {
|
||||
glViewport(10, 10, width-10, height-10);
|
||||
}
|
||||
|
||||
void processInput(GLFWwindow *window) {
|
||||
if(glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) {
|
||||
glfwSetWindowShouldClose(window, true);
|
||||
}
|
||||
}
|
||||
|
||||
void renderGraphics(GLFWwindow *window) {
|
||||
|
||||
}
|
||||
|
||||
int main () {
|
||||
glfwInit();
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
#ifdef __APPLE__
|
||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
||||
#endif
|
||||
|
||||
GLFWwindow *window = glfwCreateWindow(800, 600, "TimeCoil", NULL, NULL);
|
||||
if (window == NULL) {
|
||||
std::cerr << "Failed to create GLFW window." << std::endl;
|
||||
glfwTerminate();
|
||||
return -1;
|
||||
}
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSetFramebufferSizeCallback(window, framebufferSizeCallback);
|
||||
|
||||
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
|
||||
std::cerr << "Failed to initialize GLAD." << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
while(!glfwWindowShouldClose(window)) {
|
||||
processInput(window);
|
||||
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
glfwTerminate();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user