Exemple #1
0
	MyProfileWindow (	Gwen::Controls::Base* pParent)
		: Gwen::Controls::WindowControl( pParent )
	{
		SetTitle( L"FEM Settings" );

		SetSize( 450, 150 );
		this->SetPos(0,40);

//		this->Dock( Gwen::Pos::Bottom);

		

		{
			m_ctrl = new Gwen::Controls::TreeControl( this );
			m_node = m_ctrl->AddNode( L"Total Parent Time" );

		
			//Gwen::Controls::TreeNode* pNode = ctrl->AddNode( L"Node Two" );
			//pNode->AddNode( L"Node Two Inside" );
			//pNode->AddNode( L"Eyes" );
			//pNode->AddNode( L"Brown" )->AddNode( L"Node Two Inside" )->AddNode( L"Eyes" )->AddNode( L"Brown" );
			//Gwen::Controls::TreeNode* node = ctrl->AddNode( L"Node Three" );
				
			

			//m_ctrl->Dock(Gwen::Pos::Bottom);
			
			m_ctrl->ExpandAll();
			m_ctrl->SetBounds( this->GetInnerBounds().x,this->GetInnerBounds().y,this->GetInnerBounds().w,this->GetInnerBounds().h);
			
		}



	}
Exemple #2
0
	void	UpdateText(CProfileIterator*  profileIterator, bool idle)
	{
	
		static bool update=true;

			m_ctrl->SetBounds(0,0,this->GetInnerBounds().w,this->GetInnerBounds().h);

//		if (!update)
//			return;
		update=false;

	
		static int test = 1;
		test++;

		static double time_since_reset = 0.f;
		if (!idle)
		{
			time_since_reset = CProfileManager::Get_Time_Since_Reset();
		}

		//Gwen::UnicodeString txt = Gwen::Utility::Format( L"FEM Settings  %i fps", test );
		{
		//recompute profiling data, and store profile strings

		char blockTime[128];

		double totalTime = 0;

		int frames_since_reset = CProfileManager::Get_Frame_Count_Since_Reset();

		profileIterator->First();

		double parent_time = profileIterator->Is_Root() ? time_since_reset : profileIterator->Get_Current_Parent_Total_Time();

	
		Gwen::Controls::TreeNode* curParent = m_node;

		double accumulated_time = dumpRecursive(profileIterator,m_node);

		Gwen::UnicodeString txt = Gwen::Utility::Format( L"Profiling: %s total time: %.3f ms, unaccounted %.3f %% :: %.3f ms", profileIterator->Get_Current_Parent_Name(), parent_time ,
			parent_time > SIMD_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f, parent_time - accumulated_time);
		//sprintf(blockTime,"--- Profiling: %s (total running time: %.3f ms) ---",	profileIterator->Get_Current_Parent_Name(), parent_time );
		//displayProfileString(xOffset,yStart,blockTime);
		m_node->SetText(txt);


			//printf("%s (%.3f %%) :: %.3f ms\n", "Unaccounted:",);
	

		}
		
		static bool once1 = true;
		if (once1)
		{
			once1 = false;
			m_ctrl->ExpandAll();
		}

	}
	MyProfileWindow (	Gwen::Controls::Base* pParent)
    : Gwen::Controls::WindowControl( pParent ),
	profIter(0)
	{
		SetTitle( L"Time Profiler" );
		
		SetSize( 450, 450 );
		this->SetPos(10,400);
		
        //		this->Dock( Gwen::Pos::Bottom);
		
		
		
		{
			m_ctrl = new Gwen::Controls::TreeControl( this );
			m_node = m_ctrl->AddNode( L"Total Parent Time" );
			
			
			//Gwen::Controls::TreeNode* pNode = ctrl->AddNode( L"Node Two" );
			//pNode->AddNode( L"Node Two Inside" );
			//pNode->AddNode( L"Eyes" );
			//pNode->AddNode( L"Brown" )->AddNode( L"Node Two Inside" )->AddNode( L"Eyes" )->AddNode( L"Brown" );
			//Gwen::Controls::TreeNode* node = ctrl->AddNode( L"Node Three" );
			
			
			
			//m_ctrl->Dock(Gwen::Pos::Bottom);
			
			m_ctrl->ExpandAll();
            m_ctrl->SetKeyboardInputEnabled(true);
			m_ctrl->SetBounds( this->GetInnerBounds().x,this->GetInnerBounds().y,this->GetInnerBounds().w,this->GetInnerBounds().h);
			
		}
		
		
		
	}
