#include "glad.h"
#include <GLFW/glfw3.h>
#include <array>
#include <iostream>
#include <span>
#include <utility>
{
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE);
#ifdef __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
#endif
GLFWwindow* window = glfwCreateWindow(
SCR_WIDTH,
SCR_HEIGHT,
"LearnOpenGL example in StapleGL",
nullptr,
nullptr);
if (window == nullptr) {
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
if (gladLoadGLLoader(reinterpret_cast<GLADloadproc>(glfwGetProcAddress)) == 0) {
std::cout << "Failed to initialize GLAD" << std::endl;
return -1;
}
glEnable(GL_MULTISAMPLE);
std::array<float, 12> vertices = {
0.5F, 0.5F, 0.0F,
0.5F, -0.5F, 0.0F,
-0.5F, -0.5F, 0.0F,
-0.5F, 0.5F, 0.0F
};
std::array<unsigned int, 6> indices = {
0, 1, 3,
1, 2, 3
};
VBO.set_layout(layout);
basic.bind();
while (glfwWindowShouldClose(window) == 0) {
glClearColor(0.2F, 0.3F, 0.3F, 1.0F);
glClear(GL_COLOR_BUFFER_BIT);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr);
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
return 0;
}
{
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) {
glfwSetWindowShouldClose(window, 1);
}
}
{
glViewport(0, 0, width, height);
}
void processInput(GLFWwindow *window)
void framebuffer_size_callback(GLFWwindow *window, int width, int height)
Element Buffer Object (EBO) wrapper.
Vertex Array Object (VAO) wrapper.
void bind() const
Bind the vertex array object.
void set_index_buffer(index_buffer &&ibo)
Set the index buffer object.
auto add_vertex_buffer(vertex_buffer &&vbo) -> vertex_array::iterator_t
Add a vertex buffer to the vertex array object.
Vertex Buffer Object (VBO) wrapper.
StapleGL, a C++20 wrapper for OpenGL.