Esempio n. 1
0
void CDebugGeometry::addText(const char* szText, const LTVector& position, const LTRGBColor& color)
{

	CDIDebugText* pText = NULL;
#ifdef __D3D
	pText = (CDIDebugText*)r_GetRenderStruct()->CreateRenderObject(CRenderObject::eDebugText); if (!pText) return;
#endif
#ifdef __XBOX
	pText = (CDIDebugText*)r_GetRenderStruct()->CreateRenderObject(CRenderObject::eDebugText); if (!pText) return;
#endif
    if (!pText) return;

#ifdef __D3D
	if (!GETCONSOLE()->GetInitialized()) return;
	pText->SetFont(GETCONSOLE()->GetFont()); 
#endif
#ifdef __XBOX
	if (!GETCONSOLE()->GetInitialized()) return;
	pText->SetFont(GETCONSOLE()->GetFont()); 
#endif
	
	pText->m_DPVert.rgba.a = color.rgb.a; pText->m_DPVert.rgba.r = color.rgb.r; pText->m_DPVert.rgba.g = color.rgb.g; pText->m_DPVert.rgba.b = color.rgb.b;
	
	pText->m_DPVert.x = position.x; pText->m_DPVert.y = position.y; pText->m_DPVert.z = position.z;
	LTStrCpy(pText->m_Text,szText,DEBUG_TEXT_MAX_LEN); 
	mText.push_back(pText);
}
Esempio n. 2
0
bool CWorldClientBSP::LoadRenderData(ILTStream *pStream)
{
	ASSERT(r_GetRenderStruct());
	if (!r_GetRenderStruct()->LoadWorldData(pStream))
		return false;

	// Clear out any lightgroup data we've already got loaded
	m_aLightGroups.clear();
	world_bsp_shared->LightTable().ClearLightGroups();

	uint32 nNumLightGroups;
	*pStream >> nNumLightGroups;
	LT_MEM_TRACK_ALLOC(m_aLightGroups.reserve(nNumLightGroups), LT_MEM_TYPE_WORLD);
	CClientLightGroup LightGroup;
	for (; nNumLightGroups; --nNumLightGroups)
	{
		m_aLightGroups.push_back(LightGroup);
		if (!m_aLightGroups.back().Load(pStream))
			return false;

		// Load the light table fix-up
		if (!world_bsp_shared->LightTable().LoadLightGroup(pStream, m_aLightGroups.back().GetID(), m_aLightGroups.back().GetColor()))
			return false;
	}

	return true;
}
Esempio n. 3
0
// ------------------------------------------------------------------------
// D3D specific object creation routine.
// ------------------------------------------------------------------------
CDIModelDrawable *ModelPiece::CreateModelRenderObject( uint32 type )
{
#if !defined(DE_SERVER_COMPILE) && !defined(DE_HEADLESS_CLIENT)
			// Note : The renderer can create render objects without being initialized
			if (r_GetRenderStruct()->m_bLoaded)
				return (CDIModelDrawable*)r_GetRenderStruct()->CreateRenderObject((enum CRenderObject::RENDER_OBJECT_TYPES)type);

		
#endif
		// default or server option
		CDIModelDrawable* p;
		LT_MEM_TRACK_ALLOC(p = new CDIModelDrawable(),LT_MEM_TYPE_MODEL);
		return p;	// Create a dummy Drawable object (it knows how to load - or, really, skip by a load)...

}
Esempio n. 4
0
void CDebugGeometry::clear()
{
#ifdef __D3D
	RenderStruct* pRendStruct = r_GetRenderStruct();
	if (pRendStruct) if (!pRendStruct->m_bInitted) pRendStruct = NULL;	// Renderer already shut down...
#endif
#ifdef __XBOX
	RenderStruct* pRendStruct = r_GetRenderStruct();
	if (pRendStruct) if (!pRendStruct->m_bInitted) pRendStruct = NULL;	// Renderer already shut down...
#endif
    
	while (!mLines.empty())
    {					// Clear out mLines...
		CDIDebugLine* pLine = *(mLines.begin()); 
		mLines.pop_front();
#ifdef __D3D
	 	if (pRendStruct) pRendStruct->DestroyRenderObject(pLine);
#endif
#ifdef __XBOX
	 	if (pRendStruct) pRendStruct->DestroyRenderObject(pLine);
#endif
    }

	while (!mPolygons.empty()) {				// Clear out mPolygons...
		CDIDebugPolygon* pPoly = *(mPolygons.begin()); 
		mPolygons.pop_front();
#ifdef __D3D
		if (pRendStruct) pRendStruct->DestroyRenderObject(pPoly); 
#endif
#ifdef __XBOX
		if (pRendStruct) pRendStruct->DestroyRenderObject(pPoly); 
#endif
    }
    

	while (!mText.empty()) {					// Clear out mText...
		CDIDebugText* pText = *(mText.begin()); 
		mText.pop_front();
#ifdef __D3D
	 	if (pRendStruct) pRendStruct->DestroyRenderObject(pText); 
#endif
#ifdef __XBOX
	 	if (pRendStruct) pRendStruct->DestroyRenderObject(pText); 
#endif
    }
}
Esempio n. 5
0
void CDebugGeometry::addPolygon(CDIDebugPolygon* poly, bool bScreenSpace)
{
	CDIDebugPolygon* pPoly = NULL;
#ifdef __D3D
	pPoly = (CDIDebugPolygon*)r_GetRenderStruct()->CreateRenderObject(CRenderObject::eDebugPolygon); if (!pPoly) return;
#endif
#ifdef __XBOX
	pPoly = (CDIDebugPolygon*)r_GetRenderStruct()->CreateRenderObject(CRenderObject::eDebugPolygon); if (!pPoly) return;
#endif
    if (!pPoly) return;
	pPoly->m_bScreenSpace  = bScreenSpace;
	pPoly->m_DPPoly3	   = poly->m_DPPoly3;
	pPoly->m_DPPoly4	   = poly->m_DPPoly4;
	pPoly->m_VertCount	   = poly->m_VertCount;
	pPoly->m_Polygon[0]	   = poly->m_Polygon[0];
	pPoly->m_Polygon[1]	   = poly->m_Polygon[1];
	pPoly->m_Polygon[2]	   = poly->m_Polygon[2];
	pPoly->m_Polygon[3]	   = poly->m_Polygon[3];
		
	mPolygons.push_back(pPoly);
}
Esempio n. 6
0
void CDebugGeometry::addLine(const LTVector& from, const LTVector& to, const LTRGBColor& color, bool bScreenSpace)
{
	// The renderer creates the render object (DD Object) and passes it back to us...		
	CDIDebugLine* pLine = NULL;	
#ifdef __D3D
	pLine = (CDIDebugLine*)r_GetRenderStruct()->CreateRenderObject(CRenderObject::eDebugLine); if (!pLine) return;
#endif
#ifdef __XBOX
	pLine = (CDIDebugLine*)r_GetRenderStruct()->CreateRenderObject(CRenderObject::eDebugLine); if (!pLine) return;
#endif
    if (!pLine) {
		return;
	}	
	
	pLine->m_DPLine.verts[0].x = from.x;  pLine->m_DPLine.verts[0].y = from.y;  pLine->m_DPLine.verts[0].z = from.z;
	pLine->m_DPLine.verts[1].x = to.x;    pLine->m_DPLine.verts[1].y = to.y;    pLine->m_DPLine.verts[1].z = to.z;
	pLine->m_DPLine.rgba.a = color.rgb.a; pLine->m_DPLine.rgba.r = color.rgb.r; pLine->m_DPLine.rgba.g = color.rgb.g; pLine->m_DPLine.rgba.b = color.rgb.b;
	pLine->m_bScreenSpace = bScreenSpace;
	
		
	mLines.push_back(pLine);
}
Esempio n. 7
0
LTRESULT r_InitRender(RMode *pMode)
{
	RenderStructInit init;
	int initStatus;
	HWND hWnd;

	// Don't get in here recursively.
	if(g_ClientGlob.m_bInitializingRenderer)
		return LT_OK;


	VarSetter<BOOL> setter(&g_ClientGlob.m_bInitializingRenderer, LTTRUE, LTFALSE);

	r_TermRender(0, false);


	hWnd = (HWND)dsi_GetMainWindow();
	ShowWindow(hWnd, SW_RESTORE);

	if (g_bFirstTimeInit) 
		r_InitSysCache(&g_SysCache);
	
	// Setup the init request.
	memset(&init, 0, sizeof(init));
	init.m_hWnd = (void*)hWnd;
	memcpy(&init.m_Mode, pMode, sizeof(RMode));


	// Set up the RenderStruct.
	rdll_RenderDLLSetup(&g_Render);

	// Store these.. the renderer may change them for pixel doubling.
	g_Render.m_Width = pMode->m_Width;
	g_Render.m_Height = pMode->m_Height;

	// Try to initialize the renderer for the requested mode.
	initStatus = g_Render.Init(&init);
	if(initStatus != RENDER_OK || init.m_RendererVersion != LTRENDER_VERSION)
	{
		g_pClientMgr->SetupError(LT_ERRORLOADINGRENDERDLL, "Init Failed");
		RETURN_ERROR_PARAM(1, r_InitRender, LT_ERRORLOADINGRENDERDLL, "Init Failed");
	}

	// Init the console.
	g_pClientMgr->InitConsole();

	// Restore interface surfaces that were backed up.
	if(!cis_RendererIsHere(r_GetRenderStruct()))
	{
		g_pClientMgr->SetupError(LT_UNABLETORESTOREVIDEO);
		RETURN_ERROR(1, r_InitRender, LT_UNABLETORESTOREVIDEO);
	}

	g_Render.m_bInitted = true;
	g_Render.m_bLoaded = true;

    // Let the game do a loading screen or something.
    if (i_client_shell != NULL) {
        i_client_shell->OnEvent(LTEVENT_RENDERALMOSTINITTED, 0);
    }

	// Bind any open worlds.
	if(!g_pClientMgr->BindClientShellWorlds())
	{
		g_Render.m_bInitted = false;
		g_Render.m_bLoaded = false;
		RETURN_ERROR(1, r_InitRender, LT_ERRORBINDINGWORLD);
	}

	// Set focus and capture the mouse.  We leave things like resizing the window to the render DLL.
	SetFocus(hWnd);

	// Bind any open textures.
	g_pClientMgr->BindSharedTextures();

	// Store this config..
	memcpy(&g_RMode, &init.m_Mode, sizeof(RMode));

	char cmd[200];
	// Set the console variables.
	LTSNPrintF(cmd, sizeof(cmd), "CardDesc %s", init.m_Mode.m_InternalName);
	c_CommandHandler(cmd);

	LTSNPrintF(cmd, sizeof(cmd), "ScreenWidth %d", init.m_Mode.m_Width);
	c_CommandHandler(cmd);

	LTSNPrintF(cmd, sizeof(cmd), "ScreenHeight %d", init.m_Mode.m_Height);
	c_CommandHandler(cmd);

	LTSNPrintF(cmd, sizeof(cmd), "BitDepth %d", init.m_Mode.m_BitDepth);
	c_CommandHandler(cmd);

	// The console can load its background now that we're initialized.
	con_LoadBackground();

    // Tell the game the renderer has initialized.
    if (i_client_shell != NULL) 
	{
        i_client_shell->OnEvent(LTEVENT_RENDERINIT, 0);
    }
    
	g_bFirstTimeInit = false;
	return LT_OK;
}