first commit

This commit is contained in:
Joseph Roy 2024-04-15 23:26:53 +01:00
commit a8b366277a
4 changed files with 134 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
bin/

48
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,48 @@
{
"makefile.launchConfigurations": [
{
"cwd": "/home/joseph/Source/OpenGL",
"binaryPath": "/home/joseph/Source/OpenGL/OpenGLTest",
"binaryArgs": []
},
{
"cwd": "/home/joseph/Source/OpenGL",
"binaryPath": "/home/joseph/Source/OpenGL/OpenGLTest.out",
"binaryArgs": []
}
],
"files.associations": {
"bit": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"exception": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp"
},
"editor.insertSpaces": false
}

19
Makefile Normal file
View File

@ -0,0 +1,19 @@
CXX = g++
CFLAGS = -std=c++17
LDFLAGS = -lglfw -lGLEW -lGL
TARGET = bin/OpenGLTest
$(TARGET): main.cpp | bin
$(CXX) $(CFLAGS) -o $@ $^ $(LDFLAGS)
.PHONY: test clean
test: $(TARGET)
./$(TARGET)
clean:
rm -f $(TARGET)
bin:
mkdir -p bin

66
main.cpp Normal file
View File

@ -0,0 +1,66 @@
#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);
}