-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
168 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include "Camera.h" | ||
|
||
using namespace Engine; | ||
|
||
Camera::Camera() { | ||
glGenBuffers(1, &this->cameraBuffer); | ||
} | ||
|
||
Camera::~Camera() { | ||
glBindBuffer(GL_UNIFORM_BUFFER, this->cameraBuffer); | ||
glDeleteBuffers(1, &this->cameraBuffer); | ||
} | ||
|
||
void Camera::setCamera(glm::vec3 cameraPos, glm::vec3 lookAt) { | ||
if (!this->cameraBuffer) { | ||
return; | ||
} | ||
|
||
float realMatrix[] = {cameraPos.x, cameraPos.y, cameraPos.z, 0.0f, | ||
lookAt.x, lookAt.y, lookAt.z, 0.0f}; | ||
|
||
glBindBuffer(GL_UNIFORM_BUFFER, this->cameraBuffer); | ||
glBufferData(GL_UNIFORM_BUFFER, sizeof(float) * 8, realMatrix, GL_DYNAMIC_DRAW); | ||
glBindBuffer(GL_UNIFORM_BUFFER, 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <GL/glew.h> | ||
|
||
#include <glm/glm.hpp> | ||
|
||
namespace Engine { | ||
|
||
class Camera { | ||
private: | ||
GLuint cameraBuffer; | ||
public: | ||
Camera(); | ||
~Camera(); | ||
|
||
void setCamera(glm::vec3 cameraPos, glm::vec3 lookAt); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "MainShader.h" | ||
|
||
#include <memory> | ||
#include "../engine/shader/Shader.h" | ||
#include "../engine/shader/ShaderLoader.h" | ||
|
||
using namespace Game::Shader; | ||
|
||
MainShader::MainShader() { | ||
Engine::ShaderLoader loadMainFragment(GL_FRAGMENT_SHADER, "shader/main.frag"); | ||
Engine::Shader mainFragment(loadMainFragment); | ||
this->shaders.push_back(std::make_shared<Engine::Shader>(mainFragment)); | ||
|
||
Engine::ShaderLoader loadMainVertex(GL_VERTEX_SHADER, "shader/main.vert"); | ||
Engine::Shader mainVertex(loadMainVertex); | ||
this->shaders.push_back(std::make_shared<Engine::Shader>(mainVertex)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "../engine/shader/ShaderProgram.h" | ||
|
||
#include <GL/glew.h> | ||
|
||
namespace Game { | ||
namespace Shader { | ||
class MainShader : public Engine::ShaderProgram { | ||
|
||
public: | ||
GLint positionLocation = getUniformLocation("position"); | ||
|
||
MainShader(); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters