-
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
11 changed files
with
134 additions
and
17 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
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,29 @@ | ||
#include "indexbuffer.h" | ||
|
||
using namespace sparky; | ||
using namespace graphics; | ||
|
||
namespace sparky { | ||
namespace graphics { | ||
|
||
IndexBuffer::IndexBuffer(GLushort* data, GLsizei count) | ||
: m_Count(count) | ||
{ | ||
glGenBuffers(1, &m_BufferID); | ||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_BufferID); | ||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, count * sizeof(GLushort), data, GL_STATIC_DRAW); | ||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); | ||
|
||
} | ||
|
||
void IndexBuffer::bind() const | ||
{ | ||
glBindBuffer(GL_ARRAY_BUFFER, m_BufferID); | ||
} | ||
void IndexBuffer::unbind() const | ||
{ | ||
glBindBuffer(GL_ELEMENT_ARRAY_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,24 @@ | ||
#pragma once | ||
|
||
#include<GL/glew.h> | ||
|
||
namespace sparky { | ||
namespace graphics { | ||
|
||
class IndexBuffer { | ||
|
||
private: | ||
GLuint m_BufferID; | ||
GLuint m_Count; | ||
|
||
public: | ||
IndexBuffer(GLushort* data, GLsizei count); | ||
void bind() const; | ||
void unbind() const; | ||
|
||
inline GLuint getCount() const { return m_Count; } | ||
|
||
|
||
}; | ||
} | ||
} |
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,32 @@ | ||
#include "vertexarray.h" | ||
|
||
namespace sparky { | ||
namespace graphics { | ||
VertexArray::VertexArray() | ||
{ | ||
glGenVertexArrays(1, &m_ArrayID); | ||
} | ||
VertexArray::~VertexArray() | ||
{ | ||
for (int i = 0; i < m_Buffers.size(); i++) | ||
delete m_Buffers[i]; | ||
} | ||
void VertexArray::addBuffer(Buffer* buffer, GLuint index) | ||
{ | ||
bind(); | ||
buffer->bind(); | ||
glEnableVertexAttribArray(index); | ||
glVertexAttribPointer(index, buffer->getComponentCount(), GL_FLOAT, GL_FALSE, 0, 0); | ||
buffer->unbind(); | ||
unbind(); | ||
} | ||
void VertexArray::bind() const | ||
{ | ||
glBindVertexArray(m_ArrayID); | ||
} | ||
void VertexArray::unbind() const | ||
{ | ||
glBindVertexArray(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,20 @@ | ||
#pragma once | ||
#include <GL/glew.h> | ||
#include <vector> | ||
#include "buffer.h" | ||
|
||
namespace sparky{ | ||
namespace graphics { | ||
class VertexArray { | ||
private: | ||
GLuint m_ArrayID; | ||
std::vector<Buffer*> m_Buffers; | ||
public: | ||
VertexArray(); | ||
~VertexArray(); | ||
void addBuffer(Buffer* buffer, GLuint index); | ||
void bind() const; | ||
void unbind() const; | ||
}; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,15 +1,10 @@ | ||
#version 330 core | ||
|
||
layout (location = 0) in vec4 position; | ||
uniform mat4 pr_matrix; | ||
uniform mat4 vw_matrix = mat4(1.0); | ||
uniform mat4 ml_matrix = mat4(1.0); | ||
layout(location = 0) in vec3 position; | ||
|
||
out vec2 lightPos; | ||
out vec4 pos; | ||
uniform mat4 pr_matrix; | ||
uniform mat4 ml_matrix; | ||
|
||
void main() | ||
{ | ||
gl_Position = pr_matrix * vw_matrix * ml_matrix * position; | ||
pos = position; | ||
void main() { | ||
gl_Position = pr_matrix * ml_matrix * vec4(position, 1.0); | ||
} |