Beispiel #1
0
void EditorScreen::Draw()
{
	GHScreen::DrawScreens();	

	MFRenderer_ClearScreen(MFRCF_Depth);

	MFMatrix mat;
	mat.LookAt(MakeVector(2.0,1.5,-1.0), MakeVector(1.0,0.3f,1.0f));
	MFView_SetCameraMatrix(mat);
//	pScene->Draw();
}
Beispiel #2
0
void dBThemeScreen::Draw()
{
	MFRenderer_ClearScreen(MFRCF_All, clearColour);

	MFView_Push();
	MFRect rect = { 0.f, 0.f, 1280, 720 };
	MFView_SetOrtho(&rect);

	dBEntity *pE = NULL;
	while(pE = entityPool.Iterate(pE))
		pE->Draw();

	MFView_Pop();
}
Beispiel #3
0
int MFRenderer_CreateDisplay()
{
	// create the D3D device
	D3DPRESENT_PARAMETERS presentparams;
	HRESULT hr;

	MFZeroMemory(&presentparams, sizeof(D3DPRESENT_PARAMETERS));
	presentparams.BackBufferWidth = gDisplay.width;
	presentparams.BackBufferHeight = gDisplay.height;
	presentparams.BackBufferFormat = (gDisplay.colourDepth == 32) ? D3DFMT_X8R8G8B8 : D3DFMT_R5G6B5;
	presentparams.BackBufferCount = 1;
	presentparams.MultiSampleType = D3DMULTISAMPLE_NONE;
	presentparams.SwapEffect = D3DSWAPEFFECT_DISCARD;
	presentparams.EnableAutoDepthStencil = TRUE;
	presentparams.AutoDepthStencilFormat = D3DFMT_D24S8;
	presentparams.FullScreen_RefreshRateInHz = gDisplay.refreshRate; 
	presentparams.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE_OR_IMMEDIATE;// : D3DPRESENT_INTERVAL_IMMEDIATE;
	presentparams.Flags = (gDisplay.wide ? D3DPRESENTFLAG_WIDESCREEN : NULL) | (gDisplay.progressive ? D3DPRESENTFLAG_PROGRESSIVE : NULL);

	hr = d3d8->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, NULL, D3DCREATE_HARDWARE_VERTEXPROCESSING, &presentparams, &pd3dDevice);
	if(hr != D3D_OK)
		return 2;

	// clear frame buffers to black
	MFVector oldColour = gClearColour;
	MFRenderer_SetClearColour(0,0,0,0);
	MFRenderer_BeginFrame();
	MFRenderer_ClearScreen(CS_All);
	MFRenderer_EndFrame();
	MFRenderer_BeginFrame();
	MFRenderer_ClearScreen(CS_All);
	MFRenderer_EndFrame();
	MFRenderer_SetClearColour(oldColour.x, oldColour.y, oldColour.z, oldColour.w);

	return 0;
}
Beispiel #4
0
MF_API void MFRenderer_BuildCommandBuffers(MFRenderer *pRenderer)
{
	MFCALLSTACKc;

	for(int l = 0; l < pRenderer->numLayers; ++l)
	{
		MFRenderLayer &layer = pRenderer->pLayers[l];

		int numElements = (int)layer.elements.size();

		// configure render target
		if(numElements > 0 || layer.clearFlags != MFRCF_None)
			MFRenderer_SetRenderTarget(layer.pRenderTarget);

		// clear render target
		MFRenderClearFlags cf = (MFRenderClearFlags)((layer.pRenderTarget->availableColourTargets ? layer.clearFlags & MFRCF_Colour : 0) | (layer.pRenderTarget->bHasDepth ? layer.clearFlags & MFRCF_Depth : 0) | (layer.pRenderTarget->bHasStencil ? layer.clearFlags & MFRCF_Stencil : 0));
		if(layer.clearFlags != MFRCF_None)
			MFRenderer_ClearScreen(cf, layer.clearColour, layer.clearZ, layer.clearStencil);

		if(numElements == 0)
			continue;

		// sort elements
		if(layer.sortMode != MFRL_SM_None)
			MFRendererInternal_SortElements(layer);

		// init renderer state
		MFRendererState state;
		MFZeroMemory(&state, sizeof(state));
		for(int m = 0; m < MFSCM_NumDerived; ++m)
			state.pMatrixStatesSet[MFSCM_DerivedStart + m] = &state.derivedMatrices[m];

		state.pStateBlocks[MFSBT_Global] = pRenderer->pGlobal;
		state.pStateBlocks[MFSBT_Layer] = layer.pLayer;
		state.pStateBlocks[MFSBT_Override] = pRenderer->pOverride;

		// render elements
		MFRenderer_RenderElements(state, layer.elements.getPointer(), numElements);

		// clear the layer
		layer.elements.clear();
	}
}
Beispiel #5
0
void Game_Draw()
{
	MFCALLSTACK;

	// set clear colour and clear the screen
	MFRenderer_SetClearColour(0.f, 0.f, 0.2f, 1.f);
	MFRenderer_ClearScreen();

	// push current view onto the stack
	MFView_Push();

	// set orthographic projection
	MFView_SetOrtho();

	// render some text
	MFFont_DrawText2(MFFont_GetDebugFont(), 200.f, 200.f, 50.f, MFVector::one, "Hello World!");

	// pop the current view
	MFView_Pop();
}
MF_API void MFDebug_DebugAssert(const char *pReason, const char *pMessage, const char *pFile, int line)
{
	MFDebug_Message(MFStr("%s(%d) : Assertion Failure.",pFile,line));
	MFDebug_Message(MFStr("Failed Condition: %s\n%s", pReason, pMessage));
#if !defined(_RETAIL)
	MFCallstack_Log();
#endif

#if defined(MF_LINUX) || defined(MF_OSX)
	MFDebug_Breakpoint();
#endif

	if(!MFFont_GetDebugFont())
		return;

	while(!gQuit)
	{
		MFSystem_HandleEventsPlatformSpecific();

		MFSystem_UpdateTimeDelta();
		gFrameCount++;

		MFSystem_Update();
		MFSystem_PostUpdate();

		MFRenderer_BeginFramePlatformSpecific();

		MFRenderer_SetClearColour(0,0,0,0);
		MFRenderer_ClearScreen();

		MFView_SetDefault();
		MFView_SetOrtho();

		if(!(((uint32)gSystemTimer.GetSecondsF()) % 2))
		{
			MFMaterial_SetMaterial(MFMaterial_GetStockMaterial(MFMat_White));
			MFPrimitive(PT_QuadList);

			MFBegin(4);
			MFSetColour(1,0,0,1);
			MFSetPosition(50, 50, 0);
			MFSetPosition(590, 110, 0);

			MFSetColour(0,0,0,1);
			MFSetPosition(55, 55, 0);
			MFSetPosition(585, 105, 0);
			MFEnd();
		}

		MFFont_DrawText2f(MFFont_GetDebugFont(), 110, 60, 20, MakeVector(1,0,0,1), "Software Failure. Press left mouse button to continue.");
		MFFont_DrawText2f(MFFont_GetDebugFont(), 240, 80, 20, MakeVector(1,0,0,1), "Guru Meditation: ");

		MFFont_DrawText2f(MFFont_GetDebugFont(), 80, 120, 20, MakeVector(1,0,0,1), "Assertion Failure:");
		MFFont_DrawText2f(MFFont_GetDebugFont(), 80, 140, 20, MakeVector(1,0,0,1), MFStr("Failed Condition: %s", pReason));
		MFFont_DrawText2f(MFFont_GetDebugFont(), 80, 160, 20, MakeVector(1,0,0,1), MFStr("File: %s, Line: %d", pFile, line));
		MFFont_DrawText2f(MFFont_GetDebugFont(), 80, 190, 20, MakeVector(1,0,0,1), MFStr("Message: %s", pMessage));

#if !defined(_RETAIL)
		MFFont_DrawText2f(MFFont_GetDebugFont(), 80, 230, 20, MakeVector(1,0,0,1), "Callstack:");
		MFFont_DrawText2f(MFFont_GetDebugFont(), 100, 250.0f, 20, MakeVector(1,0,0,1), MFCallstack_GetCallstackString());
#else
		MFFont_DrawText2f(MFFont_GetDebugFont(), 80, 230, 20, MakeVector(1,0,0,1), "Callstack not available in RETAIL builds");
#endif

//		MFSystem_Draw();
		MFRenderer_EndFramePlatformSpecific();
	}
}
Beispiel #7
0
void Game_Draw()
{
	MFCALLSTACK;

	MFRenderer_SetClearColour(0.f, 0.f, 0.2f, 1.f);
	MFRenderer_ClearScreen();

	// Set identity camera (no camera)
	MFView_Push();
	MFView_SetAspectRatio(MFDisplay_GetNativeAspectRatio());
	MFView_SetProjection();

	MFMaterial_SetMaterial(MFMaterial_GetStockMaterial(MFMat_White));

	// set the world matrix to identity
	MFMatrix world = MFMatrix::identity;

	// move the box into the scene (along the z axis)
	world.Translate(MakeVector(0, 0, 5));

	// increment rotation
	static float rotation = 0.0f;
	rotation += MFSystem_TimeDelta();

	// rotate the box
	world.RotateYPR(rotation, rotation * 2.0f, rotation * 0.5f);

	// begin rendering the box
	MFPrimitive(PT_TriList);
	MFSetMatrix(world);

	// begin rendering 12 triangles (12 * 3 vertices)
	MFBegin(3 * 12);

	// draw a bunch of triangles
	MFSetColour(1,0,0,1);
	MFSetPosition(-1,-1, -1);
	MFSetPosition(-1, 1, -1);
	MFSetPosition( 1, 1, -1);
	MFSetPosition(-1,-1, -1);
	MFSetPosition( 1, 1, -1);
	MFSetPosition( 1,-1, -1);

	MFSetColour(0,1,0,1);
	MFSetPosition(-1,-1,1);
	MFSetPosition( 1,-1,1);
	MFSetPosition( 1, 1,1);
	MFSetPosition(-1,-1,1);
	MFSetPosition( 1, 1,1);
	MFSetPosition(-1, 1,1);

	MFSetColour(0,0,1,1);
	MFSetPosition( 1,-1,1);
	MFSetPosition( 1,-1,-1);
	MFSetPosition( 1, 1,-1);
	MFSetPosition( 1,-1,1);
	MFSetPosition( 1, 1,-1);
	MFSetPosition( 1, 1,1);

	MFSetColour(1,0,1,1);
	MFSetPosition(-1,-1,1);
	MFSetPosition(-1, 1,1);
	MFSetPosition(-1, 1,-1);
	MFSetPosition(-1,-1,1);
	MFSetPosition(-1, 1,-1);
	MFSetPosition(-1,-1,-1);

	MFSetColour(1,1,0,1);
	MFSetPosition(-1, 1,1);
	MFSetPosition( 1, 1,1);
	MFSetPosition( 1, 1,-1);
	MFSetPosition(-1, 1,1);
	MFSetPosition( 1, 1,-1);
	MFSetPosition(-1, 1,-1);

	MFSetColour(0,1,1,1);
	MFSetPosition(-1,-1,1);
	MFSetPosition(-1,-1,-1);
	MFSetPosition( 1,-1,-1);
	MFSetPosition(-1,-1,1);
	MFSetPosition( 1,-1,-1);
	MFSetPosition( 1,-1,1);

	MFEnd();

	MFRect disp;
	MFDisplay_GetDisplayRect(&disp);
	MFView_SetOrtho(&disp);
	pUI->Draw();

	MFView_Pop();
}