63 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			63 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 <memory>
 | |
| #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,std::unique_ptr<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
 |