summaryrefslogtreecommitdiff
path: root/engine/gl_shader.cpp
blob: 091d65cef9ba9305560e15eae50d14a1a183a34f (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//
//===========================================================================//


#include "render_pch.h"
#include "gl_shader.h"
#include "const.h"
#include "gl_cvars.h"
#include "gl_lightmap.h"
#include "decal_private.h"
#include "gl_model_private.h"
#include "r_local.h"
#include "materialproxyfactory.h"
#include "enginestats.h"
#include "editor_sendcommand.h"
#include "gl_matsysiface.h"
#include "vmodes.h"
#include "materialsystem/imaterialsystemhardwareconfig.h"
#include "tier1/strtools.h"
#include "filesystem.h"
#include "traceinit.h"
#include "sys_dll.h"
#include "tier0/icommandline.h"
#include "materialsystem/idebugtextureinfo.h"
#include "common.h"
#include "iregistry.h"
#include "materialsystem/materialsystem_config.h"
#include "ivideomode.h"
#include "modes.h"
#include "ivideomode.h"
#include "tier2/tier2.h"

#include "igame.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

static CMaterialProxyFactory s_MaterialProxyFactory;


//-----------------------------------------------------------------------------
// Connects to other
//-----------------------------------------------------------------------------
static void Shader_ConnectOtherMatSysInterfaces( )
{
	// NOTE: These two interfaces have been connected in the tier2 library
	if ( !g_pMaterialSystemHardwareConfig )
	{
		Shader_Disconnect();
		Sys_Error( "Could not get the material system hardware config interface! (2)" );
	}
	if ( !g_pMaterialSystemDebugTextureInfo )
	{
		Shader_Disconnect();
		Sys_Error( "Could not get the debug texture info interface!" );
	}
}


//-----------------------------------------------------------------------------
// Connect to interfaces we need
//-----------------------------------------------------------------------------
bool Shader_Connect( bool bSetProxyFactory )
{
	if ( !materials )
		return false;

	int nAdapter = CommandLine()->ParmValue( "-adapter", 0 );
	int nModeFlags = MATERIAL_INIT_ALLOCATE_FULLSCREEN_TEXTURE;
	if ( CommandLine()->FindParm( "-ref" ) )
	{
		nModeFlags |= MATERIAL_INIT_REFERENCE_RASTERIZER;
	}

	materials->SetAdapter( nAdapter, nModeFlags );
	if ( bSetProxyFactory )
		materials->SetMaterialProxyFactory( &s_MaterialProxyFactory );

	Shader_ConnectOtherMatSysInterfaces( );
	return g_pMaterialSystemHardwareConfig && g_pMaterialSystemDebugTextureInfo;
}


//-----------------------------------------------------------------------------
// Connect to interfaces we need
//-----------------------------------------------------------------------------
void Shader_Disconnect( void )
{
}



#ifndef SWDS

void Shader_SwapBuffers( void )
{
	assert( materials );
	materials->SwapBuffers();
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void Shader_BeginRendering ( void )
{
	// FIXME:
//	vid.width  = window_rect.width;
//	vid.height = window_rect.height;
}
#endif