learningGL/main.cpp

67 lines
1.6 KiB
C++
Raw Permalink Normal View History

2024-04-15 22:26:53 +00:00
#include <GLES3/gl3.h> // Include the OpenGL ES header
#include <GLFW/glfw3.h>
#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/vec4.hpp>
#include <glm/mat4x4.hpp>
#include <iostream>
void framebuffer_size_callback(GLFWwindow* window, int width, int height);
int main()
{
if (!glfwInit())
{
std::cerr << "Failed to initialize GLFW." << std::endl;
return -1;
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
#ifdef __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
#endif
GLFWwindow* window = glfwCreateWindow(800, 600, "OpenGL window", nullptr, nullptr);
if (window == NULL)
{
const char* description;
int errorCode = glfwGetError(&description);
std::cout << "Failed to create GLFW window. Error code: " << errorCode << ", Description: " << description << std::endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glViewport(0, 0, 800, 600);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glm::mat4 matrix;
glm::vec4 vec;
auto test = vec * matrix;
while (!glfwWindowShouldClose(window))
{
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glfwPollEvents();
glfwSwapBuffers(window);
}
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
glViewport(0, 0, width, height);
}