summaryrefslogtreecommitdiff
path: root/app/legion/rendermanager.h
blob: 555d7b809eb029704a2512fc6a05711daa9cbc92 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: The main manager of rendering 
//
// $Revision: $
// $NoKeywords: $
//===========================================================================//

#ifndef RENDERMANAGER_H
#define RENDERMANAGER_H

#ifdef _WIN32
#pragma once
#endif

#include "gamemanager.h"
#include "tier1/mempool.h"
#include "mathlib/mathlib.h"


//-----------------------------------------------------------------------------
// Physics property for entities
//-----------------------------------------------------------------------------
class CCameraProperty
{
	DECLARE_FIXEDSIZE_ALLOCATOR( CCameraProperty );

public:
	CCameraProperty();
	void GetForward( Vector *pForward );

	// Array used for fixed-timestep simulation
	Vector m_Origin;
	QAngle m_Angles;
	Vector m_Velocity;
	QAngle m_AngVelocity;

private:
	friend class CRenderManager;
};


//-----------------------------------------------------------------------------
// Rendering management 
//-----------------------------------------------------------------------------
class CRenderManager : public CGameManager<>
{
public:
	// Inherited from IGameManager
	virtual bool Init();
	virtual LevelRetVal_t LevelInit( bool bFirstCall );
	virtual void Update( );
	virtual LevelRetVal_t LevelShutdown( bool bFirstCall );
	virtual void Shutdown();

	// Property allocation
	CCameraProperty *CreateCameraProperty();
	void DestroyCameraProperty( CCameraProperty *pProperty );

	void RenderWorldInRect( int x, int y, int nWidth, int nHeight );
	void RenderWorldFullscreen();

private:
	// Set up a projection matrix for a 90 degree fov
	void SetupProjectionMatrix( int nWidth, int nHeight, float flFOV );

	// Set up a orthographic projection matrix
	void SetupOrthoMatrix( int nWidth, int nHeight );

	// Sets up the camera
	void SetupCameraRenderState( );

	// Draws the world
	void RenderWorld();

	// Done completely client-side, want total smoothness, so simulate at render interval
	void UpdateLocalPlayerCamera();

	bool m_bRenderWorldFullscreen;
	int m_nRenderX;
	int m_nRenderY;
	int m_nRenderWidth;
	int m_nRenderHeight;
};


//-----------------------------------------------------------------------------
// Singleton accessor
//-----------------------------------------------------------------------------
extern CRenderManager *g_pRenderManager;


#endif // RENDERMANAGER_H