Addded missing files
This commit is contained in:
parent
862aac0454
commit
d1d56b0b80
8 changed files with 58712 additions and 0 deletions
26
src/opengl/IndexBuffer.cpp
Normal file
26
src/opengl/IndexBuffer.cpp
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#include "IndexBuffer.h"
|
||||||
|
#include "Renderer.h"
|
||||||
|
|
||||||
|
IndexBuffer::IndexBuffer(const unsigned int *data, unsigned int count) : m_Count(count)
|
||||||
|
{
|
||||||
|
//Validate the fact that GLuint opengl datatype is defined as unsigned int for the current platform architecture
|
||||||
|
ASSERT(sizeof(unsigned int) == sizeof(GLuint));
|
||||||
|
|
||||||
|
GLCall(glGenBuffers(1, &m_RendererID));
|
||||||
|
GLCall(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_RendererID));
|
||||||
|
GLCall(glBufferData(GL_ELEMENT_ARRAY_BUFFER, count * sizeof(unsigned int), data, GL_STATIC_DRAW));
|
||||||
|
}
|
||||||
|
|
||||||
|
IndexBuffer::~IndexBuffer()
|
||||||
|
{
|
||||||
|
GLCall(glDeleteBuffers(1, &m_RendererID));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IndexBuffer::Bind() const
|
||||||
|
{
|
||||||
|
GLCall(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_RendererID));
|
||||||
|
}
|
||||||
|
void IndexBuffer::Unbind() const
|
||||||
|
{
|
||||||
|
GLCall(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
||||||
|
}
|
16
src/opengl/IndexBuffer.h
Normal file
16
src/opengl/IndexBuffer.h
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class IndexBuffer
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
unsigned int m_RendererID;
|
||||||
|
unsigned int m_Count;
|
||||||
|
|
||||||
|
public:
|
||||||
|
IndexBuffer(const unsigned int *data, unsigned int count);
|
||||||
|
~IndexBuffer();
|
||||||
|
|
||||||
|
void Bind() const;
|
||||||
|
void Unbind() const;
|
||||||
|
inline unsigned int GetCount() const { return m_Count; }
|
||||||
|
};
|
26
src/opengl/Renderer.cpp
Normal file
26
src/opengl/Renderer.cpp
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#include "Renderer.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
//Discard error flags from openGL state machine
|
||||||
|
void GLClearError()
|
||||||
|
{
|
||||||
|
while (glGetError() != GL_NO_ERROR)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GLLogCall(const char *function, const char *file, int line)
|
||||||
|
{
|
||||||
|
while (GLenum error = glGetError())
|
||||||
|
{
|
||||||
|
std::cout << "[OpenGL error] ("
|
||||||
|
<< error << "): " << function << " "
|
||||||
|
<< file << ":" << line << std::endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ErrorGLCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam)
|
||||||
|
{
|
||||||
|
std::cout << "Source: " << source << "Type: " << type << "Id: " << id << "Severity: " << severity << "Length: " << length << message << std::endl;
|
||||||
|
}
|
25
src/opengl/Renderer.h
Normal file
25
src/opengl/Renderer.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
//Force the compilation process to statically link glew
|
||||||
|
#define GLEW_STATIC
|
||||||
|
|
||||||
|
#include "glew.h"
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
#include <csignal>
|
||||||
|
|
||||||
|
|
||||||
|
//This should be review to integrate with debugger
|
||||||
|
#define ASSERT(x) \
|
||||||
|
if (!(x)) \
|
||||||
|
std::raise(SIGTRAP)
|
||||||
|
|
||||||
|
#define GLCall(x) \
|
||||||
|
GLClearError(); \
|
||||||
|
x; \
|
||||||
|
ASSERT(GLLogCall(#x, __FILE__, __LINE__))
|
||||||
|
|
||||||
|
//Discard error flags from openGL state machine
|
||||||
|
void GLClearError();
|
||||||
|
bool GLLogCall(const char *function, const char *file, int line);
|
||||||
|
//This is just for OpenGL4.3 onwards
|
||||||
|
void ErrorGLCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam);
|
23
src/opengl/VertexBuffer.cpp
Normal file
23
src/opengl/VertexBuffer.cpp
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#include "VertexBuffer.h"
|
||||||
|
#include "Renderer.h"
|
||||||
|
|
||||||
|
VertexBuffer::VertexBuffer(const void *data, unsigned int size)
|
||||||
|
{
|
||||||
|
GLCall(glGenBuffers(1, &m_RendererID));
|
||||||
|
GLCall(glBindBuffer(GL_ARRAY_BUFFER, m_RendererID));
|
||||||
|
GLCall(glBufferData(GL_ARRAY_BUFFER, size, data, GL_STATIC_DRAW));
|
||||||
|
}
|
||||||
|
|
||||||
|
VertexBuffer::~VertexBuffer()
|
||||||
|
{
|
||||||
|
GLCall(glDeleteBuffers(1,&m_RendererID));
|
||||||
|
}
|
||||||
|
|
||||||
|
void VertexBuffer::Bind() const
|
||||||
|
{
|
||||||
|
GLCall(glBindBuffer(GL_ARRAY_BUFFER,m_RendererID));
|
||||||
|
}
|
||||||
|
void VertexBuffer::Unbind() const
|
||||||
|
{
|
||||||
|
GLCall(glBindBuffer(GL_ARRAY_BUFFER,0));
|
||||||
|
}
|
15
src/opengl/VertexBuffer.h
Normal file
15
src/opengl/VertexBuffer.h
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class VertexBuffer
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
unsigned int m_RendererID;
|
||||||
|
|
||||||
|
public:
|
||||||
|
VertexBuffer(const void* data, unsigned int size);
|
||||||
|
~VertexBuffer();
|
||||||
|
|
||||||
|
void Bind() const;
|
||||||
|
void Unbind() const;
|
||||||
|
};
|
||||||
|
|
32080
src/opengl/glew.c
Normal file
32080
src/opengl/glew.c
Normal file
File diff suppressed because it is too large
Load diff
26501
src/opengl/glew.h
Normal file
26501
src/opengl/glew.h
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue