gfxInit.h
Engine/source/gfx/gfxInit.h
More...
Classes:
class
Interface for tracking GFX adapters and initializing them into devices.
Detailed Description
1
2//-----------------------------------------------------------------------------
3// Copyright (c) 2012 GarageGames, LLC
4//
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to
7// deal in the Software without restriction, including without limitation the
8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9// sell copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21// IN THE SOFTWARE.
22//-----------------------------------------------------------------------------
23
24#ifndef _GFXINIT_H_
25#define _GFXINIT_H_
26
27#ifndef _GFXDEVICE_H_
28 #include "gfx/gfxDevice.h"
29#endif
30#ifndef _ENGINEOBJECT_H_
31 #include "console/engineObject.h"
32#endif
33
34
35/// Interface for tracking GFX adapters and initializing them into devices.
36/// @note Implement this class per platform.
37/// @note This is just a class so it can be friends with GFXDevice)
38class GFXInit
39{
40 DECLARE_STATIC_CLASS( GFXInit );
41
42public:
43 /// Allows device to register themselves as available
44 typedef Signal<void (Vector<GFXAdapter*>&)> RegisterDeviceSignal;
45 static RegisterDeviceSignal& getRegisterDeviceSignal();
46
47 /// Prepares the adapter list.
48 static void init();
49
50 /// Cleans out the adapter list.
51 static void cleanup();
52
53 /// Creates a GFXDevice based on an adapter from the
54 /// enumerateAdapters method.
55 ///
56 /// @param adapter Graphics adapter to create device
57 static GFXDevice *createDevice( GFXAdapter *adapter );
58
59 /// Enumerate all the graphics adapters on the system
60 static void enumerateAdapters();
61
62 /// Get the enumerated adapters. Should only call this after
63 /// a call to enumerateAdapters.
64 static void getAdapters( Vector<GFXAdapter*> *adapters );
65
66 /// Get the number of available adapters.
67 static S32 getAdapterCount();
68
69 /// Compares the adapter's output display device with the given output display device
70 static bool compareAdapterOutputDevice(const GFXAdapter* adapter, const char* outputDevice);
71
72 /// Chooses a suitable GFXAdapter, based on type, preferences, and fallbacks.
73 /// If the requested type is omitted, we use the prefs value.
74 /// If the requested type isn't found, we use fallbacks: OpenGL, NullDevice
75 /// This method never returns NULL.
76 static GFXAdapter *chooseAdapter( GFXAdapterType type, const char* outputDevice);
77
78 /// Override which chooses an adapter based on an index instead
79 static GFXAdapter *chooseAdapter( GFXAdapterType type, S32 outputDeviceIndex );
80
81 /// Gets the first adapter of the requested type (and on the requested output device)
82 /// from the list of enumerated adapters. Should only call this after a call to
83 /// enumerateAdapters.
84 static GFXAdapter *getAdapterOfType( GFXAdapterType type, const char* outputDevice );
85
86 /// Override which gets an adapter based on an index instead
87 static GFXAdapter *getAdapterOfType( GFXAdapterType type, S32 outputDeviceIndex );
88
89 /// Converts a GFXAdapterType to a string name. Useful for writing out prefs
90 static const char *getAdapterNameFromType( GFXAdapterType type );
91
92 /// Converts a string to a GFXAdapterType. Useful for reading in prefs.
93 static GFXAdapterType getAdapterTypeFromName( const char* name );
94
95 /// Returns a GFXVideoMode that describes the current state of the main monitor.
96 /// This should probably move to the abstract window manager
97 static GFXVideoMode getDesktopResolution();
98
99 /// Based on user preferences (or in the absence of a valid user selection,
100 /// a heuristic), return a "best" adapter.
101 static GFXAdapter *getBestAdapterChoice();
102
103 /// Get the initial video mode based on user preferences (or a heuristic).
104 static GFXVideoMode getInitialVideoMode();
105private:
106 /// List of known adapters.
107 static Vector<GFXAdapter*> smAdapters;
108
109 static RegisterDeviceSignal* smRegisterDeviceSignal;
110};
111
112#endif
113