- Introduce Mesh3D class with vertices, texture, VBO/VAO. - Replace Object3D struct and textures map in engine with Mesh3D objects. - Update createObject to load from file path instead of vertex array. - Adjust cube rendering to use new vertex count. - Remove debug prints from Texture2D loading. - Toggle fragment shader color vs texture usage.
62 lines
1.2 KiB
C++
62 lines
1.2 KiB
C++
#ifndef ENGINE_H
|
|
#define ENGINE_H
|
|
|
|
#include <GL/glew.h>
|
|
#include <GLFW/glfw3.h>
|
|
#include "ShaderProgram.h"
|
|
#include "Texture2D.h"
|
|
#include <map>
|
|
#include <sstream>
|
|
#include <string>
|
|
#include <vector>
|
|
#include "Mesh3D.h"
|
|
|
|
#define NBCALLBACKS 1
|
|
|
|
typedef void (*KeyCallback)(GLFWwindow* window, int key, int scancode, int action, int mods);
|
|
|
|
struct Object3D {
|
|
Texture2D texture;
|
|
GLuint VBO;
|
|
GLuint VAO;
|
|
};
|
|
|
|
typedef std::map<std::string,djalim::Mesh3D> Objects3D;
|
|
|
|
static bool gWireframe = false;
|
|
|
|
namespace djalim {
|
|
|
|
class OpenGlEngine{
|
|
|
|
public:
|
|
|
|
void start();
|
|
OpenGlEngine( const char* title, int width, int height);
|
|
~OpenGlEngine();
|
|
|
|
GLFWwindow* window;
|
|
double previousSeconds = 0.0;
|
|
double elapsedSeconds;
|
|
int frameCount = 0;
|
|
ShaderProgram shaderProgram;
|
|
|
|
Objects3D objects;
|
|
|
|
unsigned int VBO;
|
|
unsigned int VAO;
|
|
|
|
bool gWireframe = false;
|
|
|
|
void onUpdate();
|
|
void loadHints();
|
|
void createObject(std::string name, std::string textures, std::string filepath);
|
|
void loadCallbacks();
|
|
void showFps();
|
|
void onCreate();
|
|
void onDestroy();
|
|
};
|
|
}
|
|
|
|
#endif // ENGINE_H
|