예제 #1
0
void InitLightExam()
{
	ZFXCOLOR color(0, 0, 1, 1);
	g_pDevice->SetShadeMode(RS_SHADE_SOLID, 1.0f, &color);
	ZFXVector vU(0, 1, 0);
	ZFXVIEWPORT vp = { 0, 0, 800, 600 };
	g_pDevice->InitStage(60, &vp, 0);
	g_pDevice->SetClippingPlanes(0.1f, 1000.0f);
	g_pDevice->SetMode(EMD_PERSPECTIVE, 0);

	IShaderManager* sm = g_pDevice->GetShaderManager();
	if (g_vshader)
		sm->BindShader(g_vshader);
	if (g_fshader)
		sm->BindShader(g_fshader);
	if (g_vshader || g_fshader)
		sm->EnableShader(true);


	light.Type = LGT_SPOT;
	light.cAmbient.rgba(0.2, 0.2, 0.2, 1);
	light.cDiffuse.rgba(0, 0, 1, 1);
	light.cSpecular.rgba(1, 0, 0, 1);
	light.fAttenuation0 = 1.0f;
	light.fAttenuation1 = 0.0f;
	light.fTheta = 30;
	light.fPhi = 60;
	light.fRange = 50;
	light.vcDirection = ZFXVector(0, 0, 0);
}
예제 #2
0
void InitTriangleExam()
{
	ZFXCOLOR color(0, 0, 1, 1);
	g_pDevice->SetShadeMode(RS_SHADE_SOLID, 1.0f, &color);
	ZFXVector vU(0, 1, 0);
	ZFXVIEWPORT vp = { 0, 0, 800, 600 };
	g_pDevice->InitStage(60, &vp, 0);
	g_pDevice->SetClippingPlanes(0.1f, 1000.0f);
	g_pDevice->SetMode(EMD_ORTHOGONAL, 0);

	IShaderManager* sm = g_pDevice->GetShaderManager();
	if (g_vshader)
		sm->BindShader(g_vshader);
	if (g_fshader)
		sm->BindShader(g_fshader);
	if (g_vshader || g_fshader)
		sm->EnableShader(true);

	sm->EnableShader(false);
}
예제 #3
0
/**
* Do one frame.
*/
HRESULT ProgramTick(void)
{
	HRESULT hr = ZFX_FAIL;
	ZFXMatrix mWorld;
	mWorld.Identity();

	static float fT = 0.0f;
	static float fA = 0.0f;


	// this is just fancy fadein/fadeout eyecandy ////////
	if (fT <= 1.0f)
	{
		fA = fT;
		fT += 0.01f;
	}
	else if (fT <= 2.0f)
	{
		fA = 1 - (fT - 1); 
		fT += 0.01f;
	}
	else fT = 0.0f;
	// end of fancy fadein/fadeout eyecandy //////////////

	// set first viewport (whole window)
	g_pDevice->SetMode(EMD_PERSPECTIVE, 0);
	IShaderManager* sm = g_pDevice->GetShaderManager();
	if (g_vshader)
		sm->BindShader(g_vshader);
	if (g_fshader)
		sm->BindShader(g_fshader);
	if(g_vshader || g_fshader)
		sm->EnableShader(true);
	GLfloat f[16] = { 0.0 };
	glGetFloatv(GL_MODELVIEW_MATRIX, f);
	glGetFloatv(GL_PROJECTION_MATRIX, f);
	g_pDevice->SetClearColor(0.7f, 0.7f, 1.0f);

	// clear buffers and start scene
	g_pDevice->BeginRendering(true, true, true);

	mWorld.Translate(-1.0f, 1.0f, 3.0f);
	g_pDevice->SetWorldTransform(&mWorld);
	hr = g_pMarder->Render(true, false);

	mWorld.Translate(-1.0f, -5.0f, 2.0f);
	g_pDevice->SetWorldTransform(&mWorld);
	hr = g_pLeopard2->Render(true, false);

	mWorld.Identity();
	//mWorld.Translate(1.1f, -0.6f, 1.0f);
	g_pDevice->SetWorldTransform(&mWorld);
	hr = g_pG3->Render(true, false);

	g_pDevice->FadeScreen(0.0f, 0.0f, 0.0f, fA);

	// render into second viewport
	g_pDevice->SetMode(EMD_PERSPECTIVE, 1);
	if (g_vshader || g_fshader)
		sm->EnableShader(true);
	glGetFloatv(GL_MODELVIEW_MATRIX, f);
	glGetFloatv(GL_PROJECTION_MATRIX, f);
	g_pDevice->SetClearColor(1.0f, 0.2f, 0.2f);
	g_pDevice->Clear(true, true, true);

	mWorld.Translate(-2.0f, 1.0f, 3.0f);
	g_pDevice->SetWorldTransform(&mWorld);
	g_pMarder->Render(true, true);

	mWorld.Translate(-1.0f, -5.0f, 2.0f);
	g_pDevice->SetWorldTransform(&mWorld);
	g_pLeopard2->Render(true, true);

	mWorld.Translate(1.1f, -0.6f, 1.0f);
	g_pDevice->SetWorldTransform(&mWorld);
	g_pG3->Render(true, true);

	g_pDevice->FadeScreen(0.0f, 0.0f, 0.0f, 1.0f - fA);

	g_pDevice->SetMode(EMD_PERSPECTIVE, 0);

	/*if (g_pDevice->IsWindowed())
		g_pDevice->DrawText(g_nFontID, 10, 10, 255, 255, 0, "ZFXEngine 2.0");
	else 
	{
		g_pDevice->GetResolution(&pt);
		g_pDevice->DrawText(g_nFontID, 10, 10, 255, 255, 0, "Screen: (%d,%d)", pt.x, pt.y);
	}
*/
	// flip backbuffer to front
	g_pDevice->EndRendering();
	return hr;
} // Tick