bool OpenGLExampleBrowser::init(int argc, char* argv[])
{
    b3CommandLineArgs args(argc,argv);
    
	loadCurrentSettings(startFileName, args);
	if (args.CheckCmdLineFlag("nogui"))
	{
		renderGrid = false;
		renderGui = false;
	}
	if (args.CheckCmdLineFlag("tracing"))
	{
		b3ChromeUtilsStartTimings();
	}
	args.GetCmdLineArgument("fixed_timestep",gFixedTimeStep);
	args.GetCmdLineArgument("png_skip_frames", gPngSkipFrames);	
	///The OpenCL rigid body pipeline is experimental and 
	///most OpenCL drivers and OpenCL compilers have issues with our kernels.
	///If you have a high-end desktop GPU such as AMD 7970 or better, or NVIDIA GTX 680 with up-to-date drivers
	///you could give it a try
	///Note that several old OpenCL physics examples still have to be ported over to this new Example Browser
	if (args.CheckCmdLineFlag("enable_experimental_opencl"))
	{
		enable_experimental_opencl = true;
		gAllExamples->initOpenCLExampleEntries();
	}
	
	if (args.CheckCmdLineFlag("disable_retina"))
	{
		gAllowRetina = false;
	}
		
	
	int width = 1024;
    int height=768;
#ifndef NO_OPENGL3
    SimpleOpenGL3App* simpleApp=0;
	sUseOpenGL2 =args.CheckCmdLineFlag("opengl2");
#else
	sUseOpenGL2 = true;
#endif
	const char* appTitle = "Bullet Physics ExampleBrowser";
#if defined (_DEBUG) || defined (DEBUG)
	const char* optMode = "Debug build (slow)";
#else
	const char* optMode = "Release build";
#endif

    if (sUseOpenGL2 )
    {
		char title[1024];
		sprintf(title,"%s using limited OpenGL2 fallback. %s", appTitle,optMode);
        s_app = new SimpleOpenGL2App(title,width,height);
        s_app->m_renderer = new SimpleOpenGL2Renderer(width,height);
    } 

#ifndef NO_OPENGL3
	else
    {
		char title[1024];
		sprintf(title,"%s using OpenGL3+. %s", appTitle,optMode);
        simpleApp = new SimpleOpenGL3App(title,width,height, gAllowRetina);
        s_app = simpleApp;
    }
#endif
	m_internalData->m_app = s_app;
    char* gVideoFileName = 0;
    args.GetCmdLineArgument("mp4",gVideoFileName);
   #ifndef NO_OPENGL3 
    if (gVideoFileName)
        simpleApp->dumpFramesToVideo(gVideoFileName);
   #endif 
   
    s_instancingRenderer = s_app->m_renderer;
    s_window  = s_app->m_window;

    width = s_window->getWidth();
    height = s_window->getHeight();
    
	prevMouseMoveCallback  = s_window->getMouseMoveCallback();
	s_window->setMouseMoveCallback(MyMouseMoveCallback);
	
	prevMouseButtonCallback = s_window->getMouseButtonCallback();
	s_window->setMouseButtonCallback(MyMouseButtonCallback);
	prevKeyboardCallback = s_window->getKeyboardCallback();
	s_window->setKeyboardCallback(MyKeyboardCallback);

	s_app->m_renderer->getActiveCamera()->setCameraDistance(13);
	s_app->m_renderer->getActiveCamera()->setCameraPitch(0);
	s_app->m_renderer->getActiveCamera()->setCameraTargetPosition(0,0,0);

	float mouseMoveMult= s_app->getMouseMoveMultiplier();
	if (args.GetCmdLineArgument("mouse_move_multiplier", mouseMoveMult))
	{
		s_app->setMouseMoveMultiplier(mouseMoveMult);
	}

	
	float mouseWheelMult= s_app->getMouseWheelMultiplier();
	if (args.GetCmdLineArgument("mouse_wheel_multiplier",mouseWheelMult))
	{
		s_app->setMouseWheelMultiplier(mouseWheelMult);
	}

	
	args.GetCmdLineArgument("shared_memory_key", gSharedMemoryKey);
								
	float red,green,blue;
	s_app->getBackgroundColor(&red,&green,&blue);
	args.GetCmdLineArgument("background_color_red",red);
	args.GetCmdLineArgument("background_color_green",green);
	args.GetCmdLineArgument("background_color_blue",blue);
	s_app->setBackgroundColor(red,green,blue);

	b3SetCustomWarningMessageFunc(MyGuiPrintf);
	b3SetCustomPrintfFunc(MyGuiPrintf);
	b3SetCustomErrorMessageFunc(MyStatusBarError);
	
	

    assert(glGetError()==GL_NO_ERROR);
	
	{
		GL3TexLoader* myTexLoader = new GL3TexLoader;
		m_internalData->m_myTexLoader = myTexLoader;

		
		if (sUseOpenGL2)
		{
			m_internalData->m_gwenRenderer = new Gwen::Renderer::OpenGL_DebugFont();
		}
#ifndef NO_OPENGL3
		else
		{
			sth_stash* fontstash = simpleApp->getFontStash();
			m_internalData->m_gwenRenderer = new GwenOpenGL3CoreRenderer(simpleApp->m_primRenderer, fontstash, width, height, s_window->getRetinaScale(), myTexLoader);
		}
#endif

		gui2 = new GwenUserInterface;
		
		m_internalData->m_gui = gui2;
		
		m_internalData->m_myTexLoader = myTexLoader;


		
		gui2->init(width, height, m_internalData->m_gwenRenderer, s_window->getRetinaScale());
		
		
	}
	//gui = 0;// new GwenUserInterface;
	
	GL3TexLoader* myTexLoader = m_internalData->m_myTexLoader;
	// = myTexLoader;
    
    
 
	//

	if (gui2)
	{
		




		//	gui->getInternalData()->m_explorerPage
		Gwen::Controls::TreeControl* tree = gui2->getInternalData()->m_explorerTreeCtrl;


		//gui->getInternalData()->pRenderer->setTextureLoader(myTexLoader);

#ifndef BT_NO_PROFILE
		s_profWindow= setupProfileWindow(gui2->getInternalData());
		m_internalData->m_profWindow = s_profWindow;
		profileWindowSetVisible(s_profWindow,false);
#endif //BT_NO_PROFILE
		gui2->setFocus();

		s_parameterInterface = s_app->m_parameterInterface = new GwenParameterInterface(gui2->getInternalData());
		s_app->m_2dCanvasInterface = new QuickCanvas(myTexLoader);
	

	///add some demos to the gAllExamples

    
	int numDemos = gAllExamples->getNumRegisteredExamples();

	//char nodeText[1024];
	//int curDemo = 0;
	int selectedDemo = 0;
	Gwen::Controls::TreeNode* curNode = tree;
	m_internalData->m_handler2 = new MyMenuItemHander(-1);

	char* demoNameFromCommandOption = 0;
	args.GetCmdLineArgument("start_demo_name", demoNameFromCommandOption);
	if (demoNameFromCommandOption) {
		selectedDemo = -1;
	}

	tree->onReturnKeyDown.Add(m_internalData->m_handler2, &MyMenuItemHander::onButtonD);
	int firstAvailableDemoIndex=-1;
	Gwen::Controls::TreeNode* firstNode=0;

	for (int d = 0; d<numDemos; d++)
	{
//		sprintf(nodeText, "Node %d", i);
		Gwen::UnicodeString nodeUText = Gwen::Utility::StringToUnicode(gAllExamples->getExampleName(d));
		if (gAllExamples->getExampleCreateFunc(d))//was test for gAllExamples[d].m_menuLevel==1
		{
			Gwen::Controls::TreeNode* pNode = curNode->AddNode(nodeUText);
			
			if (firstAvailableDemoIndex<0)
			{
				firstAvailableDemoIndex = d;
				firstNode = pNode;
			}
			
			if (d == selectedDemo)
			{
				firstAvailableDemoIndex = d;
				firstNode = pNode;
				//pNode->SetSelected(true);
				//tree->ExpandAll();
			//	tree->ForceUpdateScrollBars();
			//tree->OnKeyLeft(true);
		//	tree->OnKeyRight(true);
			
			
			//tree->ExpandAll();

			//	selectDemo(d);


			}
			
			if (demoNameFromCommandOption )
			{
				const char* demoName = gAllExamples->getExampleName(d);
				int res = strcmp(demoName, demoNameFromCommandOption);
				if (res==0)
				{
					firstAvailableDemoIndex = d;
					firstNode = pNode;
				}
			}

#if 1
			MyMenuItemHander* handler = new MyMenuItemHander(d);
			m_internalData->m_handlers.push_back(handler);
			
			pNode->onNamePress.Add(handler, &MyMenuItemHander::onButtonA);
			pNode->GetButton()->onDoubleClick.Add(handler, &MyMenuItemHander::onButtonB);
			pNode->GetButton()->onDown.Add(handler, &MyMenuItemHander::onButtonC);
			pNode->onSelect.Add(handler, &MyMenuItemHander::onButtonE);
			pNode->onReturnKeyDown.Add(handler, &MyMenuItemHander::onButtonG);
			pNode->onSelectChange.Add(handler, &MyMenuItemHander::onButtonF);
			
#endif
//			pNode->onKeyReturn.Add(handler, &MyMenuItemHander::onButtonD);
//			pNode->GetButton()->onKeyboardReturn.Add(handler, &MyMenuItemHander::onButtonD);
	//		pNode->onNamePress.Add(handler, &MyMenuItemHander::onButtonD);
//			pNode->onKeyboardPressed.Add(handler, &MyMenuItemHander::onButtonD);
//			pNode->OnKeyPress
		}
		 else
		 {
			 curNode = tree->AddNode(nodeUText);
			 m_internalData->m_nodes.push_back(curNode);
		 }
	}

	if (sCurrentDemo==0)
	{
		if (firstAvailableDemoIndex>=0)
		{
			firstNode->SetSelected(true);
			while (firstNode != tree)
			{
				firstNode->ExpandAll();
				firstNode = (Gwen::Controls::TreeNode*)firstNode->GetParent();
			}
			
			selectDemo(firstAvailableDemoIndex);
		}

	}
	free(demoNameFromCommandOption);
	demoNameFromCommandOption = 0;

	btAssert(sCurrentDemo!=0);
	if (sCurrentDemo==0)
	{
		printf("Error, no demo/example\n");
		exit(0);
	}
	
    gui2->registerFileOpenCallback(fileOpenCallback);
	gui2->registerQuitCallback(quitCallback);
   }


	return true;
}
void	GwenUserInterface::init(int width, int height,Gwen::Renderer::Base* renderer,float retinaScale)
{
	m_data->m_curYposition = 20;
	//m_data->m_primRenderer = new GLPrimitiveRenderer(width,height);
	m_data->pRenderer = renderer;//new GwenOpenGL3CoreRenderer(m_data->m_primRenderer,stash,width,height,retinaScale);

	m_data->skin.SetRender( m_data->pRenderer );
	

	m_data->pCanvas= new Gwen::Controls::Canvas( &m_data->skin );
	m_data->pCanvas->SetSize( width,height);
	m_data->pCanvas->SetDrawBackground( false);
	m_data->pCanvas->SetBackgroundColor( Gwen::Color( 150, 170, 170, 255 ) );
	
	
	
	MyTestMenuBar* menubar = new MyTestMenuBar(m_data->pCanvas);
	m_data->m_viewMenu = menubar->m_viewMenu;
    m_data->m_menuItems = menubar->m_menuItems;
	m_data->m_menubar = menubar;
	
	
    
	Gwen::Controls::StatusBar* bar = new Gwen::Controls::StatusBar(m_data->pCanvas);
	m_data->m_bar = bar;
	

	m_data->m_rightStatusBar = new Gwen::Controls::Label( bar );
	
	m_data->m_rightStatusBar->SetWidth(width/2);
	//m_data->m_rightStatusBar->SetText( L"Label Added to Right" );
	bar->AddControl( m_data->m_rightStatusBar, true );
	
	m_data->m_TextOutput = new Gwen::Controls::ListBox( m_data->pCanvas );
	
	m_data->m_TextOutput->Dock( Gwen::Pos::Bottom );
	m_data->m_TextOutput->SetHeight( 100 );
	
	m_data->m_leftStatusBar = new Gwen::Controls::Label( bar );
	
	//m_data->m_leftStatusBar->SetText( L"Label Added to Left" );
	m_data->m_leftStatusBar->SetWidth(width/2);
	bar->AddControl( m_data->m_leftStatusBar,false);
	
	//Gwen::KeyboardFocus
	/*Gwen::Controls::GroupBox* box = new Gwen::Controls::GroupBox(m_data->pCanvas);
	box->SetText("text");
	box->SetName("name");
	box->SetHeight(500);
	*/
	Gwen::Controls::ScrollControl* windowRight= new Gwen::Controls::ScrollControl(m_data->pCanvas);
	windowRight->Dock(Gwen::Pos::Right);
	windowRight->SetWidth(250);
	windowRight->SetHeight(250);
	windowRight->SetScroll(false,true);
	m_data->m_windowRight = windowRight;


	//windowLeft->SetSkin(
	Gwen::Controls::TabControl* tab = new Gwen::Controls::TabControl(windowRight);
	m_data->m_tab = tab;

	

	//tab->SetHeight(300);
	tab->SetWidth(240);
	tab->SetHeight(1250);
	//tab->Dock(Gwen::Pos::Left);
	tab->Dock( Gwen::Pos::Fill );
	//tab->SetMargin( Gwen::Margin( 2, 2, 2, 2 ) );

	Gwen::UnicodeString str1(L"Params");
	m_data->m_demoPage = tab->AddPage(str1);
	
	



//	Gwen::UnicodeString str2(L"OpenCL");
//	tab->AddPage(str2);
	//Gwen::UnicodeString str3(L"page3");
//	tab->AddPage(str3);



	//but->onPress.Add(handler, &MyHander::onButtonA);



	//box->Dock(Gwen::Pos::Left);

	/*Gwen::Controls::WindowControl* windowBottom = new Gwen::Controls::WindowControl(m_data->pCanvas);
	windowBottom->SetHeight(100);
	windowBottom->Dock(Gwen::Pos::Bottom);
	windowBottom->SetTitle("bottom");
	*/
//	Gwen::Controls::Property::Text* prop = new Gwen::Controls::Property::Text(m_data->pCanvas);
	//prop->Dock(Gwen::Pos::Bottom);
	/*Gwen::Controls::SplitterBar* split = new Gwen::Controls::SplitterBar(m_data->pCanvas);
	split->Dock(Gwen::Pos::Center);
	split->SetHeight(300);
	split->SetWidth(300);
	*/
	/*


	*/

	Gwen::Controls::ScrollControl* windowLeft = new Gwen::Controls::ScrollControl(m_data->pCanvas);
	windowLeft->Dock(Gwen::Pos::Left);
	//	windowLeft->SetTitle("title");
	windowLeft->SetScroll(false, false);
	windowLeft->SetWidth(250);
	windowLeft->SetPos(50, 50);
	windowLeft->SetHeight(500);
	//windowLeft->SetClosable(false);
	//	windowLeft->SetShouldDrawBackground(true);
	windowLeft->SetTabable(true);
	
	Gwen::Controls::TabControl* explorerTab = new Gwen::Controls::TabControl(windowLeft);

	//tab->SetHeight(300);
//	explorerTab->SetWidth(230);
	explorerTab->SetHeight(250);
	//tab->Dock(Gwen::Pos::Left);
	explorerTab->Dock(Gwen::Pos::Fill);

	



	//m_data->m_exampleInfoTextOutput->SetBounds(2, 10, 236, 400);

	//windowRight

	Gwen::UnicodeString explorerStr1(L"Explorer");
	m_data->m_explorerPage = explorerTab->AddPage(explorerStr1);
	Gwen::UnicodeString shapesStr1(L"Test");
	Gwen::Controls::TabButton* shapes = explorerTab->AddPage(shapesStr1);

	///todo(erwincoumans) figure out why the HSV color picker is extremely slow
	//Gwen::Controls::HSVColorPicker* color = new Gwen::Controls::HSVColorPicker(shapes->GetPage());
	Gwen::Controls::ColorPicker* color = new Gwen::Controls::ColorPicker(shapes->GetPage());
	color->SetKeyboardInputEnabled(true);
	
	Gwen::Controls::TreeControl* ctrl = new Gwen::Controls::TreeControl(m_data->m_explorerPage->GetPage());
	m_data->m_explorerTreeCtrl = ctrl;
	ctrl->SetKeyboardInputEnabled(true);
	ctrl->Focus();
	ctrl->SetBounds(2, 10, 236, 300);

	m_data->m_exampleInfoGroupBox = new Gwen::Controls::Label( m_data->m_explorerPage->GetPage() );
	m_data->m_exampleInfoGroupBox->SetPos(2, 314);
	m_data->m_exampleInfoGroupBox->SetHeight( 15 );
	m_data->m_exampleInfoGroupBox->SetWidth(234);
	m_data->m_exampleInfoGroupBox->SetText("Example Description");

	m_data->m_exampleInfoTextOutput = new Gwen::Controls::ListBox(m_data->m_explorerPage->GetPage());

	//m_data->m_exampleInfoTextOutput->Dock( Gwen::Pos::Bottom );
	m_data->m_exampleInfoTextOutput->SetPos(2, 332);
	m_data->m_exampleInfoTextOutput->SetHeight( 150 );
	m_data->m_exampleInfoTextOutput->SetWidth(233);
	

   
}
void	GwenUserInterface::init(int width, int height,struct sth_stash* stash,float retinaScale)
{
	m_data->m_curYposition = 20;
	m_data->m_primRenderer = new GLPrimitiveRenderer(width,height);
	m_data->pRenderer = new GwenOpenGL3CoreRenderer(m_data->m_primRenderer,stash,width,height,retinaScale);

	m_data->skin.SetRender( m_data->pRenderer );

	m_data->pCanvas= new Gwen::Controls::Canvas( &m_data->skin );
	m_data->pCanvas->SetSize( width,height);
	m_data->pCanvas->SetDrawBackground( false);
	m_data->pCanvas->SetBackgroundColor( Gwen::Color( 150, 170, 170, 255 ) );

	MyTestMenuBar* menubar = new MyTestMenuBar(m_data->pCanvas);
	Gwen::Controls::StatusBar* bar = new Gwen::Controls::StatusBar(m_data->pCanvas);
	m_data->m_rightStatusBar = new Gwen::Controls::Label( bar );
	m_data->m_rightStatusBar->SetWidth(width/2);
	//m_data->m_rightStatusBar->SetText( L"Label Added to Right" );
	bar->AddControl( m_data->m_rightStatusBar, true );

	m_data->m_leftStatusBar = new Gwen::Controls::Label( bar );
	//m_data->m_leftStatusBar->SetText( L"Label Added to Left" );
	m_data->m_leftStatusBar->SetWidth(width/2);
	bar->AddControl( m_data->m_leftStatusBar,false);
	//Gwen::KeyboardFocus
	/*Gwen::Controls::GroupBox* box = new Gwen::Controls::GroupBox(m_data->pCanvas);
	box->SetText("text");
	box->SetName("name");
	box->SetHeight(500);
	*/
	Gwen::Controls::ScrollControl* windowRight= new Gwen::Controls::ScrollControl(m_data->pCanvas);
	windowRight->Dock(Gwen::Pos::Right);
	windowRight->SetWidth(150);
	windowRight->SetHeight(250);
	windowRight->SetScroll(false,true);



	//windowLeft->SetSkin(
	Gwen::Controls::TabControl* tab = new Gwen::Controls::TabControl(windowRight);
	
	//tab->SetHeight(300);
	tab->SetWidth(140);
	tab->SetHeight(250);
	//tab->Dock(Gwen::Pos::Left);
	tab->Dock( Gwen::Pos::Fill );
	//tab->SetMargin( Gwen::Margin( 2, 2, 2, 2 ) );

	Gwen::UnicodeString str1(L"Main");
	m_data->m_demoPage = tab->AddPage(str1);

	

	
//	Gwen::UnicodeString str2(L"OpenCL");
//	tab->AddPage(str2);
	//Gwen::UnicodeString str3(L"page3");
//	tab->AddPage(str3);
	
		
	
	//but->onPress.Add(handler, &MyHander::onButtonA);

	
	
	//box->Dock(Gwen::Pos::Left);

	/*Gwen::Controls::WindowControl* windowBottom = new Gwen::Controls::WindowControl(m_data->pCanvas);
	windowBottom->SetHeight(100);
	windowBottom->Dock(Gwen::Pos::Bottom);
	windowBottom->SetTitle("bottom");
	*/
//	Gwen::Controls::Property::Text* prop = new Gwen::Controls::Property::Text(m_data->pCanvas);
	//prop->Dock(Gwen::Pos::Bottom);
	/*Gwen::Controls::SplitterBar* split = new Gwen::Controls::SplitterBar(m_data->pCanvas);
	split->Dock(Gwen::Pos::Center);
	split->SetHeight(300);
	split->SetWidth(300);
	*/
	/*
	
	
	*/

	Gwen::Controls::ScrollControl* windowLeft = new Gwen::Controls::ScrollControl(m_data->pCanvas);
	windowLeft->Dock(Gwen::Pos::Left);
	//	windowLeft->SetTitle("title");
	windowLeft->SetScroll(false, false);
	windowLeft->SetWidth(250);
	windowLeft->SetPos(50, 50);
	windowLeft->SetHeight(500);
	//windowLeft->SetClosable(false);
	//	windowLeft->SetShouldDrawBackground(true);
	windowLeft->SetTabable(true);

	Gwen::Controls::TabControl* explorerTab = new Gwen::Controls::TabControl(windowLeft);

	//tab->SetHeight(300);
//	explorerTab->SetWidth(230);
	explorerTab->SetHeight(250);
	//tab->Dock(Gwen::Pos::Left);
	explorerTab->Dock(Gwen::Pos::Fill);

	Gwen::UnicodeString explorerStr1(L"Explorer");
	m_data->m_explorerPage = explorerTab->AddPage(explorerStr1);
	Gwen::UnicodeString shapesStr1(L"Shapes");
	explorerTab->AddPage(shapesStr1);
	Gwen::UnicodeString testStr1(L"Test");
	explorerTab->AddPage(testStr1);

	Gwen::Controls::TreeControl* ctrl = new Gwen::Controls::TreeControl(m_data->m_explorerPage->GetPage());
	m_data->m_explorerTreeCtrl = ctrl;
	ctrl->SetKeyboardInputEnabled(true);
	ctrl->Focus();
	ctrl->SetBounds(2, 10, 236, 400);

}
Exemple #7
0
int main(int argc, char* argv[])
{
    shadowMapWorldSize = 25;

	b3Clock clock;

	float dt = 1./120.f;
	int width = 1024;
	int height=768;

	app = new SimpleOpenGL3App("AllBullet2Demos",width,height);
	app->m_instancingRenderer->setCameraDistance(13);
	app->m_instancingRenderer->setCameraPitch(0);
	app->m_instancingRenderer->setCameraTargetPosition(b3MakeVector3(0,0,0));
	app->m_window->setMouseMoveCallback(MyMouseMoveCallback);
	app->m_window->setMouseButtonCallback(MyMouseButtonCallback);
	app->m_window->setKeyboardCallback(MyKeyboardCallback);
	

	GLint err = glGetError();
    assert(err==GL_NO_ERROR);

	sth_stash* fontstash=app->getFontStash();
	gui = new GwenUserInterface;
	gui->init(width,height,fontstash,app->m_window->getRetinaScale());
//	gui->getInternalData()->m_explorerPage
	Gwen::Controls::TreeControl* tree = gui->getInternalData()->m_explorerTreeCtrl;

	
	
	app->m_parameterInterface = new GwenParameterInterface(gui->getInternalData());

	//gui->getInternalData()->m_demoPage;

	int numDemos = sizeof(allDemos)/sizeof(BulletDemoEntry);

	char nodeText[1024];
	int curDemo = 0;
	int selectedDemo = loadCurrentDemoEntry(startFileName);
	Gwen::Controls::TreeNode* curNode = tree;
	MyMenuItemHander* handler2 = new MyMenuItemHander(-1);

	tree->onReturnKeyDown.Add(handler2, &MyMenuItemHander::onButtonD);

	for (int d = 0; d<numDemos; d++)
	{
//		sprintf(nodeText, "Node %d", i);
		Gwen::UnicodeString nodeUText = Gwen::Utility::StringToUnicode(allDemos[d].m_name);
		if (allDemos[d].m_menuLevel==1)
		{
			Gwen::Controls::TreeNode* pNode = curNode->AddNode(nodeUText);
			if (d == selectedDemo)
			{
				pNode->SetSelected(true);
				tree->ExpandAll();
				selectDemo(d);


			}
			MyMenuItemHander* handler = new MyMenuItemHander(d);
			pNode->onNamePress.Add(handler, &MyMenuItemHander::onButtonA);
			pNode->GetButton()->onDoubleClick.Add(handler, &MyMenuItemHander::onButtonB);
			pNode->GetButton()->onDown.Add(handler, &MyMenuItemHander::onButtonC);
			pNode->onSelect.Add(handler, &MyMenuItemHander::onButtonE);
			pNode->onReturnKeyDown.Add(handler, &MyMenuItemHander::onButtonG);
			pNode->onSelectChange.Add(handler, &MyMenuItemHander::onButtonF);
//			pNode->onKeyReturn.Add(handler, &MyMenuItemHander::onButtonD);
//			pNode->GetButton()->onKeyboardReturn.Add(handler, &MyMenuItemHander::onButtonD);
	//		pNode->onNamePress.Add(handler, &MyMenuItemHander::onButtonD);
//			pNode->onKeyboardPressed.Add(handler, &MyMenuItemHander::onButtonD);
//			pNode->OnKeyPress
		}
		 else
		 {
			 curNode = tree->AddNode(nodeUText);
		 }
	}

/*	for (int i=0;i<numDemos;i++)
	{
		allNames.push_back(allDemos[i].m_name);
	}
	*/
	//selectDemo(loadCurrentDemoEntry(startFileName));
	/*
	gui->registerComboBox(DEMO_SELECTION_COMBOBOX,allNames.size(),&allNames[0],sCurrentDemoIndex);

	//const char* names2[] = {"comboF", "comboG","comboH"};
	//gui->registerComboBox(2,3,&names2[0],0);

	gui->setComboBoxCallback(MyComboBoxCallback);
	*/
	unsigned long int	prevTimeInMicroseconds = clock.getTimeMicroseconds();

	
	do
	{

		GLint err = glGetError();
		assert(err==GL_NO_ERROR);
		app->m_instancingRenderer->init();
        DrawGridData dg;
        dg.upAxis = app->getUpAxis();
		
		app->m_instancingRenderer->updateCamera(dg.upAxis);
        app->drawGrid(dg);

		static int frameCount = 0;
		frameCount++;

		if (0)
		{
		char bla[1024];

		sprintf(bla,"Simple test frame %d", frameCount);

		app->drawText(bla,10,10);
		}

		if (sCurrentDemo)
		{
			if (!pauseSimulation)
			{
				unsigned long int	curTimeInMicroseconds = clock.getTimeMicroseconds();
				unsigned long int diff = curTimeInMicroseconds-prevTimeInMicroseconds;
				float deltaTimeInSeconds = (diff)*1.e-6;
				//printf("---------------------------------------------------\n");
				//printf("Framecount = %d\n",frameCount);

				sCurrentDemo->stepSimulation(deltaTimeInSeconds);//1./60.f);
				prevTimeInMicroseconds = curTimeInMicroseconds;
			}
			sCurrentDemo->renderScene();
			sCurrentDemo->physicsDebugDraw();
		}

		static int toggle = 1;
		if (1)
		{
		gui->draw(app->m_instancingRenderer->getScreenWidth(),app->m_instancingRenderer->getScreenHeight());
		}
		toggle=1-toggle;
		app->m_parameterInterface->syncParameters();
		app->swapBuffer();
	} while (!app->m_window->requestedExit());

//	selectDemo(0);
	delete gui;
	delete app;
	return 0;
}
Exemple #8
0
	GWEN_CONTROL_INLINE( TreeControl, GUnit )
	{
		{
			Gwen::Controls::TreeControl* ctrl = new Gwen::Controls::TreeControl( this );

			ctrl->AddNode( L"Node One" );
			Gwen::Controls::TreeNode* pNode = ctrl->AddNode( L"Node Two" );
			pNode->AddNode( L"Node Two Inside" );
			pNode->AddNode( L"Eyes" );
			pNode->AddNode( L"Brown" )->AddNode( L"Node Two Inside" )->AddNode( L"Eyes" )->AddNode( L"Brown" );
			pNode->AddNode( L"More" );
			pNode->AddNode( L"Nodes" );
			ctrl->AddNode( L"Node Three" );

			ctrl->SetBounds( 30, 30, 200, 200 );
			ctrl->ExpandAll();
		}

		{
			Gwen::Controls::TreeControl* ctrl = new Gwen::Controls::TreeControl( this );

			ctrl->AllowMultiSelect( true );

			ctrl->AddNode( L"Node One" );
			Gwen::Controls::TreeNode* pNode = ctrl->AddNode( L"Node Two" );
			pNode->AddNode( L"Node Two Inside" );
			pNode->AddNode( L"Eyes" );
			Gwen::Controls::TreeNode* pNodeTwo = pNode->AddNode( L"Brown" )->AddNode( L"Node Two Inside" )->AddNode( L"Eyes" );
			pNodeTwo->AddNode( L"Brown" );
			pNodeTwo->AddNode( L"Green" );
			pNodeTwo->AddNode( L"Slime" );
			pNodeTwo->AddNode( L"Grass" );
			pNodeTwo->AddNode( L"Pipe" );
			pNode->AddNode( L"More" );
			pNode->AddNode( L"Nodes" );

			ctrl->AddNode( L"Node Three" );

			ctrl->SetBounds( 240, 30, 200, 200 );
			ctrl->ExpandAll();
		}
	}
