chore: linking glad

This commit is contained in:
Krzysztof Rudnicki 2022-08-28 19:20:00 +02:00
parent 8f60f623cd
commit f41d678331
5 changed files with 117 additions and 44 deletions

View File

@ -1,16 +1,17 @@
{
"configurations": [
{
"name": "linux-gcc-x64",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "linux-gcc-x64",
"compilerArgs": []
}
],
"version": 4
"configurations": [
{
"name": "linux-gcc-x64",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/dependencies/include"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "linux-gcc-x64",
"compilerArgs": []
}
],
"version": 4
}

50
.vscode/settings.json vendored
View File

@ -25,5 +25,53 @@
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
]
],
"files.associations": {
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp"
}
}

5
.vscode/tasks.json vendored
View File

@ -6,8 +6,11 @@
"command": "/usr/bin/g++",
"args": [
"-Wall", "${workspaceFolder}/Engine/engine/*.cpp",
"${workspaceFolder}/Engine/engine/glad.c",
"-o",
"${workspaceFolder}/Engine/engine/match", "-lglfw", "-lGLU", "-lGL", "-lm",
"${workspaceFolder}/Engine/engine/match", "-lglut", "-lglfw", "-lGLU", "-lGL", "-lm",
"-I${workspaceFolder}/dependencies/include",
],
"options": {

Binary file not shown.

View File

@ -1,38 +1,59 @@
#include <glad/glad.h>
#include <GLFW/glfw3.h>
int main(void)
#include <iostream>
void e() { std::cout << "breakpoint" << std::endl; };
void instantiateGLFWWindow()
{
GLFWwindow* window;
glfwInit(); // we initialize glfw
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
// we configure glfw ,
// first argument is what option we want to configure, // the second sets the value of the option
// see: https://www.glfw.org/docs/latest/window.html#window_hints
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// We tell glfw we want to use smaller subset of OGL features without backwards-compatible one
//glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
// We would use this one if we worked on macOs
}
/* Initialize the library */
if (!glfwInit())
{
return -1;
}
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "xD", NULL, NULL);
if (!window)
int createWindowObject()
{
GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL, NULL);
// we provide width and height of window
// then name of the window
// we ignore last 2 parameters
// function returns GLFW window object that we will use for other glfw operations
if (window == NULL)
{
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return -1;
}
/* Make the window's context current */
// context of our window becomes the main context of current thread
glfwMakeContextCurrent(window);
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClear(GL_COLOR_BUFFER_BIT);
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}
int initializeGLAD()
{
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
std::cout << "Failed to initialize GLAD" << std::endl;
return -1;
}
return 0;
}
int main()
{
if(initializeGLAD() == -1) return -1;
instantiateGLFWWindow();
if(createWindowObject() == -1) return -1;
e();
return 0;
}