diff --git a/src/gfx/include/gfx/object.hpp b/src/gfx/include/gfx/object.hpp index 4fbda26b452d156cc3bcc24157f20ea10a140471..8effe312b7704b62bbd2f7aa650b422ccf32ba21 100644 --- a/src/gfx/include/gfx/object.hpp +++ b/src/gfx/include/gfx/object.hpp @@ -26,6 +26,10 @@ public: glm::vec3 _color = glm::vec3(1.0f, 0.5f, 0.31f), std::string _shader_type = "lit"); + void SendDataToVAO(std::vector<float> const &_vertices, + std::vector<unsigned int> const &_indices, + std::vector<float> const &_normals); + std::vector<float> const &getVertices() const { return _VAO->getVertices(); } void setVertices(std::vector<float> const &new_vertices) { _VAO->setVertices(new_vertices); } @@ -35,10 +39,6 @@ public: std::vector<float> const &getNormals() const { return _VAO->getNormals(); } void setNormals(std::vector<float> const &new_normals) { _VAO->setNormals(new_normals); } - void SendDataToVAO(std::vector<float> const &_vertices, - std::vector<unsigned int> const &_indices, - std::vector<float> const &_normals); - VAO* getVAO() { return _VAO.get(); } std::string getShaderType() const { return shader_type; } diff --git a/src/gfx/src/render.cpp b/src/gfx/src/render.cpp index efd6816ce4bde343675c5f27f27990e029b32a5f..22d35f52b888243f2ef4736924c78b0c5dd21663 100644 --- a/src/gfx/src/render.cpp +++ b/src/gfx/src/render.cpp @@ -52,7 +52,7 @@ std::vector<unsigned int> generate_grid_indices(int span) void send_matrices_to_shader(Shader &myShader, glm::mat4 &model, glm::mat4 &view, glm::mat4 &projection) { - // QUESTION: glGetUniformLocation CPU usage high? + // glGetUniformLocation CPU usage high? int modelLoc = glGetUniformLocation(myShader.getID(), "model"); ASSUMPTION(glGetError() == GL_NO_ERROR); glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model)); @@ -82,7 +82,7 @@ void draw_objects(std::map<std::string, shader_ptr> &myShaders, light_ptr light, if (shader_used == "lit") { - // Hardcoded light index + /* Hardcoded light index */ // TO DO: enum promennych z shaderu myShaders[shader_used]->setVec3("lightColor", light->getColor()); myShaders[shader_used]->setVec3("lightPos", light->getPosition()); @@ -161,9 +161,9 @@ void gfx_draw(std::map<std::string, shader_ptr> &myShaders, light_ptr light, glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); ASSUMPTION(glGetError() == GL_NO_ERROR); - // DRAW OBJECTS + /* DRAW OBJECTS */ draw_objects(myShaders, light, cam_frames, active_camera, objects, obj_frames, view, projection); - // DRAW GRID + /* DRAW GRID */ draw_grid(myShaders, grid, grid_frame, view, projection); } diff --git a/src/studio/src/simulator.cpp b/src/studio/src/simulator.cpp index 49e65f53d762fe3377473761fe6c2c597f92066f..29183b6ac42ed5b0a48df55c3b513108e17c60bd 100644 --- a/src/studio/src/simulator.cpp +++ b/src/studio/src/simulator.cpp @@ -126,16 +126,16 @@ Simulator::Simulator() , obj_controls{std::make_shared<ObjectController>()} , light{std::make_shared<Light>(glm::vec3(1.0f, 1.0f, 1.0f), obj_frames[1]->getPosition())} { - // SET LIGHT CUBE SHADER AND SIZE + /* SET LIGHT CUBE SHADER AND SIZE */ objects[1]->setShaderType("basic"); obj_frames[1]->setScale(glm::vec3(0.1f, 0.1f, 0.1f)); - // SET ACTIVE OBJECT AND ROTATE + /* SET ACTIVE OBJECT AND ROTATE */ active_object_idx = 0; // 1 for light obj_controls[object_ctrl_type]->setFrame(obj_frames[active_object_idx]); obj_controls[object_ctrl_type]->rotate(glm::vec3(0.0f, 50.0f, 0.0f)); - // SET ACTIVE CAMERA AND CONTROLLER TYPE + /* SET ACTIVE CAMERA AND CONTROLLER TYPE */ cameras[active_camera]->setWindowSize(window().size()); cam_controls[active_camera_type]->setFrame(cam_frames[active_camera]); @@ -145,17 +145,19 @@ Simulator::~Simulator() {} void Simulator::update() { - // Update the state (i.e., transform objects, create/destroy objects, ... ) + /* Update the state (i.e., transform objects, create/destroy objects, ... ) */ process_input(); process_mouse(); - // obj_controls[0]->rotate(glm::vec3(1.0f, 0.0f, 0.0f)); // Rotation around x-axis demo + + /* Rotation around x-axis demo */ + // obj_controls[0]->rotate(glm::vec3(1.0f, 0.0f, 0.0f)); } void Simulator::present() { - // Present the state to the user (i.e., render objects) - // For now, we just clear screen buffers and show some gui widget. + /* Present the state to the user (i.e., render objects) + * For now, we just clear screen buffers and show some gui widget. */ ImGui::Begin("ImGui dialog"); ImGui::Text("Hello, world!"); @@ -169,7 +171,7 @@ void Simulator::present() gfx_draw(myShaders, light, cameras, cam_frames, active_camera, objects, obj_frames, grid, grid_frame); } -// Object movement now works only for one object +/* Object movement now works only for one object */ // TO DO: send frames to controller somewhere? void Simulator::process_input() { @@ -190,7 +192,7 @@ void Simulator::process_input() cam_controls[active_camera_type]->move(keyboard().down()); } - int fill_mode = keyboard().down().contains("X") ? GL_LINE : GL_FILL; // MTO DO: change + int fill_mode = keyboard().down().contains("X") ? GL_LINE : GL_FILL; // MTO DO: put elsewhere glPolygonMode(GL_FRONT_AND_BACK, fill_mode); ASSUMPTION(glGetError() == GL_NO_ERROR); }