Commit db997784 authored by Nicolas Docquier's avatar Nicolas Docquier
Browse files

Adapt mbs_common/realtime code to the new architecture

This mainly consist in calling the MbsWorld3D constructor with the 2 new
arguments, i.e. the WindowManager object and the WorldRenderer object.
parent 3d290429
......@@ -85,7 +85,7 @@ int main(int argc, char const *argv[])
mbs_dirdyn->options->save2file = 1;
mbs_dirdyn->options->respath = PROJECT_SOURCE_DIR"/../resultsR";
mbs_dirdyn->options->animpath = PROJECT_SOURCE_DIR"/../animationR";
mbs_dirdyn->options->realtime = 0;
mbs_dirdyn->options->realtime = 1;
mbs_run_dirdyn(mbs_dirdyn, mbs_data);
......
......@@ -104,6 +104,10 @@ if (FLAG_REAL_TIME AND FLAG_OPEN_GL)
include_directories("./open_gl/world")
include_directories("./open_gl/renderer")
include_directories("./open_gl/renderer/default")
include_directories("./open_gl/renderer/ogl")
include_directories("./open_gl/specific_include")
include_directories("./open_gl/window")
include_directories("./open_gl/window/glfw")
increment_src( ${PROJECT_SOURCE_DIR}/open_gl )
......
......@@ -10,6 +10,9 @@
#include <string>
#include <sstream>
#include "OglWorldRenderer.hh"
#include "GlfwWindowManager.hh"
#if (defined OPEN_GL_THREAD_UNIX) || (defined OPEN_GL_PROCESS_UNIX)
#include <unistd.h>
#include <pthread.h>
......@@ -236,7 +239,8 @@ void init_open_gl(Realtime_visu *visu, MbsData *mbs_data, int nb_models, int *nb
}
// create world
world_3d = new OpenGLMbs::MbsWorld3D(1024, 768, shader_flag, multi_samp);
world_3d = new OpenGLMbs::MbsWorld3D(1024, 768, shader_flag, multi_samp, glm::vec3(0.0, 0.0, 0.0),
new OpenGLMbs::OglWorldRenderer(), new OpenGLMbs::GlfwWindowManager());
// load each model
for(int i=0; i<nb_models; i++)
......@@ -850,7 +854,8 @@ void opengl_thread_unix_run_visu(OpenGlIn* open_gl_in)
}
// create world
world_3d = new OpenGLMbs::MbsWorld3D(1024, 768, shader_flag, multi_samp);
world_3d = new OpenGLMbs::MbsWorld3D(1024, 768, shader_flag, multi_samp, glm::vec3(0.0, 0.0, 0.0),
new OpenGLMbs::OglWorldRenderer(), new OpenGLMbs::GlfwWindowManager());
// save world adress
open_gl_in->visu->visu_class = world_3d;
......
......@@ -20,6 +20,9 @@
#include <iostream>
#include <sstream>
#include "OglWorldRenderer.hh"
#include "GlfwWindowManager.hh"
// states of the window
enum {OPEN_GL_RUN, OPEN_GL_BREAK, OPEN_GL_STOP};
......@@ -112,7 +115,8 @@ int main(int argc, char const *argv[])
}
// create world
world_3d = new OpenGLMbs::MbsWorld3D(1024, 768, shader_flag, multi_samp);
world_3d = new OpenGLMbs::MbsWorld3D(1024, 768, shader_flag, multi_samp, glm::vec3(0.0, 0.0, 0.0),
new OpenGLMbs::OglWorldRenderer(), new OpenGLMbs::GlfwWindowManager());
// load each model
for(int i=0; i<nb_models; i++)
......
......@@ -16,6 +16,9 @@
#include <sstream>
#include <windows.h>
#include "OglWorldRenderer.hh"
#include "GlfwWindowManager.hh"
// size of the buffer to send messages
#define BUFSIZE 4096
......@@ -73,7 +76,8 @@ int main(int argc, char const *argv[])
multi_samp = 4;
// create world
world_3d = new OpenGLMbs::MbsWorld3D(1024, 768, shader_flag, multi_samp);
world_3d = new OpenGLMbs::MbsWorld3D(1024, 768, shader_flag, multi_samp, glm::vec3(0.0, 0.0, 0.0),
new OpenGLMbs::OglWorldRenderer(), new OpenGLMbs::GlfwWindowManager());
}
else
{
......@@ -88,7 +92,8 @@ int main(int argc, char const *argv[])
OpenGLMbs::shader_multisample(pipe_msg, shader_flag, multi_samp);
// create world
world_3d = new OpenGLMbs::MbsWorld3D(1024, 768, shader_flag, multi_samp);
world_3d = new OpenGLMbs::MbsWorld3D(1024, 768, shader_flag, multi_samp, glm::vec3(0.0, 0.0, 0.0),
new OpenGLMbs::OglWorldRenderer(), new OpenGLMbs::GlfwWindowManager());
}
world_3d->AddMbs(pipe_msg);
......
......@@ -20,9 +20,11 @@
//#include <gtx/transform.hpp>
#include "DefaultWorldRenderer.hh"
#include "GlfwWindowManager.hh"
#include "DefaultWindowManager.hh"
#include "OglWorldRenderer.hh"
#include "GlfwWindowManager.hh"
namespace OpenGLMbs{
......@@ -38,17 +40,24 @@ inline int limit_int_range(int x, int min, int max) { return (x < min) ? min : (
* \param[in] background_color color of the background
*/
MbsWorld3D::MbsWorld3D(int x_width, int y_width, int shader_flag, int multi_samp, glm::vec3 const& background_color,
MbsWorldRenderer* renderer):
MbsWorldRenderer* renderer, MbsWindowManager* winMngr):
mbs_read(this)
{
winManager = new DefaultWindowManager();
// Init the window
if(winMngr==0){
winManager=new DefaultWindowManager();
//winManager=new GlfwWindowManager();
}
else{
winManager = winMngr;
}
winManager->Init(this, x_width, y_width, multi_samp);
// Initialize the renderer
if(renderer==0){
worldRenderer=new DefaultWorldRenderer();
//worldRenderer=new OglWorldRenderer();
}
else{
worldRenderer = renderer;
......@@ -59,7 +68,7 @@ MbsWorld3D::MbsWorld3D(int x_width, int y_width, int shader_flag, int multi_samp
// init the renderer
renderer->Init();
worldRenderer->Init();
// swap buffers
winManager->SwapBuffers();
......
......@@ -51,7 +51,8 @@ class MbsWorld3D
public:
MbsWorld3D(int x_width=1024, int y_width=768, int shader_flag=LIGHTS_NO_SPEC_SHADER, int multi_samp=4,
glm::vec3 const& background_color = glm::vec3(0.8, 0.8, 0.8),
MbsWorldRenderer* renderer=0);
MbsWorldRenderer* renderer=0,
MbsWindowManager* winManager=0);
~MbsWorld3D();
/// get the width along the X axis (in pixels)
......
......@@ -9,9 +9,8 @@
#include "shader_multisample.hh"
#include <iostream>
#include "MbsWorldRenderer.hh"
#include "OglWorldRenderer.hh"
#include "DefaultWorldRenderer.hh"
#include "GlfwWindowManager.hh"
// function prototype for manual loading
void manual_mbs_load(OpenGLMbs::MbsWorld3D *world_3d);
......@@ -31,7 +30,8 @@ int main(int argc, char **argv)
// main window for 3D world
OpenGLMbs::MbsWorldRenderer* rdr = new OpenGLMbs::OglWorldRenderer();
OpenGLMbs::MbsWorld3D world_3d(1024, 768, shader_flag, multi_samp, glm::vec3(0.0, 0.0, 0.0), rdr);
OpenGLMbs::MbsWorld3D world_3d(1024, 768, shader_flag, multi_samp, glm::vec3(0.0, 0.0, 0.0),
new OpenGLMbs::OglWorldRenderer(), new OpenGLMbs::GlfwWindowManager());
// load mbs file
world_3d.AddMbs(PROJECT_SOURCE_DIR"/../../ExampleProjects/PendulumSpringC/dataR/PendulumSpringC_obj.mbs");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment