- Add position, rotation and scale fields to `Mesh3D` and expose them publicly. - Remove the old `Object3D` struct; `Objects3D` now stores `unique_ptr<Mesh3D>`. - Implement a new `createObject(name,textures,filepath,position,rotation,scale)` overload that sets transforms after loading the mesh. - Add a `draw(Mesh3D*)` helper that binds the texture, builds a model matrix and issues `glDrawArrays`. - Update the rendering loop to use `draw()` instead of the old cube routine. - Simplify `onCreate`: enable depth test, flip textures, create two objects with proper transforms, set clear color. - Enable window resizing (`GLFW_RESIZABLE`), change default size to 800×600 in `main.cpp`. - Clean up includes and remove unused `cube.cpp`; refactor OBJ parsing for robustness. These changes unify object handling, allow per‑object transformations, simplify the rendering pipeline, improve maintainability, and make the window resizable.
		
			
				
	
	
		
			61 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			61 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| #ifndef ENGINE_H
 | |
| #define ENGINE_H
 | |
| 
 | |
| #include <GL/glew.h>
 | |
| #include <GLFW/glfw3.h>
 | |
| #include "ShaderProgram.h"
 | |
| #include <map>
 | |
| #include <memory>
 | |
| #include <string>
 | |
| #include "Mesh3D.h"
 | |
| #include <GL/glew.h>
 | |
| #include <GLFW/glfw3.h>
 | |
| #include <glm/glm.hpp>
 | |
| #include <glm/gtc/matrix_transform.hpp>
 | |
| #include <glm/gtc/type_ptr.hpp>
 | |
| 
 | |
| #define NBCALLBACKS 1
 | |
| 
 | |
| typedef void (*KeyCallback)(GLFWwindow* window, int key, int scancode, int action, int mods);
 | |
| 
 | |
| 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 createObject(std::string name, std::string textures, std::string filepath, glm::vec3 position, glm::vec3 rotation, glm::vec3 scale);
 | |
|       void loadCallbacks();
 | |
|       void showFps();
 | |
|       void onCreate();
 | |
|       void onDestroy();
 | |
|       void draw(Mesh3D* object);
 | |
|   };
 | |
| }
 | |
| 
 | |
| #endif // ENGINE_H
 |