create components dir
This commit is contained in:
parent
6d980ee4ec
commit
ce2a615ced
7 changed files with 44 additions and 36 deletions
|
|
@ -1,5 +1,7 @@
|
|||
project('test', 'cpp')
|
||||
|
||||
sources = []
|
||||
|
||||
deps = []
|
||||
deps += dependency('fmt')
|
||||
deps += dependency('glfw3')
|
||||
|
|
|
|||
1
src/components/meson.build
Normal file
1
src/components/meson.build
Normal file
|
|
@ -0,0 +1 @@
|
|||
sources += files('shader.cpp', 'shader.hpp')
|
||||
11
src/components/shader.cpp
Normal file
11
src/components/shader.cpp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#include "shader.hpp"
|
||||
|
||||
Shader::Shader(GLuint shader) { this->shader = shader; }
|
||||
void Shader::SetSource(std::string source) { this->SetSource(source.c_str()); }
|
||||
void Shader::SetSource(const char *source) {
|
||||
glShaderSource(shader, 1, &source, NULL);
|
||||
}
|
||||
void Shader::Compile() { glCompileShader(shader); }
|
||||
void Shader::Attach(GLuint program) { glAttachShader(program, shader); }
|
||||
VertexShader::VertexShader() : Shader(glCreateShader(GL_VERTEX_SHADER)) {}
|
||||
FragmentShader::FragmentShader() : Shader(glCreateShader(GL_FRAGMENT_SHADER)) {}
|
||||
26
src/components/shader.hpp
Normal file
26
src/components/shader.hpp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#include <GL/glew.h>
|
||||
#include <string>
|
||||
|
||||
class Shader {
|
||||
public:
|
||||
Shader(GLuint shader);
|
||||
|
||||
protected:
|
||||
GLuint shader;
|
||||
|
||||
public:
|
||||
void SetSource(std::string source);
|
||||
void SetSource(const char *source);
|
||||
void Compile();
|
||||
void Attach(GLuint program);
|
||||
};
|
||||
|
||||
class VertexShader : public Shader {
|
||||
public:
|
||||
VertexShader();
|
||||
};
|
||||
|
||||
class FragmentShader : public Shader {
|
||||
public:
|
||||
FragmentShader();
|
||||
};
|
||||
|
|
@ -1,2 +1,4 @@
|
|||
sources = files('main.cpp')
|
||||
sources += files('main.cpp')
|
||||
|
||||
subdir('components')
|
||||
subdir('systems')
|
||||
|
|
|
|||
|
|
@ -82,13 +82,3 @@ int ShaderSystem::Draw(int width, int height, float time) {
|
|||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Shader::Shader(GLuint shader) { this->shader = shader; }
|
||||
void Shader::SetSource(std::string source) { this->SetSource(source.c_str()); }
|
||||
void Shader::SetSource(const char *source) {
|
||||
glShaderSource(shader, 1, &source, NULL);
|
||||
}
|
||||
void Shader::Compile() { glCompileShader(shader); }
|
||||
void Shader::Attach(GLuint program) { glAttachShader(program, shader); }
|
||||
VertexShader::VertexShader() : Shader(glCreateShader(GL_VERTEX_SHADER)) {}
|
||||
FragmentShader::FragmentShader() : Shader(glCreateShader(GL_FRAGMENT_SHADER)) {}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <GL/glew.h>
|
||||
#include <linmath.h>
|
||||
#include <string>
|
||||
#include "../components/shader.hpp"
|
||||
|
||||
class ShaderSystem {
|
||||
GLuint vertex_buffer;
|
||||
|
|
@ -15,27 +15,3 @@ public:
|
|||
int Draw(int width, int height, float time);
|
||||
GLuint *CreateBuffer();
|
||||
};
|
||||
|
||||
class Shader {
|
||||
public:
|
||||
Shader(GLuint shader);
|
||||
|
||||
protected:
|
||||
GLuint shader;
|
||||
|
||||
public:
|
||||
void SetSource(std::string source);
|
||||
void SetSource(const char *source);
|
||||
void Compile();
|
||||
void Attach(GLuint program);
|
||||
};
|
||||
|
||||
class VertexShader : public Shader {
|
||||
public:
|
||||
VertexShader();
|
||||
};
|
||||
|
||||
class FragmentShader : public Shader {
|
||||
public:
|
||||
FragmentShader();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue