Ejemplo n.º 1
0
//屏触响应
//int32 TestBox2DLite_MouseEvent( E_Mex_MouseEvent eEvent, int16 iPosX, int16 iPosY )
iS32 TestBox2DLite_MouseEvent(i51InputStruct InputData)
{
    iU16 uWidth=240, uHeight=320;
	if( i51AdeMmiGetScreenScale ( &uWidth , &uHeight ) == 0 ) return iFALSE;
    if(InputData.type==i51_PEN_INPUT&&InputData.u.pen.type==i51_PEN_UP)
    {
        iU16 PenX = InputData.u.pen.x;
        iU16 PenY = InputData.u.pen.y;
	if(PenY<uHeight/4)
	{
		if(PenX<uWidth/3) InitDemo(1);
		else if( PenX<uWidth*2/3) InitDemo(2);
		else InitDemo(3);
	}
	else if(PenY<uHeight*2/4)
	{
		if(PenX<uWidth/3) InitDemo(4);
		else if( PenX<uWidth*2/3) InitDemo(5);
		else InitDemo(6);
	}
	else if(PenY<uHeight*3/4)
	{
		if(PenX<uWidth/3) InitDemo(7);
		else if( PenX<uWidth*2/3) InitDemo(8);
		else InitDemo(9);
	}
	else
	{
            LaunchBomb();
	}
    }
	return 1;
}
Ejemplo n.º 2
0
//按键响应
//int32 TestBox2DLite_KeyEvent(E_Mex_KeyEvent keyEvent, E_Mex_KeyCode keyCode)
iS32 TestBox2DLite_KeyEvent(void)
{
i51KEYS keyCode;
i51InputStruct InputData;
i51KitKeyInputQueueOut(KeyQueue, &InputData);
if(InputData.type==i51_KEY_INPUT&&InputData.u.key.type==i51_KEY_UP)
{
i51KEYS keyCode = InputData.u.key.value;
    switch ( keyCode )
    {
    case i51_KEY_NUM0:
        InitDemo(0);
        break;
    case i51_KEY_NUM1:
        InitDemo(1);
        break;
    case i51_KEY_NUM2:
        InitDemo(2);
        break;
    case i51_KEY_NUM3:
        InitDemo(3);
        break;
    case i51_KEY_NUM4:
        InitDemo(4);
        break;
    case i51_KEY_NUM5:
        InitDemo(5);
        break;
    case i51_KEY_NUM6:
        InitDemo(6);
        break;
    case i51_KEY_NUM7:
        InitDemo(7);
        break;
    case i51_KEY_NUM8:
        InitDemo(8);
        break;
    case i51_KEY_NUM9:
        InitDemo(9);
        break;
    case i51_KEY_ENTER:
        LaunchBomb();
        break;
    }
}

TestBox2DLite_MouseEvent(InputData);

    return 1;
}
Ejemplo n.º 3
0
void main(int argc, char** argv)
{
	InitDemo(0);
	
	viewNode = world._quadtree.root();

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
	glutInitWindowSize(800, 800);
	glutCreateWindow("Box2D");

	glutReshapeFunc(Reshape);
	glutDisplayFunc(SimulationLoop);
	glutKeyboardFunc(Keyboard);
	glutSpecialFunc(ArrowKeys);
	glutIdleFunc(SimulationLoop);
	glutMouseFunc(MouseFunc);
	glutPassiveMotionFunc(MouseMotion);

	glutMainLoop();
}
Ejemplo n.º 4
0
CairoGLRenderer::CairoGLRenderer(HWND hWnd, HDC hdc) : m_device (0), m_surface(0), m_cr(0), m_hdc(0)
{
   InitDemo(hWnd, hdc);
}
Ejemplo n.º 5
0
//
// Program starts here
//
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd) {	

	g_pHWND = CreateGameWindow();
	CreateD3DDevice();	
	

	MY_UI::DirectX11* renderer = new MY_UI::DirectX11( g_Device, g_DeviceContext );
	MY_UI::cRootWidget* root = new MY_UI::cRootWidget();
	MY_UI::cWidgetSkin* skin = new MY_UI::cWidgetSkin();
	//the MY_UI::Utilities::cInput input    class declared above will clean up MY UI on its destruction so you dont need to free any memory. You can explicitly call MY_UI::DeInit() if you want when the program is shutting down though
	MY_UI::Init(renderer, skin, root);
	MY_UI::Utilities::SetCursor(MY_UI::Utilities::Standard);
	RECT temp;
	GetClientRect( g_pHWND, &temp );
	root->SetSize(temp.right, temp.bottom);

	InitDemo();
	InitScene();

	//
	// Begin the main game loop
	//
	MY_UI::Controls::Text* fpscounter = new MY_UI::Controls::Text(root);
	fpscounter->SetFontSize(20);
	unsigned int framecount = 0;
	unsigned int lasttick = MY_UI::Utilities::GetTime();
	std::string fpsStr, FrameStats;

	MSG msg;
	while( true )
	{
		// Skip out if the window is closed
		if ( !IsWindowVisible( g_pHWND ) )
			break;

		// If we have a message from windows..
		if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
		{
			// if it's QUIT then quit..
			if ( msg.message == WM_QUIT )
				break;

			// Handle the regular window stuff..
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		else
		{
			// Normal DirectX rendering loop
				

				framecount++;
				if(MY_UI::Utilities::GetTime() -lasttick  >= 1000){// update
					float fps(static_cast<float>(framecount));
					float msec(1000.0f/fps);
					std::ostringstream outs1;   
					outs1.precision(4);
					outs1<<" FPS: "<<fps<<" MPF: "<<msec;
					fpsStr=outs1.str();
					lasttick=MY_UI::Utilities::GetTime();
					framecount=0;// reset
					std::ostringstream o;
					o<<"Draw Calls: "<<renderer->GetDrawCalls();
					fpscounter->SetText(fpsStr +o.str());
				}
				
	
				float ClearColor[4] = { .2f, .1f, 1.0f, 0.0f };
				
				g_DeviceContext->ClearRenderTargetView( BackBufferRTV, ClearColor );
	
				// This is how easy it is to render

				Render3D();
				root->Draw();
				
				SwapChain->Present(0, 0);

		}
	}
	MY_UI::Safe_Delete(Dummy);// destroy the dummy. This is not absolutely needed because the MY_UI library will clean up all widgets, but I delete it here because the 3d example needs to be shut down before everything else
	SAFE_DELETE(input);// make sure to delete this here. It will call the cleanup code in its destructor
	Cleanup();// clean up the 3d stuff
	HR(SwapChain->SetFullscreenState(false, 0));// this is needed in case full screen is on
	
	RELEASECOM(BackBufferRTV);
	RELEASECOM(SwapChain);
	RELEASECOM(g_DeviceContext);
	RELEASECOM(g_Device);


}
Ejemplo n.º 6
0
iKIT iBOOL i51KitMain ( iS32 aid , iU32 message , void* parameter )
{


	//	TODO :	消息循环
	switch ( message )
	{
		case i51_MSG_PAINT :
//i51AdeOsLog(0, "Start i51_MSG_PAINT!");
i51KitKeyInputQueueIn(KeyQueue, message, parameter);
TestBox2DLite_KeyEvent();
TestBox2DLite_Paint();
//i51AdeOsLog(0, "End i51_MSG_PAINT!");
			break;
		case i51_MSG_KEYUP :
		case i51_MSG_KEYDOWN :
//i51AdeOsLog(0, "Start i51KitKeyInputQueueIn!");
			i51KitKeyInputQueueIn(KeyQueue, message, parameter);
//i51AdeOsLog(0, "End i51KitKeyInputQueueIn!");
			break ;
		case i51_MSG_PADDOWN:
		case i51_MSG_PADUP:
//i51AdeOsLog(0, "Start i51KitKeyPADQueueIn!");
			i51KitKeyInputQueueIn(KeyQueue, message, parameter);
//i51AdeOsLog(0, "End i51KitKeyPADQueueIn!");
			break;			
		case i51_MSG_INIT :
			i51KIT_STATIC_KIT_SET(Adapter,parameter);
			i51KIT_STATIC_KIT_ASSERT(Adapter);

////i51AdeOsLog(0,"Adapter");

	             //	加载i51KitStd动态库
	             i51KIT_DYNAMIC_KIT_LOAD(i51KitStd,(iU16*)L"PKiGAPI\\i51KitStd.kit");
////i51AdeOsLog(0,"PKiGAPI\\i51KitStd.kit");
	             if ( iNULL == i51KIT_DYNAMIC_KIT_PROTOTYPE(i51KitStd) ) 
	             {
	                 return 0 ;
	             }
////i51AdeOsLog(0,"i51KitStd");
			 
	             //	加载i51KitStd动态库
	             i51KIT_DYNAMIC_KIT_LOAD(i51KitG2,(iU16*)L"PKiGAPI\\i51KitG2.kit");
////i51AdeOsLog(0,"PKiGAPI\\i51KitG2.kit");
	             if ( iNULL == i51KIT_DYNAMIC_KIT_PROTOTYPE(i51KitG2) ) 
	             {
	                 return 0 ;
	             }
	             //	加载i51KitKey动态库
	             i51KIT_DYNAMIC_KIT_LOAD(i51KitKey,(iU16*)L"PKiGAPI\\i51KitKey.kit");
////i51AdeOsLog(0,"PKiGAPI\\i51KitG2.kit");
	             if ( iNULL == i51KIT_DYNAMIC_KIT_PROTOTYPE(i51KitKey) ) 
	             {
	                 return 0 ;
	             }
//i51KernelSetCache(L"i51KitG2");

////i51AdeOsLog(0,"i51KitG2");
    i51KitG2CleanScreen(0,iNULL);
	i51KitG2Update();
////i51AdeOsLog(0, "Init OK");
FontFile = i51KitStdResOpen((iU16*)L"Fonts\\Typehead.re");
KeyQueue=i51KitKeyInputQueueCreat();
TestBox2DLite_Init();
             InitDemo(4);
			i51AdeOsScreenAlwaysLight(1);
			break ;
		case i51_MSG_RUN :
			i51KernelSetFPS(120,0) ;
			break ;
		case i51_MSG_PAUSE :
			break ;
		case i51_MSG_EXIT :
			i51AdeOsScreenAlwaysLight(0);

TestBox2DLite_Destroy();
			i51KIT_DYNAMIC_KIT_UNLOAD(i51KitStd);
			i51KIT_DYNAMIC_KIT_UNLOAD(i51KitG2);
			i51KIT_DYNAMIC_KIT_UNLOAD(i51KitKey);
			break ;
	}

	return iTRUE ;
Ejemplo n.º 7
0
void Keyboard(unsigned char key, int x, int y)
{
	switch (key)
	{
	case 27:
		exit(0);
		break;

	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
		{
			InitDemo(key - '1');
		}
		break;
	case 'b':
		{
			bruteForceHitCalc = !bruteForceHitCalc;
		}
		break;
	case 'p':
		{
			if(dt != 0.0f){ dt = 0.0f; }
			else { dt = 1.0f / 60.0f;}
		}
		break;
	case ' ':
		{
			LaunchBomb();
		}
		break;
	case 'u':
		{
			if(viewNode->parent()){ viewNode = viewNode->parent(); }
		}
		break;
	case 'd':
		{
			viewNode->children(true);
			if(viewNode->child(AutoMatic::QuadtreeNode::pXpY))
			{
				viewNode = viewNode->child(AutoMatic::QuadtreeNode::pXpY);
				child = 0;
			}
		}
		break;
	case 'n':
		{
			child++; if(child >= 4){ child = 0; }
			if(viewNode->parent())
			{
				viewNode = viewNode->parent()->child((AutoMatic::QuadtreeNode::ChildId)child);
			}
		}
		break;
	}
}