Rewrote VertexArray to support multiple VBOs; Minor fixes and organization

This commit is contained in:
grayson committed 2021-08-24 01:26:10 -05:00
1 parent f75f98d9db
commit e17d2e283a
18 files changed
+129 -86

No files matched your search

+1 -5
View File
@@ -1,15 +1,11 @@
#pragma once
#include <Windows.h>
#include <chrono>
#include <unordered_map>
#include <vector>
#include <Windows.h>
#include "Config.h"
#include "Utility.h"
#include "IntroGamestate.h"
#include "Renderer.h"
//TODO: Check #include consistency
//TODO: Separate #includes between headers and implementations
//TODO: Document ALL frontend functions
namespace nf {
-1
View File
@@ -1,5 +1,4 @@
#pragma once
#include "GL/glew.h"
namespace nf {
class IndexBuffer {
+1 -1
View File
@@ -1,6 +1,5 @@
#pragma once
#include "IGamestate.h"
#include "Utility.h"
namespace nf {
class IntroGamestate : public IGamestate {
@@ -12,5 +11,6 @@ namespace nf {
void render() override;
private:
int counter;
//TODO: Flesh out intro gamestate
};
}
+2 -1
View File
@@ -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 "Input.h"
#include "Utility.h"
using namespace nf;
+1 -4
View File
@@ -1,8 +1,5 @@
#pragma once
#ifdef NFENGINE
#include "GL/glew.h"
#include "GL\wglew.h"
#endif
#include <Windows.h>
namespace nf {
class Application;
+4 -6
View File
@@ -1,9 +1,5 @@
#pragma once
#ifdef NFENGINE
#include "GL/glew.h"
#endif
#include "Utility.h"
#include <unordered_map>
namespace nf {
class Shader {
@@ -11,10 +7,12 @@ namespace nf {
Shader(const char* vertexSource, const char* fragmentSource);
void bind();
void getUniformLocation(const char* uniformName);
~Shader();
private:
unsigned int m_id;
//Associated resource?
std::unordered_map<const char*, unsigned int> m_uniformLocations;
//TODO: Load from resource
};
}
+2 -5
View File
@@ -1,11 +1,6 @@
#pragma once
#include <chrono>
#include <thread>
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <Windows.h>
namespace nf {
#ifdef _DEBUG
@@ -33,6 +28,7 @@ __debugbreak();
static void LogImp(int in);
static void LogImp(double in);
static void ErrorImp(const char* in, const char* filename, int line);
static void ErrorImp(const std::string& in, const char* filename, int line);
};
#else
#define DEBUGINIT
@@ -42,6 +38,7 @@ std::exit(-1)
#endif
const wchar_t* toWide(const char* in);
const wchar_t* toWide(const std::string& in);
bool writeFile(const char* filename, const std::string& in);
std::string readFile(const char* filename);
}
+9 -12
View File
@@ -1,35 +1,32 @@
#pragma once
#ifdef NFENGINE
#include "GL/glew.h"
#endif
#include <vector>
#include "VertexBuffer.h"
#include "Utility.h"
namespace nf {
struct VertexBufferElement {
unsigned int type;
unsigned int count;
unsigned char normalized;
static unsigned int getSizeOfType(unsigned int type);
};
class VertexArray {
public:
VertexArray(const void* bufferData, size_t bufferSize);
VertexArray();
void bind();
void addBuffer(const void* data, const size_t size);
template<typename T>
void push(unsigned int count);
void finishBufferLayout();
void bind(unsigned int buffer = 1);
~VertexArray();
private:
unsigned int m_id;
VertexBuffer m_vb;
bool m_hasLayout;
std::vector<VertexBufferElement> m_layoutElements;
unsigned int m_vertexStride;
bool m_lastBufferHasLayout;
std::vector<VertexBuffer*> m_buffers;
std::vector<VertexBufferElement> m_lastBufferLayout;
unsigned int m_attribute;
unsigned int m_lastStride;
};
}
-3
View File
@@ -1,7 +1,4 @@
#pragma once
#ifdef NFENGINE
#include "GL/glew.h"
#endif
namespace nf {
class VertexBuffer {