Exemple #9
0
int main(int argc, char* argv[])
{
    shadowMapWorldSize = 25;

	b3Clock clock;

	//float dt = 1./120.f;
    int width = 1024;
    int height=768;

	//	wci.m_resizeCallback = MyResizeCallback;

    SimpleOpenGL3App* simpleApp=0;
    bool useOpenGL2=false;
    if (useOpenGL2)
    {
        app = new SimpleOpenGL2App("AllBullet2Demos",width,height);
        app->m_renderer = new SimpleOpenGL2Renderer(width,height);
    } else
    {
        simpleApp = new SimpleOpenGL3App("AllBullet2Demos",width,height);
        app = simpleApp;
    }
    
    s_instancingRenderer = app->m_renderer;
	s_window  = app->m_window;
	prevMouseMoveCallback  = s_window->getMouseMoveCallback();
	s_window->setMouseMoveCallback(MyMouseMoveCallback);
	
	prevMouseButtonCallback = s_window->getMouseButtonCallback();
	s_window->setMouseButtonCallback(MyMouseButtonCallback);
	prevKeyboardCallback = s_window->getKeyboardCallback();
	s_window->setKeyboardCallback(MyKeyboardCallback);

	app->m_renderer->setCameraDistance(13);
	app->m_renderer->setCameraPitch(0);
	app->m_renderer->setCameraTargetPosition(0,0,0);

	b3SetCustomWarningMessageFunc(MyStatusBarWarning);
	b3SetCustomPrintfFunc(MyStatusBarPrintf);
	

	/*
	SimpleOpenGL3App* app = new SimpleOpenGL3App("AllBullet2Demos",width,height);
	s_instancingRenderer->setCameraDistance(13);
	s_instancingRenderer->setCameraPitch(0);
	s_instancingRenderer->setCameraTargetPosition(0,0,0);
	s_window->setMouseMoveCallback(MyMouseMoveCallback);
	s_window->setMouseButtonCallback(MyMouseButtonCallback);
	s_window->setKeyboardCallback(MyKeyboardCallback);
	
	*/
    assert(glGetError()==GL_NO_ERROR);

	

	gui = new GwenUserInterface;
	GL3TexLoader* myTexLoader = new GL3TexLoader;
    
    Gwen::Renderer::Base* gwenRenderer = 0;
    if (useOpenGL2)
    {
        gwenRenderer = new Gwen::Renderer::OpenGL_DebugFont();
    } else
    {
        sth_stash* fontstash=simpleApp->getFontStash();
        gwenRenderer = new GwenOpenGL3CoreRenderer(simpleApp->m_primRenderer,fontstash,width,height,s_window->getRetinaScale(),myTexLoader);
    }
	//

	gui->init(width,height,gwenRenderer,s_window->getRetinaScale());
//	gui->getInternalData()->m_explorerPage
	Gwen::Controls::TreeControl* tree = gui->getInternalData()->m_explorerTreeCtrl;

	
	//gui->getInternalData()->pRenderer->setTextureLoader(myTexLoader);

	
	MyProfileWindow* profWindow = setupProfileWindow(gui->getInternalData());
	profileWindowSetVisible(profWindow,false);
	gui->setFocus();
#if 0
	{
		MyGraphInput input(gui->getInternalData());
		input.m_width=300;
		input.m_height=300;
		input.m_xPos = 0;
		input.m_yPos = height-input.m_height;
		input.m_name="Test Graph1";
		input.m_texName = "graph1";
		GraphingTexture* gt = new GraphingTexture;
		gt->create(256,256);
		int texId = gt->getTextureId();
		myTexLoader->m_hashMap.insert("graph1", texId);
		//MyGraphWindow* gw = 
		setupTextureWindow(input);
	}
	if (1)
	{
		MyGraphInput input(gui->getInternalData());
		input.m_width=300;
		input.m_height=300;
		input.m_xPos = width-input.m_width;
		input.m_yPos = height-input.m_height;
		input.m_name="Test Graph2";
		input.m_texName = "graph2";
		GraphingTexture* gt = new GraphingTexture;
		int texWidth = 512;
		int texHeight = 512;
		gt->create(texWidth,texHeight);
		for (int i=0;i<texWidth;i++)
		{
			for (int j=0;j<texHeight;j++)
			{
				gt->setPixel(i,j,0,0,0,255);
			}
		}
		gt->uploadImageData();
		
		int texId = gt->getTextureId();
		input.m_xPos = width-input.m_width;
		myTexLoader->m_hashMap.insert("graph2", texId);
		//MyGraphWindow* gw = 
		setupTextureWindow(input);
	}
	//destroyTextureWindow(gw);
#endif 
	s_parameterInterface  = app->m_parameterInterface = new GwenParameterInterface(gui->getInternalData());
	app->m_2dCanvasInterface = new QuickCanvas(myTexLoader);

	//gui->getInternalData()->m_demoPage;

	int numDemos = sizeof(allDemos)/sizeof(BulletDemoEntry);

	//char nodeText[1024];
	//int curDemo = 0;
	int selectedDemo = loadCurrentDemoEntry(startFileName);
	Gwen::Controls::TreeNode* curNode = tree;
	MyMenuItemHander* handler2 = new MyMenuItemHander(-1);

	tree->onReturnKeyDown.Add(handler2, &MyMenuItemHander::onButtonD);

	for (int d = 0; d<numDemos; d++)
	{
//		sprintf(nodeText, "Node %d", i);
		Gwen::UnicodeString nodeUText = Gwen::Utility::StringToUnicode(allDemos[d].m_name);
		if (allDemos[d].m_menuLevel==1)
		{
			Gwen::Controls::TreeNode* pNode = curNode->AddNode(nodeUText);
			if (d == selectedDemo)
			{
				pNode->SetSelected(true);
				tree->ExpandAll();
				selectDemo(d);


			}
			MyMenuItemHander* handler = new MyMenuItemHander(d);
			pNode->onNamePress.Add(handler, &MyMenuItemHander::onButtonA);
			pNode->GetButton()->onDoubleClick.Add(handler, &MyMenuItemHander::onButtonB);
			pNode->GetButton()->onDown.Add(handler, &MyMenuItemHander::onButtonC);
			pNode->onSelect.Add(handler, &MyMenuItemHander::onButtonE);
			pNode->onReturnKeyDown.Add(handler, &MyMenuItemHander::onButtonG);
			pNode->onSelectChange.Add(handler, &MyMenuItemHander::onButtonF);
//			pNode->onKeyReturn.Add(handler, &MyMenuItemHander::onButtonD);
//			pNode->GetButton()->onKeyboardReturn.Add(handler, &MyMenuItemHander::onButtonD);
	//		pNode->onNamePress.Add(handler, &MyMenuItemHander::onButtonD);
//			pNode->onKeyboardPressed.Add(handler, &MyMenuItemHander::onButtonD);
//			pNode->OnKeyPress
		}
		 else
		 {
			 curNode = tree->AddNode(nodeUText);
		 }
	}

/*	for (int i=0;i<numDemos;i++)
	{
		allNames.push_back(allDemos[i].m_name);
	}
	*/
	//selectDemo(loadCurrentDemoEntry(startFileName));
	/*
	gui->registerComboBox(DEMO_SELECTION_COMBOBOX,allNames.size(),&allNames[0],sCurrentDemoIndex);

	//const char* names2[] = {"comboF", "comboG","comboH"};
	//gui->registerComboBox(2,3,&names2[0],0);

	gui->setComboBoxCallback(MyComboBoxCallback);
	*/
	unsigned long int	prevTimeInMicroseconds = clock.getTimeMicroseconds();

    gui->registerFileOpenCallback(fileOpenCallback);
    
	do
	{

		assert(glGetError()==GL_NO_ERROR);
		s_instancingRenderer->init();
        DrawGridData dg;
        dg.upAxis = app->getUpAxis();

        {
            BT_PROFILE("Update Camera");
            s_instancingRenderer->updateCamera(dg.upAxis);
        }

		if (renderGrid)
        {
            BT_PROFILE("Draw Grid");
            app->drawGrid(dg);
        }
		static int frameCount = 0;
		frameCount++;

		if (0)
		{
            BT_PROFILE("Draw frame counter");
            char bla[1024];
            sprintf(bla,"Frame %d", frameCount);
            app->drawText(bla,10,10);
		}

		if (sCurrentDemo)
		{
			if (!pauseSimulation)
			{
				unsigned long int	curTimeInMicroseconds = clock.getTimeMicroseconds();
				unsigned long int diff = curTimeInMicroseconds-prevTimeInMicroseconds;
				float deltaTimeInSeconds = (diff)*1.e-6;
				//printf("---------------------------------------------------\n");
				//printf("Framecount = %d\n",frameCount);

				sCurrentDemo->stepSimulation(deltaTimeInSeconds);//1./60.f);
				prevTimeInMicroseconds = curTimeInMicroseconds;
			}
			
			if (renderVisualGeometry)
            {
				if (visualWireframe)
				{
					glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
				}
                BT_PROFILE("Render Scene");
                sCurrentDemo->renderScene();
            }
            {
				glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
                sCurrentDemo->physicsDebugDraw(gDebugDrawFlags);
            }
		}

		static int toggle = 1;
		if (1)
		{
            if (!pauseSimulation)
                processProfileData(profWindow,false);
            {
                if (useOpenGL2)
				{
					saveOpenGLState(width,height);
				}
                BT_PROFILE("Draw Gwen GUI");
                gui->draw(s_instancingRenderer->getScreenWidth(),s_instancingRenderer->getScreenHeight());
                if (useOpenGL2)
                {
                    restoreOpenGLState();
                }
            }
		}
		toggle=1-toggle;
        {
            BT_PROFILE("Sync Parameters");
            s_parameterInterface->syncParameters();
        }
        {
            BT_PROFILE("Swap Buffers");
            app->swapBuffer();
        }

		gui->forceUpdateScrollBars();
	} while (!s_window->requestedExit());

//	selectDemo(0);
	delete gui;
	delete app;
	return 0;
}