Ejemplo n.º 1
0
void main(void)
{
	// 內定使用DirectX 9來繪圖
	char *device = "dx9";
	void (*render)(void) = RenderFrameDX9;
	bool (*init_resource)(void) = InitResourceDX9;
	bool (*release_resource)(void) = ReleaseResourceDX9;
	void (*resize_func)(int width, int height) = ResizeWindowDX9;

	printf("Press\n(1) for Direct3D9\n(2) for OpenGL\n");
	int c = getche();

	switch(c)
	{
	default:
	case '1':
		render = RenderFrameDX9;
		init_resource = InitResourceDX9;
		release_resource = ReleaseResourceDX9;
		resize_func = ResizeWindowDX9;
		break;
	case '2':
		device = "opengl";
		init_resource = InitResourceOpenGL;
		release_resource = ReleaseResourceOpenGL;
		render = RenderFrameOpenGL;
		resize_func = ResizeWindowOpenGL;
		break;
	}

	GutResizeFunc( resize_func );

	// 在(100,100)的位置開啟一個大小為(512x512)的視窗
	GutCreateWindow(100, 100, 512, 512, device);

	// 做OpenGL或DirectX初始化
	if ( !GutInitGraphicsDevice(device) )
	{
		printf("Failed to initialize %s device\n", device);
		exit(0);
	}

	// 設定方向光
	g_Light.m_Position.Set(-3.0f, 0.0f, 5.0f);
	g_Light.m_Direction.Set(0.0f, 1.0f, 1.0f, 0.0f);
	g_Light.m_Direction.Normalize();
	g_Light.m_Diffuse.Set(0.6f, 0.6f, 0.6f, 1.0f);
	//g_Light.m_Specular.Set(1.0f, 1.0f, 1.0f, 1.0f);
	g_Light.m_Specular.Set(0.0f, 0.0f, 0.0f, 1.0f);

	g_light_pos_x = g_Light.m_Position[0];

	GutInputInit();
	g_Control.SetCamera(Vector4(0.0f, 0.0f, 10.0f), Vector4(0.0f, 0.0f, 0.0f), Vector4(0.0f, 1.0f, 0.0f) );

	g_Model.Load_ASCII("..\\..\\models\\teapot.gma");

	// 載入shader
	if ( !init_resource() )
	{
		release_resource();
		printf("Failed to load resources\n");
		exit(0);
	}

	// 主回圈
	while( GutProcessMessage() )
	{
		GetUserInput();
		FrameMove();
		render();
	}

	// 卸載shader
	release_resource();

	// 關閉OpenGL/DirectX繪圖裝置
	GutReleaseGraphicsDevice();
}
Ejemplo n.º 2
0
void main(void)
{
	// 內定使用DirectX 9來繪圖
	char *device = "dx9";
	void (*render)(void) = RenderFrameDX9;
	bool (*init_resource)(void) = InitResourceDX9;
	bool (*release_resource)(void) = ReleaseResourceDX9;
	void (*resize_func)(int width, int height) = ResizeWindowDX9;

#ifdef _ENABLE_DX10_
	printf("Press\n(1) for Direct3D9\n(2) for OpenGL\n(3) for Direct3D10\n");
#else
	printf("Press\n(1) for Direct3D9\n(2) for OpenGL\n");
#endif

	int c = getche();

	switch(c)
	{
	default:
	case '1':
		render = RenderFrameDX9;
		init_resource = InitResourceDX9;
		release_resource = ReleaseResourceDX9;
		resize_func = ResizeWindowDX9;
		break;
	case '2':
		device = "opengl";
		init_resource = InitResourceOpenGL;
		release_resource = ReleaseResourceOpenGL;
		render = RenderFrameOpenGL;
		resize_func = ResizeWindowOpenGL;
		break;
#ifdef _ENABLE_DX10_
	case '3':
		device = "dx10";
		init_resource = InitResourceDX10;
		release_resource = ReleaseResourceDX10;
		render = RenderFrameDX10;
		resize_func = ResizeWindowDX10;
		break;
#endif
	}

	printf("\nSelected %s device for rendering.\n", device);

	GutResizeFunc( resize_func );

	// 在(100,100)的位置開啟一個大小為(512x512)的視窗
	GutCreateWindow(100, 100, 512, 512, device);

	// 做OpenGL或DirectX初始化
	if ( !GutInitGraphicsDevice(device) )
	{
		printf("Failed to initialize %s device\n", device);
		exit(0);
	}

	g_view_matrix.Identity();
	g_world_matrix.Identity();

	GutInputInit();

	// 載入shader
	if ( !init_resource() )
	{
		release_resource();
		printf("Failed to load resources\n");
		exit(0);
	}

	// 主回圈
	while( GutProcessMessage() )
	{
		GetUserInput();
		// 畫出矩形
		render();
	}
	// 卸載shader
	release_resource();
	// 關閉OpenGL/DirectX繪圖裝置
	GutReleaseGraphicsDevice();
}
Ejemplo n.º 3
0
void main(void)
{
	// 內定使用DirectX 9來繪圖
	char *device = "dx9";
	void (*render)(void) = RenderFrameDX9;
	bool (*init_resource)(void) = InitResourceDX9;
	bool (*release_resource)(void) = ReleaseResourceDX9;
	void (*resize_func)(int width, int height) = ResizeWindowDX9;

#ifdef _ENABLE_DX10_
	printf("Press\n(1) for Direct3D9\n(2) for OpenGL\n(3) for Direct3D10\n");
#else
	printf("Press\n(1) for Direct3D9\n(2) for OpenGL\n");
#endif

	int c = getche();

	switch(c)
	{
	default:
	case '1':
		render = RenderFrameDX9;
		init_resource = InitResourceDX9;
		release_resource = ReleaseResourceDX9;
		resize_func = ResizeWindowDX9;
		break;
	case '2':
		device = "opengl";
		init_resource = InitResourceOpenGL;
		release_resource = ReleaseResourceOpenGL;
		render = RenderFrameOpenGL;
		resize_func = ResizeWindowOpenGL;
		break;
	case '3':
#ifdef _ENABLE_DX10_
		device = "dx10";
		init_resource = InitResourceDX10;
		release_resource = ReleaseResourceDX10;
		render = RenderFrameDX10;
		resize_func = ResizeWindowDX10;
#endif
		break;
	}

	GutResizeFunc( resize_func );
	// 在(100,100)的位置開啟一個大小為(512x512)的視窗
	GutCreateWindow(100, 100, 512, 512, device);
	// 做OpenGL或DirectX初始化
	if ( !GutInitGraphicsDevice(device) )
	{
		printf("Failed to initialize %s device\n", device);
		exit(0);
	}

	float texel = 1.0f/(float)shadowmap_size;
	int index = 0;

	for ( int y=-PCF_sample_span; y<=PCF_sample_span; y++ )
	{
		for ( int x=-PCF_sample_span; x<=PCF_sample_span; x++ )
		{
			g_vTexOffset[index++].Set(x*texel, y*texel, 0.0f, 0.0f);
		}
	}

	index = 0;
	for ( int y=-1; y<=2; y++ )
	{
		for ( int x=-1; x<=2; x++ )
		{
			g_vTexOffset2[index++].Set(x*texel, y*texel, 0.0f, 0.0f);
		}
	}

	GutInputInit();
	GutRegisterKeyDown(GUTKEY_1, KeyDown_1);
	GutRegisterKeyDown(GUTKEY_2, KeyDown_2);
	GutRegisterKeyPressed(GUTKEY_ADD, KeyPressed_ADD);
	GutRegisterKeyPressed(GUTKEY_SUBTRACT, KeyPressed_MINUS);

	g_Control.SetCamera(Vector4(5.0f, 0.0f, 5.0f), Vector4(0.0f), Vector4(0.0f, 1.0f, 0.0f) );

	g_Model.SetTexturePath("../../textures/");
	if ( !g_Model.Load_ASCII("../../models/altar.gma") )
	{
		exit(0);
	}

	// 載入shader
	if ( !init_resource() )
	{
		release_resource();
		printf("Failed to load resources\n");
		exit(0);
	}
	// 主回圈
	while( GutProcessMessage() )
	{
		GetUserInput();
		render();
	}
	// 卸載shader
	release_resource();
	// 關閉OpenGL/DirectX繪圖裝置
	GutReleaseGraphicsDevice();
}
Ejemplo n.º 4
0
void main(void)
{
	// 內定使用DirectX 9來繪圖
	char *device = "dx9";
	void (*render)(void) = RenderFrameDX9;
	bool (*init_resource)(void) = InitResourceDX9;
	bool (*release_resource)(void) = ReleaseResourceDX9;
	void (*resize_func)(int width, int height) = ResizeWindowDX9;

#ifndef _ENABLE_DX10_
	printf("Press\n(1) for Direct3D9\n(2) for OpenGL\n");
#else
	printf("Press\n(1) for Direct3D9\n(2) for OpenGL\n(3) for Direct3D10\n");
#endif

	int c = getche();

	switch(c)
	{
	default:
	case '1':
		render = RenderFrameDX9;
		init_resource = InitResourceDX9;
		release_resource = ReleaseResourceDX9;
		resize_func = ResizeWindowDX9;
		break;
	case '2':
		device = "opengl";
		init_resource = InitResourceOpenGL;
		release_resource = ReleaseResourceOpenGL;
		render = RenderFrameOpenGL;
		resize_func = ResizeWindowOpenGL;
		break;
	case '3':
#ifdef _ENABLE_DX10_
		device = "dx10";
		init_resource = InitResourceDX10;
		release_resource = ReleaseResourceDX10;
		render = RenderFrameDX10;
		resize_func = ResizeWindowDX10;
#endif
		break;
	}

	GutResizeFunc( resize_func );

	// 在(100,100)的位置開啟一個大小為(512x512)的視窗
	GutCreateWindow(100, 100, 512, 512, device);

	// 做OpenGL或DirectX初始化
	if ( !GutInitGraphicsDevice(device) )
	{
		printf("Failed to initialize %s device\n", device);
		exit(0);
	}

	GutInputInit();
	g_Control.SetCamera(Vector4(5.0f, 0.0f, 5.0f), Vector4(0.0f), Vector4(0.0f, 1.0f, 0.0f) );

	g_Model.Load_ASCII("../../models/teapot_set.gma");
	g_SpotLightModel.Load_ASCII("../../models/spotlight.gma");

	// 載入shader
	if ( !init_resource() )
	{
		release_resource();
		printf("Failed to load resources\n");
		exit(0);
	}

	// 主回圈
	while( GutProcessMessage() )
	{
		GetUserInput();
		render();
	}

	// 卸載shader
	release_resource();

	// 關閉OpenGL/DirectX繪圖裝置
	GutReleaseGraphicsDevice();
}
Ejemplo n.º 5
0
void main(void)
{
	// 內定使用DirectX 9來繪圖
	char *device = "dx9";
	void (*render)(void) = RenderFrameDX9;
	bool (*init_resource)(void) = InitResourceDX9;
	bool (*release_resource)(void) = ReleaseResourceDX9;
	void (*resize_func)(int width, int height) = ResizeWindowDX9;

#ifdef _ENABLE_DX10_
	printf("Press\n(1) for Direct3D9\n(2) for OpenGL\n(3) for Direct3D10\n");
#else
	printf("Press\n(1) for Direct3D9\n(2) for OpenGL\n");
#endif
	int c = getche();

	switch(c)
	{
	default:
	case '1':
		render = RenderFrameDX9;
		init_resource = InitResourceDX9;
		release_resource = ReleaseResourceDX9;
		resize_func = ResizeWindowDX9;
		break;
	case '2':
		device = "opengl";
		init_resource = InitResourceOpenGL;
		release_resource = ReleaseResourceOpenGL;
		render = RenderFrameOpenGL;
		resize_func = ResizeWindowOpenGL;
		break;
#ifdef _ENABLE_DX10_
	case '3':
		device = "dx10";
		init_resource = InitResourceDX10;
		release_resource = ReleaseResourceDX10;
		render = RenderFrameDX10;
		resize_func = ResizeWindowDX10;
		break;
#endif
	}

	printf("\nSelected %s device for rendering.\n", device);

	GutInputInit();

	GutRegisterKeyDown(GUTKEY_ESCAPE, KeyDown_ESCAPE);

	GutResizeFunc( resize_func );

	// 切換成全螢幕模式
	if ( !GutFullScreen(800, 600) )
	{
		GutFullScreen(600, 800);
	}

	// 做OpenGL或DirectX初始化
	if ( !GutInitGraphicsDevice(device) )
	{
		printf("Failed to initialize %s device\n", device);
		exit(0);
	}

	GutInputInit();

	// 載入shader
	if ( !init_resource() )
	{
		release_resource();
		printf("Failed to load resources\n");
		exit(0);
	}

	// 主回圈
	while( GutProcessMessage() )
	{
		render();
		GutReadKeyboard();
	}
	// 卸載shader
	release_resource();
	// 關閉OpenGL/DirectX繪圖裝置
	GutReleaseGraphicsDevice();
}
Ejemplo n.º 6
0
void main(void)
{
	// 內定使用DirectX 9來繪圖
	char *device = "dx9";
	void (*render)(void) = RenderFrameDX9;
	bool (*init_resource)(void) = InitResourceDX9;
	bool (*release_resource)(void) = ReleaseResourceDX9;
	void (*resize_func)(int width, int height) = ResizeWindowDX9;

#ifdef _ENABLE_DX10_
	printf("Press\n(1) for Direct3D9\n(2) for OpenGL\n(3) for Direct3D10\n");
#else
	printf("Press\n(1) for Direct3D9\n(2) for OpenGL\n");
#endif
	int c = getche();

	switch(c)
	{
	default:
	case '1':
		render = RenderFrameDX9;
		init_resource = InitResourceDX9;
		release_resource = ReleaseResourceDX9;
		resize_func = ResizeWindowDX9;
		break;
	case '2':
		device = "opengl";
		init_resource = InitResourceOpenGL;
		release_resource = ReleaseResourceOpenGL;
		render = RenderFrameOpenGL;
		resize_func = ResizeWindowOpenGL;
		break;
	case '3':
#ifdef _ENABLE_DX10_
		device = "dx10";
		init_resource = InitResourceDX10;
		release_resource = ReleaseResourceDX10;
		render = RenderFrameDX10;
		resize_func = ResizeWindowDX10;
#endif
		break;
	}

	GutResizeFunc( resize_func );

	// 在(100,100)的位置開啟一個大小為(512x512)的視窗
	GutCreateWindow(100, 100, 512, 512, device);

	// 做OpenGL或DirectX初始化
	if ( !GutInitGraphicsDevice(device) )
	{
		printf("Failed to initialize %s device\n", device);
		exit(0);
	}

	g_view_matrix.Identity();
	g_world_matrix.Identity();
	g_scale_matrix.Identity();

	GutInputInit();

	//g_Control.SetCamera(Vector4(0.0f, 10.0f, 0.0f), Vector4(0.0f, 0.0f, 0.0f), Vector4(0.0f, 0.0f, 1.0f) );
	g_Control.SetCamera(Vector4(0.0f, 0.0f, 10.0f), Vector4(0.0f, 0.0f, 0.0f), Vector4(0.0f, 1.0f, 0.0f) );

	CGutModel::SetTexturePath("../../textures/");

	g_Models[0].Load_ASCII("../../models/sun_darker.gma");
	g_Models[1].Load_ASCII("../../models/earth.gma");
	g_Models[2].Load_ASCII("../../models/moon.gma");
	g_Models[3].Load_ASCII("../../models/mars.gma");

	// 載入shader & textures
	if ( !init_resource() )
	{
		release_resource();
		printf("Failed to load resources\n");
		exit(0);
	}

	// 主回圈
	while( GutProcessMessage() )
	{
		GetUserInput();
		frame_move();
		render();
	}

	// 卸載shader
	release_resource();

	// 關閉OpenGL/DirectX繪圖裝置
	GutReleaseGraphicsDevice();
}
Ejemplo n.º 7
0
void main(void)
{
	// 內定使用DirectX 9來繪圖
	char *device = "dx9";
	void (*render)(void) = RenderFrameDX9;
	bool (*init_resource)(void) = InitResourceDX9;
	bool (*release_resource)(void) = ReleaseResourceDX9;
	void (*resize_func)(int width, int height) = ResizeWindowDX9;

	/*
	#ifdef _ENABLE_DX10_
	printf("Press\n(1) for Direct3D9\n(2) for OpenGL\n(3) for Direct3D10\n");
	#else
	printf("Press\n(1) for Direct3D9\n(2) for OpenGL\n");
	#endif
	*/

	printf("Press\n(1) for Direct3D9\n(2) for OpenGL\n");

	int c = getche();

	switch(c)
	{
	default:
	case '1':
		render = RenderFrameDX9;
		init_resource = InitResourceDX9;
		release_resource = ReleaseResourceDX9;
		resize_func = ResizeWindowDX9;
		break;
	case '2':
		device = "opengl";
		init_resource = InitResourceOpenGL;
		release_resource = ReleaseResourceOpenGL;
		render = RenderFrameOpenGL;
		resize_func = ResizeWindowOpenGL;
		break;
		/*
		#ifdef _ENABLE_DX10_
		case '3':
		device = "dx10";
		init_resource = InitResourceDX10;
		release_resource = ReleaseResourceDX10;
		render = RenderFrameDX10;
		resize_func = ResizeWindowDX10;
		break;
		#endif
		*/
	}

	printf("\nSelected %s device for rendering.\n", device);

	GutResizeFunc( resize_func );

	// 在(100,100)的位置開啟一個大小為(512x512)的視窗
	GutCreateWindow(100, 100, 512, 512, device);
	// 做OpenGL或DirectX初始化
	if ( !GutInitGraphicsDevice(device) )
	{
		printf("Failed to initialize %s device\n", device);
		exit(0);
	}
	//
	GutInputInit();
	GutRegisterKeyDown(GUTKEY_1, KeyDown_1);

	g_Control.SetCamera(Vector4(0.0f, 0.0f, 5.0f), Vector4(0.0f, 1.0f, 5.0f), Vector4(0.0f, 0.0f, 1.0f) );
	g_Control.SetMoveSpeed(20.0f);

	// 設定方向光
	g_Lights[0].m_Direction.Set(0.0f, 1.0f, 1.0f, 0.0f);
	g_Lights[0].m_Direction.Normalize();
	g_Lights[0].m_Diffuse.Set(0.6f, 0.6f, 0.6f, 1.0f);
	g_Lights[0].m_Specular.Set(1.0f, 1.0f, 1.0f, 1.0f);

	// 載入shader
	if ( !init_resource() )
	{
		release_resource();
		printf("Failed to load resources\n");
		exit(0);
	}
	// 主回圈
	while( GutProcessMessage() )
	{
		GetUserInput();
		// 畫出矩形
		render();
	}
	// 卸載shader
	release_resource();
	// 關閉OpenGL/DirectX繪圖裝置
	GutReleaseGraphicsDevice();
}
Ejemplo n.º 8
0
void main(void)
{
	// 內定使用DirectX 9來繪圖
	char *device = "dx9";
	void (*render)(void) = RenderFrameDX9;
	bool (*init_resource)(void) = InitResourceDX9;
	bool (*release_resource)(void) = ReleaseResourceDX9;
	void (*resize_func)(int width, int height) = ResizeWindowDX9;

#ifdef _ENABLE_DX10_
	printf("Press\n(1) for Direct3D9\n(2) for OpenGL\n(3) for Direct3D10\n");
#else
	printf("Press\n(1) for Direct3D9\n(2) for OpenGL\n");
#endif

	int c = getche();

	switch(c)
	{
	default:
	case '1':
		render = RenderFrameDX9;
		init_resource = InitResourceDX9;
		release_resource = ReleaseResourceDX9;
		resize_func = ResizeWindowDX9;
		break;
	case '2':
		device = "opengl";
		init_resource = InitResourceOpenGL;
		release_resource = ReleaseResourceOpenGL;
		render = RenderFrameOpenGL;
		resize_func = ResizeWindowOpenGL;
		break;
#ifdef _ENABLE_DX10_
	case '3':
		device = "dx10";
		init_resource = InitResourceDX10;
		release_resource = ReleaseResourceDX10;
		render = RenderFrameDX10;
		resize_func = ResizeWindowDX10;
		break;
#endif
	}

	printf("\nSelected %s device for rendering.\n", device);

	GutResizeFunc( resize_func );
	// 在(100,100)的位置開啟一個大小為(512x512)的視窗
	GutCreateWindow(100, 100, 512, 512, device);
	// 做OpenGL或DirectX初始化
	if ( !GutInitGraphicsDevice(device) )
	{
		printf("Failed to initialize %s device\n", device);
		exit(0);
	}
	//
	GutInputInit();

	GutRegisterKeyDown(GUTKEY_1, KeyDown_1);
	GutRegisterKeyDown(GUTKEY_2, KeyDown_2);
	GutRegisterKeyDown(GUTKEY_3, KeyDown_3);
	GutRegisterKeyDown(GUTKEY_4, KeyDown_4);
	GutRegisterKeyDown(GUTKEY_5, KeyDown_5);
	GutRegisterKeyDown(GUTKEY_6, KeyDown_6);

	GutRegisterKeyPressed(GUTKEY_EQUALS, KeyPressed_ADD);
	GutRegisterKeyPressed(GUTKEY_MINUS, KeyPressed_MINUS);
	GutRegisterKeyPressed(GUTKEY_ADD, KeyPressed_ADD);
	GutRegisterKeyPressed(GUTKEY_SUBTRACT, KeyPressed_MINUS);

	g_Control.SetCamera(Vector4(0.0f, 3.0f, 1.0f), Vector4(0.0f, 0.0f, 1.0f), Vector4(0.0f, 0.0f, 1.0f) );
	g_Control.SetMoveSpeed(5.0f);

	//
	g_emitter.m_fEmitRate = 300;
	g_emitter.m_fEmitTheta = FastMath::DegToRad(15.0f);
	g_emitter.m_fParticleInitSpeed[0] = 1.0f;
	g_emitter.m_fParticleInitSpeed[1] = 2.0f;
	g_emitter.m_fParticleLife[0] = 1.5f;
	g_emitter.m_fParticleLife[1] = 2.0f;
	g_emitter.m_fParticleSize[0] = 0.05f;
	g_emitter.m_fParticleSize[1] = 0.10f;

	g_Particle.SetEmitter(g_emitter);
	g_Particle.SetForce(Vector4(0.0f, 0.0f, -1.0f));

	// 載入shader
	if ( !init_resource() )
	{
		release_resource();
		printf("Failed to load resources\n");
		exit(0);
	}

	g_Timer.Restart();
	// 主回圈
	while( GutProcessMessage() )
	{
		GetUserInput();
		//
		framemove();
		// 畫出矩形
		render();
	}
	// 卸載shader
	release_resource();
	// 關閉OpenGL/DirectX繪圖裝置
	GutReleaseGraphicsDevice();
}
Ejemplo n.º 9
0
void main(void)
{
    // 內定使用DirectX 9來繪圖
    char *device = "dx9";
    void (*render)(void) = RenderFrameDX9;
    bool (*init_resource)(void) = InitResourceDX9;
    bool (*release_resource)(void) = ReleaseResourceDX9;
    void (*resize_func)(int width, int height) = ResizeWindowDX9;

#ifdef _ENABLE_DX10_
    printf("Press\n(1) for Direct3D9\n(2) for OpenGL\n(3) for Direct3D10\n");
#else
    printf("Press\n(1) for Direct3D9\n(2) for OpenGL\n");
#endif
    int c = getche();

    switch(c)
    {
    default:
    case '1':
        render = RenderFrameDX9;
        init_resource = InitResourceDX9;
        release_resource = ReleaseResourceDX9;
        resize_func = ResizeWindowDX9;
        break;
    case '2':
        device = "opengl";
        init_resource = InitResourceOpenGL;
        release_resource = ReleaseResourceOpenGL;
        render = RenderFrameOpenGL;
        resize_func = ResizeWindowOpenGL;
        break;
    case '3':
#ifdef _ENABLE_DX10_
        device = "dx10";
        init_resource = InitResourceDX10;
        release_resource = ReleaseResourceDX10;
        render = RenderFrameDX10;
        resize_func = ResizeWindowDX10;
#endif
        break;
    }

    GutResizeFunc( resize_func );
    GutCreateWindow(100, 100, 512, 512, device);

    if ( !GutInitGraphicsDevice(device) )
    {
        printf("Failed to initialize %s device\n", device);
        exit(0);
    }

    // ambient
    g_Lights[0].m_vPosition.Set(0.0f, 0.0f, 0.0f, 1.0f);
    g_Lights[0].m_vDiffuse.Set(0.0f);
    g_Lights[0].m_vAmbient.Set(0.3f);

    GutInputInit();

    GutRegisterKeyDown(GUTKEY_1, KeyDown_1);
    GutRegisterKeyDown(GUTKEY_2, KeyDown_2);
    GutRegisterKeyDown(GUTKEY_3, KeyDown_3);
    GutRegisterKeyDown(GUTKEY_SPACE, KeyDown_Space);

    g_Control.SetCamera(
        Vector4(0.0f, 3.0f, 0.0f),
        Vector4(0.0f, 0.0f, 0.0f),
        Vector4(0.0f, 0.0f, 1.0f) );

    g_Model.Load_ASCII("..\\..\\models\\earth_normalmapped.gma");
    g_Sphere.Load_ASCII("..\\..\\models\\sphere_simple.gma");

    // 載入shader
    if ( !init_resource() )
    {
        release_resource();
        printf("Failed to load resources\n");
        exit(0);
    }
    // 主回圈
    while( GutProcessMessage() )
    {
        GetUserInput();
        frame_move();
        render();
    }
    // 卸載shader
    release_resource();
    // 關閉OpenGL/DirectX繪圖裝置
    GutReleaseGraphicsDevice();
}