SHARE
TWEET

Untitled

a guest May 19th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. wxLfPanel::wxLfPanel(wxWindow* parent, wxWindowID id, bool withScene) : wxControl(parent, id, wxDefaultPosition, wxDefaultSize)
  2. {
  3.     timerUpdate.SetOwner(this);
  4.     Connect(timerUpdate.GetId(), wxEVT_TIMER, wxTimerEventHandler(wxLfPanel::OnTimer));
  5.     wxStaticText* main = new wxStaticText(this, wxID_ANY, wxEmptyString, GetPosition(), GetSize());
  6.     main->SetBackgroundStyle(wxBG_STYLE_CUSTOM);
  7.  
  8.     s32 creationFlags = render::EWCF_OPPL_PIPELINE | render::EWCF_AUTOCLOSE | render::EWCF_VISIBLE | (withScene ? 0 : render::EWCF_NO_DEFAULT_SCENE);
  9.     lf::render::SPlatformHandle platform_handle;
  10.         // initialize LFRenderWindow in this window
  11. #ifdef LINUX
  12.     GtkWidget* handle = main->GetHandle();
  13.     gtk_widget_realize(handle);
  14.     if (!handle || !handle->window)
  15.         return;
  16.  
  17.     platform_handle.window_handle = (long)(GDK_WINDOW_XWINDOW(handle->window));
  18.     platform_handle.display_handle = (long)(GDK_WINDOW_XDISPLAY(handle->window)); // ignored!
  19.     platform_handle.screen_handle = DefaultScreen(platform_handle.display_handle);
  20. #else
  21.     platform_handle.window_handle = reinterpret_cast<long>(main->GetHandle());
  22. #endif
  23.     CLFLog::getInstance().log(log::ELS_USER1, log::ELL_INFO, "Creating new render window ---");
  24.     _rwin = lf::CLFRender::getInstancePtr()->useExternalRenderWindow(platform_handle, creationFlags, 0);
  25.     //_rFirstWin = _rwin;   // todo: replace 0 by _rwin to use shared context again
  26.  
  27.     _rwin->setVisible(true);
  28.     if(withScene)
  29.     {
  30.         _rwin->getRenderLayer3D()->addCamera(new scene::C3DCamera());
  31.         _rwin->getRenderLayer3D()->getCamera(0)->setBackgroundColor(core::CColorI(91,95,107,255));
  32.         _rwin->getRenderLayer3D()->getCamera(0)->setPosition(core::vector3df(-10,20,-50));
  33.         _rwin->getRenderLayer3D()->getCamera(0)->setTarget(core::vector3df(0,0,0));
  34.         _rwin->getRenderLayer3D()->getCamera(0)->setFarValue(1000.f);
  35.         _rwin->getRenderLayer3D()->getCamera(0)->setRendererPipeline(0, _rwin->getForwardMultiPassRendererPipeline());
  36.         _rwin->getRenderLayer3D()->getCamera(0)->drop();
  37.     }
  38.     // sanity check
  39.     assert(_rwin && "Cannot create render window!");
  40.     _rwin->addFrameListener(this);
  41.     timerUpdate.Start(30); 
  42.     CLFLog::getInstance().log(log::ELS_USER1, log::ELL_INFO, "rwin count: %i", CLFRender::getInstance().getRenderWindowCount());
  43. }
  44.  
  45. wxLfPanel::~wxLfPanel()
  46. {
  47.     _rwin->removeFrameListener(this);
  48.     _rwin->closeWindow();
  49.     _rwin->drop();
  50.     CLFLog::getInstance().log(log::ELS_USER1, log::ELL_INFO, "rwin count: %i", CLFRender::getInstance().getRenderWindowCount());
  51.     CLFLog::getInstance().log(log::ELS_USER1, log::ELL_INFO, "Removing render window ---");
  52. }
RAW Paste Data
Top