Rewrote VertexArray to support multiple VBOs; Minor fixes and organization
This commit is contained in:
parent
f75f98d9db
commit
e17d2e283a
@ -94,7 +94,7 @@
|
|||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>NFENGINE;GLEW_STATIC;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>GLEW_STATIC;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)src\include\;$(ProjectDir)dep\include\</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)src\include\;$(ProjectDir)dep\include\</AdditionalIncludeDirectories>
|
||||||
<ObjectFileName>$(IntDir)obj\</ObjectFileName>
|
<ObjectFileName>$(IntDir)obj\</ObjectFileName>
|
||||||
@ -119,7 +119,7 @@
|
|||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>NFENGINE;GLEW_STATIC;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>GLEW_STATIC;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)src\include\;$(ProjectDir)dep\include\</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)src\include\;$(ProjectDir)dep\include\</AdditionalIncludeDirectories>
|
||||||
<ObjectFileName>$(IntDir)obj\</ObjectFileName>
|
<ObjectFileName>$(IntDir)obj\</ObjectFileName>
|
||||||
@ -144,7 +144,7 @@
|
|||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>NFENGINE;GLEW_STATIC;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>GLEW_STATIC;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)src\include\;$(ProjectDir)dep\include\</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)src\include\;$(ProjectDir)dep\include\</AdditionalIncludeDirectories>
|
||||||
<ObjectFileName>$(IntDir)obj\</ObjectFileName>
|
<ObjectFileName>$(IntDir)obj\</ObjectFileName>
|
||||||
@ -169,7 +169,7 @@
|
|||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>NFENGINE;GLEW_STATIC;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>GLEW_STATIC;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)src\include\;$(ProjectDir)dep\include\</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)src\include\;$(ProjectDir)dep\include\</AdditionalIncludeDirectories>
|
||||||
<ObjectFileName>$(IntDir)obj\</ObjectFileName>
|
<ObjectFileName>$(IntDir)obj\</ObjectFileName>
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#ifdef NFENGINE
|
|
||||||
|
#include <thread>
|
||||||
#include "GL\glew.h"
|
#include "GL\glew.h"
|
||||||
#include "GL\wglew.h"
|
#include "GL\wglew.h"
|
||||||
#endif
|
|
||||||
|
#include "Utility.h"
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
DEBUGINIT;
|
DEBUGINIT;
|
||||||
@ -41,7 +43,7 @@ namespace nf {
|
|||||||
m_states[stateName] = state;
|
m_states[stateName] = state;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Error(("State \"" + (std::string)stateName + (std::string)"\" already exists!").c_str());
|
Error("State \"" + (std::string)stateName + (std::string)"\" already exists!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +54,7 @@ namespace nf {
|
|||||||
m_defaultStateAdded = true;
|
m_defaultStateAdded = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Error(("State \"" + (std::string)stateName + (std::string)"\" doesn't exist!").c_str());
|
Error("State \"" + (std::string)stateName + (std::string)"\" doesn't exist!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -93,7 +95,7 @@ namespace nf {
|
|||||||
m_currentState->onEnter(this);
|
m_currentState->onEnter(this);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Error(("State \"" + (std::string)stateName + (std::string)"\" doesn't exist!").c_str());
|
Error("State \"" + (std::string)stateName + (std::string)"\" doesn't exist!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,6 +159,7 @@ namespace nf {
|
|||||||
m_frames = 0;
|
m_frames = 0;
|
||||||
Log("FPS: " + std::to_string(m_FPS));
|
Log("FPS: " + std::to_string(m_FPS));
|
||||||
m_fpsClock1 = std::chrono::steady_clock::now();
|
m_fpsClock1 = std::chrono::steady_clock::now();
|
||||||
|
//TODO: Rework calculating FPS
|
||||||
}
|
}
|
||||||
std::this_thread::sleep_until(next_time);
|
std::this_thread::sleep_until(next_time);
|
||||||
m_deltaTime = (double)(std::chrono::steady_clock::now() - start_time).count();
|
m_deltaTime = (double)(std::chrono::steady_clock::now() - start_time).count();
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "IntroGamestate.h"
|
#include "IntroGamestate.h"
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
#include "Utility.h"
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
void IntroGamestate::onEnter(Application* app) {
|
void IntroGamestate::onEnter(Application* app) {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "IndexBuffer.h"
|
#include "IndexBuffer.h"
|
||||||
|
|
||||||
|
#include "GL/glew.h"
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
IndexBuffer::IndexBuffer(const void* data, size_t count) {
|
IndexBuffer::IndexBuffer(const void* data, size_t count) {
|
||||||
m_count = count;
|
m_count = count;
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
#include "Renderer.h"
|
#include "Renderer.h"
|
||||||
|
|
||||||
|
#include "GL/glew.h"
|
||||||
|
#include "GL\wglew.h"
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
#include "Utility.h"
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
Renderer::Renderer(Application* app) {
|
Renderer::Renderer(Application* app) {
|
||||||
@ -54,7 +58,7 @@ namespace nf {
|
|||||||
|
|
||||||
GLenum err = glGetError();
|
GLenum err = glGetError();
|
||||||
if (err != GL_NO_ERROR) {
|
if (err != GL_NO_ERROR) {
|
||||||
Error(("OpenGL error " + std::to_string(err)).c_str());
|
Error("OpenGL error " + std::to_string(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
#include "Shader.h"
|
#include "Shader.h"
|
||||||
|
|
||||||
|
#include "GL/glew.h"
|
||||||
|
|
||||||
|
#include "Utility.h"
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
Shader::Shader(const char* vertexSource, const char* fragmentSource) {
|
Shader::Shader(const char* vertexSource, const char* fragmentSource) {
|
||||||
m_id = glCreateProgram();
|
m_id = glCreateProgram();
|
||||||
@ -19,7 +23,7 @@ namespace nf {
|
|||||||
char* message = new char[length];
|
char* message = new char[length];
|
||||||
glGetShaderInfoLog(curr, length, &length, message);
|
glGetShaderInfoLog(curr, length, &length, message);
|
||||||
message[length - 2] = 0;
|
message[length - 2] = 0;
|
||||||
Error(("OpenGL Error: " + (std::string)message).c_str());
|
Error("OpenGL Error: " + (std::string)message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glAttachShader(m_id, vs);
|
glAttachShader(m_id, vs);
|
||||||
@ -33,7 +37,7 @@ namespace nf {
|
|||||||
glGetProgramiv(m_id, GL_INFO_LOG_LENGTH, &length);
|
glGetProgramiv(m_id, GL_INFO_LOG_LENGTH, &length);
|
||||||
char* message = new char[length];
|
char* message = new char[length];
|
||||||
glGetProgramInfoLog(m_id, length, &length, message);
|
glGetProgramInfoLog(m_id, length, &length, message);
|
||||||
Error(("OpenGL Error: " + (std::string)message).c_str());
|
Error("OpenGL Error: " + (std::string)message);
|
||||||
}
|
}
|
||||||
glDeleteShader(vs);
|
glDeleteShader(vs);
|
||||||
glDeleteShader(fs);
|
glDeleteShader(fs);
|
||||||
@ -42,6 +46,14 @@ namespace nf {
|
|||||||
void Shader::bind() {
|
void Shader::bind() {
|
||||||
glUseProgram(m_id);
|
glUseProgram(m_id);
|
||||||
}
|
}
|
||||||
|
//TODO: Create overloaded setUniform function
|
||||||
|
void Shader::getUniformLocation(const char* uniformName) {
|
||||||
|
unsigned int loc = glGetUniformLocation(m_id, uniformName);
|
||||||
|
if (loc == -1) {
|
||||||
|
Error("Uniform \"" + (std::string)uniformName + "\" does not exist!");
|
||||||
|
}
|
||||||
|
m_uniformLocations[uniformName] = loc;
|
||||||
|
}
|
||||||
|
|
||||||
Shader::~Shader() {
|
Shader::~Shader() {
|
||||||
glDeleteProgram(m_id);
|
glDeleteProgram(m_id);
|
||||||
|
@ -1,50 +1,63 @@
|
|||||||
#include "VertexArray.h"
|
#include "VertexArray.h"
|
||||||
|
|
||||||
|
#include "GL/glew.h"
|
||||||
|
|
||||||
|
#include "Utility.h"
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
unsigned int VertexBufferElement::getSizeOfType(unsigned int type) {
|
VertexArray::VertexArray() {
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case GL_FLOAT:
|
|
||||||
return sizeof(type);
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
VertexArray::VertexArray(const void* bufferData, size_t bufferSize) :
|
|
||||||
m_id(0),
|
|
||||||
m_vb(bufferData, bufferSize),
|
|
||||||
m_hasLayout(false),
|
|
||||||
m_vertexStride(0)
|
|
||||||
{
|
|
||||||
glGenVertexArrays(1, &m_id);
|
glGenVertexArrays(1, &m_id);
|
||||||
|
glBindVertexArray(m_id);
|
||||||
|
m_lastBufferHasLayout = true;
|
||||||
|
m_attribute = 0;
|
||||||
|
m_lastStride = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VertexArray::bind() {
|
void VertexArray::addBuffer(const void* data, const size_t size) {
|
||||||
glBindVertexArray(m_id);
|
if (!m_lastBufferHasLayout) {
|
||||||
m_vb.bind();
|
Error("Buffer added to vertex array has no layout!");
|
||||||
if (!m_hasLayout && m_vertexStride > 0) {
|
|
||||||
unsigned int offset = 0;
|
|
||||||
for (unsigned int i = 0; i < m_layoutElements.size(); i++) {
|
|
||||||
const VertexBufferElement& element = m_layoutElements[i];
|
|
||||||
glEnableVertexAttribArray(i);
|
|
||||||
glVertexAttribPointer(i, element.count, element.type, element.normalized, m_vertexStride, (const void*)offset);
|
|
||||||
offset += element.count * VertexBufferElement::getSizeOfType(element.type);
|
|
||||||
}
|
|
||||||
m_hasLayout = true;
|
|
||||||
}
|
|
||||||
else if(!m_hasLayout) {
|
|
||||||
Error("No layout specified for vertex buffer!");
|
|
||||||
}
|
}
|
||||||
|
m_buffers.push_back(new VertexBuffer(data, size));
|
||||||
|
m_buffers.back()->bind();
|
||||||
|
m_lastBufferHasLayout = false;
|
||||||
|
m_lastStride = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void VertexArray::push<float>(unsigned int count) {
|
void VertexArray::push<float>(unsigned int count) {
|
||||||
m_layoutElements.push_back({ GL_FLOAT, count, GL_FALSE });
|
if (m_lastBufferHasLayout) {
|
||||||
m_vertexStride += VertexBufferElement::getSizeOfType(GL_FLOAT) * count;
|
Error("Tried to modify a vertex array's buffer after the layout was final!");
|
||||||
|
}
|
||||||
|
m_lastBufferLayout.push_back({ GL_FLOAT, count, GL_FALSE });
|
||||||
|
m_lastStride += count * sizeof(GL_FLOAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VertexArray::finishBufferLayout() {
|
||||||
|
unsigned int offset = 0;
|
||||||
|
for (; m_attribute < m_lastBufferLayout.size(); m_attribute++) {
|
||||||
|
const VertexBufferElement& curr = m_lastBufferLayout[m_attribute];
|
||||||
|
glEnableVertexAttribArray(m_attribute);
|
||||||
|
glVertexAttribPointer(m_attribute, curr.count, curr.type, curr.normalized, m_lastStride, (const void*)offset);
|
||||||
|
offset += sizeof(curr.type) * curr.count;
|
||||||
|
}
|
||||||
|
m_lastBufferHasLayout = true;
|
||||||
|
m_lastStride = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VertexArray::bind(unsigned int buffer) {
|
||||||
|
if (m_buffers.empty()) {
|
||||||
|
Error("No buffers and layouts added to vertex array before being bound!");
|
||||||
|
}
|
||||||
|
if (!m_lastBufferHasLayout) {
|
||||||
|
Error("Buffer added to vertex array has no layout!");
|
||||||
|
}
|
||||||
|
glBindVertexArray(m_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexArray::~VertexArray() {
|
VertexArray::~VertexArray() {
|
||||||
|
for (VertexBuffer* curr : m_buffers) {
|
||||||
|
delete curr;
|
||||||
|
}
|
||||||
glDeleteVertexArrays(1, &m_id);
|
glDeleteVertexArrays(1, &m_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,9 @@
|
|||||||
#include "VertexBuffer.h"
|
#include "VertexBuffer.h"
|
||||||
|
|
||||||
|
#include "GL/glew.h"
|
||||||
|
|
||||||
|
#include "Utility.h"
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
VertexBuffer::VertexBuffer(const void* data, const size_t size) {
|
VertexBuffer::VertexBuffer(const void* data, const size_t size) {
|
||||||
glGenBuffers(1, &m_id);
|
glGenBuffers(1, &m_id);
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
|
#include "Utility.h"
|
||||||
|
#include <thread>
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <fstream>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
#include "Utility.h"
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
@ -35,6 +39,16 @@ namespace nf {
|
|||||||
CloseHandle(cmd);
|
CloseHandle(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Debug::ErrorImp(const std::string& in, const char* filename, int line) {
|
||||||
|
std::chrono::duration<float> time = getCurrentTime();
|
||||||
|
HANDLE cmd = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
SetConsoleTextAttribute(cmd, FOREGROUND_RED);
|
||||||
|
std::printf("[%.4f] Error (%s, %i): ", time.count(), filename, line);
|
||||||
|
std::cout << in << "\n";
|
||||||
|
SetConsoleTextAttribute(cmd, 7);
|
||||||
|
CloseHandle(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
std::chrono::duration<float> Debug::getCurrentTime() {
|
std::chrono::duration<float> Debug::getCurrentTime() {
|
||||||
std::chrono::steady_clock::time_point now = std::chrono::high_resolution_clock::now();
|
std::chrono::steady_clock::time_point now = std::chrono::high_resolution_clock::now();
|
||||||
return now - m_initTime;
|
return now - m_initTime;
|
||||||
@ -47,6 +61,13 @@ namespace nf {
|
|||||||
MultiByteToWideChar(CP_ACP, NULL, in, -1, out, length);
|
MultiByteToWideChar(CP_ACP, NULL, in, -1, out, length);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
const wchar_t* toWide(const std::string& in) {
|
||||||
|
const char* cstr = in.c_str();
|
||||||
|
int length = std::strlen(cstr) + 1;
|
||||||
|
wchar_t* out = new wchar_t[length];
|
||||||
|
MultiByteToWideChar(CP_ACP, NULL, cstr, -1, out, length);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
//TODO: File encryption
|
//TODO: File encryption
|
||||||
bool writeFile(const char* filename, const std::string& in) {
|
bool writeFile(const char* filename, const std::string& in) {
|
||||||
std::string file(filename);
|
std::string file(filename);
|
||||||
@ -65,7 +86,7 @@ namespace nf {
|
|||||||
std::ofstream out;
|
std::ofstream out;
|
||||||
out.open(filename);
|
out.open(filename);
|
||||||
if (!out) {
|
if (!out) {
|
||||||
Error(("File \"" + (std::string)filename + (std::string)"\" could not be written!").c_str());
|
Error("File \"" + (std::string)filename + (std::string)"\" could not be written!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out << in;
|
out << in;
|
||||||
@ -77,7 +98,7 @@ namespace nf {
|
|||||||
std::ifstream in;
|
std::ifstream in;
|
||||||
in.open(filename);
|
in.open(filename);
|
||||||
if (!in) {
|
if (!in) {
|
||||||
Error(("File \"" + (std::string)filename + (std::string)"\" could not be read!").c_str());
|
Error("File \"" + (std::string)filename + (std::string)"\" could not be read!");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <Windows.h>
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <Windows.h>
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Utility.h"
|
|
||||||
#include "IntroGamestate.h"
|
#include "IntroGamestate.h"
|
||||||
#include "Renderer.h"
|
#include "Renderer.h"
|
||||||
//TODO: Check #include consistency
|
|
||||||
//TODO: Separate #includes between headers and implementations
|
|
||||||
//TODO: Document ALL frontend functions
|
//TODO: Document ALL frontend functions
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "GL/glew.h"
|
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
class IndexBuffer {
|
class IndexBuffer {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "IGamestate.h"
|
#include "IGamestate.h"
|
||||||
#include "Utility.h"
|
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
class IntroGamestate : public IGamestate {
|
class IntroGamestate : public IGamestate {
|
||||||
@ -12,5 +11,6 @@ namespace nf {
|
|||||||
void render() override;
|
void render() override;
|
||||||
private:
|
private:
|
||||||
int counter;
|
int counter;
|
||||||
|
//TODO: Flesh out intro gamestate
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
//Master engine include (Is this even useful?)
|
//TODO: Rework this file to only contain functions the frontend will need to access
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "Input.h"
|
#include "Input.h"
|
||||||
|
#include "Utility.h"
|
||||||
|
|
||||||
using namespace nf;
|
using namespace nf;
|
@ -1,8 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#ifdef NFENGINE
|
#include <Windows.h>
|
||||||
#include "GL/glew.h"
|
|
||||||
#include "GL\wglew.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
class Application;
|
class Application;
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#ifdef NFENGINE
|
#include <unordered_map>
|
||||||
#include "GL/glew.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Utility.h"
|
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
class Shader {
|
class Shader {
|
||||||
@ -11,10 +7,12 @@ namespace nf {
|
|||||||
Shader(const char* vertexSource, const char* fragmentSource);
|
Shader(const char* vertexSource, const char* fragmentSource);
|
||||||
|
|
||||||
void bind();
|
void bind();
|
||||||
|
void getUniformLocation(const char* uniformName);
|
||||||
|
|
||||||
~Shader();
|
~Shader();
|
||||||
private:
|
private:
|
||||||
unsigned int m_id;
|
unsigned int m_id;
|
||||||
//Associated resource?
|
std::unordered_map<const char*, unsigned int> m_uniformLocations;
|
||||||
|
//TODO: Load from resource
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -1,11 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <thread>
|
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <fstream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <Windows.h>
|
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@ -33,6 +28,7 @@ __debugbreak();
|
|||||||
static void LogImp(int in);
|
static void LogImp(int in);
|
||||||
static void LogImp(double in);
|
static void LogImp(double in);
|
||||||
static void ErrorImp(const char* in, const char* filename, int line);
|
static void ErrorImp(const char* in, const char* filename, int line);
|
||||||
|
static void ErrorImp(const std::string& in, const char* filename, int line);
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
#define DEBUGINIT
|
#define DEBUGINIT
|
||||||
@ -42,6 +38,7 @@ std::exit(-1)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
const wchar_t* toWide(const char* in);
|
const wchar_t* toWide(const char* in);
|
||||||
|
const wchar_t* toWide(const std::string& in);
|
||||||
bool writeFile(const char* filename, const std::string& in);
|
bool writeFile(const char* filename, const std::string& in);
|
||||||
std::string readFile(const char* filename);
|
std::string readFile(const char* filename);
|
||||||
}
|
}
|
@ -1,35 +1,32 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#ifdef NFENGINE
|
|
||||||
#include "GL/glew.h"
|
|
||||||
#endif
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "VertexBuffer.h"
|
#include "VertexBuffer.h"
|
||||||
#include "Utility.h"
|
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
struct VertexBufferElement {
|
struct VertexBufferElement {
|
||||||
unsigned int type;
|
unsigned int type;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
unsigned char normalized;
|
unsigned char normalized;
|
||||||
|
|
||||||
static unsigned int getSizeOfType(unsigned int type);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class VertexArray {
|
class VertexArray {
|
||||||
public:
|
public:
|
||||||
VertexArray(const void* bufferData, size_t bufferSize);
|
VertexArray();
|
||||||
|
|
||||||
void bind();
|
void addBuffer(const void* data, const size_t size);
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void push(unsigned int count);
|
void push(unsigned int count);
|
||||||
|
void finishBufferLayout();
|
||||||
|
void bind(unsigned int buffer = 1);
|
||||||
|
|
||||||
~VertexArray();
|
~VertexArray();
|
||||||
private:
|
private:
|
||||||
unsigned int m_id;
|
unsigned int m_id;
|
||||||
VertexBuffer m_vb;
|
bool m_lastBufferHasLayout;
|
||||||
bool m_hasLayout;
|
std::vector<VertexBuffer*> m_buffers;
|
||||||
std::vector<VertexBufferElement> m_layoutElements;
|
std::vector<VertexBufferElement> m_lastBufferLayout;
|
||||||
unsigned int m_vertexStride;
|
unsigned int m_attribute;
|
||||||
|
unsigned int m_lastStride;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -1,7 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#ifdef NFENGINE
|
|
||||||
#include "GL/glew.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace nf {
|
namespace nf {
|
||||||
class VertexBuffer {
|
class VertexBuffer {
|
||||||
|
Reference in New Issue
Block a user