From 4afd0522a47d9d4dfd211ab7afa10a80fea9c86f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C5=A0toura=C4=8D?= <525032@mail.muni.cz> Date: Thu, 9 Mar 2023 22:56:09 +0100 Subject: [PATCH] include order --- data/shaders/basicshader.frag | 2 +- src/gfx/CMakeLists.txt | 2 +- src/gfx/include/gfx/render.hpp | 9 +++++---- src/gfx/include/gfx/shader.h | 8 +++----- src/gfx/src/render.cpp | 7 ++++--- src/gfx/src/shader.cpp | 10 +++++++--- src/studio/include/studio/simulator.hpp | 5 +++-- src/studio/src/simulator.cpp | 5 +++-- 8 files changed, 27 insertions(+), 21 deletions(-) diff --git a/data/shaders/basicshader.frag b/data/shaders/basicshader.frag index 7ad9253..75c6387 100644 --- a/data/shaders/basicshader.frag +++ b/data/shaders/basicshader.frag @@ -1,5 +1,5 @@ #version 330 core -layout(location = 3) out vec4 FragColor; +layout(location = 0) out vec4 FragColor; void main() { FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f); diff --git a/src/gfx/CMakeLists.txt b/src/gfx/CMakeLists.txt index c5db99f..3579816 100644 --- a/src/gfx/CMakeLists.txt +++ b/src/gfx/CMakeLists.txt @@ -3,10 +3,10 @@ set(THIS_TARGET_NAME gfx) add_library(${THIS_TARGET_NAME} #./include/gfx/file.hpp ./include/gfx/shader.h + ./src/shader.cpp ./include/gfx/render.hpp ./src/render.cpp - ./src/shader.cpp # ./include/osi/opengl.hpp # ./include/osi/gui.hpp diff --git a/src/gfx/include/gfx/render.hpp b/src/gfx/include/gfx/render.hpp index 311b8cc..d87a7a4 100644 --- a/src/gfx/include/gfx/render.hpp +++ b/src/gfx/include/gfx/render.hpp @@ -1,12 +1,13 @@ -#ifndef TEMP_FILE_INCLUDED -#define TEMP_FILE_INCLUDED +#ifndef RENDER_INCLUDED +#define RENDER_INCLUDED #include <studio/simulator.hpp> #include <osi/opengl.hpp> #include <osi/gui.hpp> -#include <gfx/render.hpp> -#include <gfx/shader.h> + #include <glad/glad.h> +#include <gfx/shader.h> +#include <gfx/render.hpp> #include <iostream> Shader create_shader_program(); diff --git a/src/gfx/include/gfx/shader.h b/src/gfx/include/gfx/shader.h index a1ce86d..998663e 100644 --- a/src/gfx/include/gfx/shader.h +++ b/src/gfx/include/gfx/shader.h @@ -1,11 +1,9 @@ -#ifndef SHADER -#define SHADER +#ifndef SHADER_INCLUDED +#define SHADER_INCLUDED +#include <glad/glad.h> #include <string> -#include <fstream> -#include <sstream> #include <iostream> -#include <glad/glad.h> class Shader { diff --git a/src/gfx/src/render.cpp b/src/gfx/src/render.cpp index 1aa99da..50bf7d7 100644 --- a/src/gfx/src/render.cpp +++ b/src/gfx/src/render.cpp @@ -1,9 +1,10 @@ #include <studio/simulator.hpp> #include <osi/opengl.hpp> #include <osi/gui.hpp> -#include <gfx/render.hpp> -#include <gfx/shader.h> + #include <glad/glad.h> +#include <gfx/render.hpp> // Order important for compile +#include <gfx/shader.h> #include <iostream> Shader create_shader_program() @@ -20,7 +21,7 @@ bool create_buffer(unsigned int &VAO, unsigned int &VBO, unsigned int &EBO) /** VERTEX INPUT **/ //TRIANGLE - float vertices_triangle[] = { + float vertices_traingle[] = { -0.5f, -0.5f, 0.0f, // left 0.5f, -0.5f, 0.0f, // right 0.0f, 0.5f, 0.0f // top diff --git a/src/gfx/src/shader.cpp b/src/gfx/src/shader.cpp index f1e352a..5a27fe3 100644 --- a/src/gfx/src/shader.cpp +++ b/src/gfx/src/shader.cpp @@ -1,5 +1,12 @@ #include <gfx/shader.h> +#include <glad/glad.h> +#include <string> +#include <fstream> +#include <sstream> +#include <iostream> + + //constructor Shader::Shader(const char* vertexPath, const char* fragmentPath) { @@ -34,11 +41,8 @@ Shader::Shader(const char* vertexPath, const char* fragmentPath) const char* vShaderCode = vertexCode.c_str(); const char* fShaderCode = fragmentCode.c_str(); - // 2. compile shaders unsigned int vertex, fragment; - int success; - char infoLog[512]; // vertex Shader vertex = glCreateShader(GL_VERTEX_SHADER); diff --git a/src/studio/include/studio/simulator.hpp b/src/studio/include/studio/simulator.hpp index f4c733a..9b98c9c 100644 --- a/src/studio/include/studio/simulator.hpp +++ b/src/studio/include/studio/simulator.hpp @@ -6,9 +6,10 @@ #include <osi/opengl.hpp> #include <osi/gui.hpp> -#include <gfx/render.hpp> -#include <gfx/shader.h> + #include <glad/glad.h> +#include <gfx/shader.h> +#include <gfx/render.hpp> #include <iostream> namespace studio { diff --git a/src/studio/src/simulator.cpp b/src/studio/src/simulator.cpp index 1ff89eb..7ca58eb 100644 --- a/src/studio/src/simulator.cpp +++ b/src/studio/src/simulator.cpp @@ -1,9 +1,10 @@ #include <studio/simulator.hpp> #include <osi/opengl.hpp> #include <osi/gui.hpp> -#include <gfx/render.hpp> -#include <gfx/shader.h> + #include <glad/glad.h> +#include <gfx/shader.h> +#include <gfx/render.hpp> #include <iostream> namespace studio { -- GitLab