-
Notifications
You must be signed in to change notification settings - Fork 110
/
LuaConstPlatform.cpp
117 lines (98 loc) · 5.17 KB
/
LuaConstPlatform.cpp
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
116
117
/* This file is part of the Spring System (GPL v2 or later), see LICENSE.html */
#include "LuaConstPlatform.h"
#include "LuaUtils.h"
#include "System/Platform/Misc.h"
#include "Rendering/GlobalRendering.h"
#include "Rendering/GlobalRenderingInfo.h"
/******************************************************************************
* Platform constants
* @module Platform
* @see rts/Lua/LuaConstPlatform.cpp
******************************************************************************/
/*** Platform specific information
*
* @table Platform
* @string gpu full GPU device name
* @string gpuVendor one of "Nvidia", "Intel", "ATI", "Mesa", "Unknown"
* @string glVersionShort major.minor.buildNumber
* @string glslVersionShort major.minor
* @string glVersion full version
* @string glVendor
* @string glRenderer
* @string glslVersion full version
* @string glewVersion
* @string osName full name of the OS
* @string osFamily one of "Windows", "Linux", "MacOSX", "FreeBSD", "Unknown"
* @number numDisplays
* @number gpuMemorySize size of total GPU memory in MBs; only available for "Nvidia", (rest are 0)
* @number sdlVersionCompiledMajor
* @number sdlVersionCompiledMinor
* @number sdlVersionCompiledPatch
* @number sdlVersionLinkedMajor
* @number sdlVersionLinkedMinor
* @number sdlVersionLinkedPatch
* @bool glSupportNonPowerOfTwoTex
* @bool glSupportTextureQueryLOD
* @bool glSupport24bitDepthBuffer
* @bool glSupportRestartPrimitive
* @bool glSupportClipSpaceControl
* @bool glSupportFragDepthLayout
*/
bool LuaConstPlatform::PushEntries(lua_State* L)
{
LuaPushNamedString(L, "gpu", globalRenderingInfo.gpuName);
LuaPushNamedString(L, "gpuVendor", globalRenderingInfo.gpuVendor);
LuaPushNamedNumber(L, "gpuMemorySize", globalRenderingInfo.gpuMemorySize.x);
LuaPushNamedString(L, "glVersionShort", globalRenderingInfo.glVersionShort.data());
LuaPushNamedString(L, "glslVersionShort", globalRenderingInfo.glslVersionShort.data());
LuaPushNamedNumber(L, "glslVersionNum", globalRenderingInfo.glslVersionNum);
LuaPushNamedString(L, "glVersion", globalRenderingInfo.glVersion);
LuaPushNamedString(L, "glVendor", globalRenderingInfo.glVendor);
LuaPushNamedString(L, "glRenderer", globalRenderingInfo.glRenderer);
LuaPushNamedString(L, "glslVersion", globalRenderingInfo.glslVersion);
LuaPushNamedString(L, "glewVersion", globalRenderingInfo.glewVersion);
LuaPushNamedNumber(L, "sdlVersionCompiledMajor", globalRenderingInfo.sdlVersionCompiled.major);
LuaPushNamedNumber(L, "sdlVersionCompiledMinor", globalRenderingInfo.sdlVersionCompiled.minor);
LuaPushNamedNumber(L, "sdlVersionCompiledPatch", globalRenderingInfo.sdlVersionCompiled.patch);
LuaPushNamedNumber(L, "sdlVersionLinkedMajor", globalRenderingInfo.sdlVersionLinked.major);
LuaPushNamedNumber(L, "sdlVersionLinkedMinor", globalRenderingInfo.sdlVersionLinked.minor);
LuaPushNamedNumber(L, "sdlVersionLinkedPatch", globalRenderingInfo.sdlVersionLinked.patch);
lua_pushstring(L, "availableVideoModes");
lua_createtable(L, 0, globalRenderingInfo.availableVideoModes.size());
for (int i = 0; i < globalRenderingInfo.availableVideoModes.size(); ++i) {
lua_pushnumber(L, i + 1);
lua_createtable(L, 0, 6);
const auto& avm = globalRenderingInfo.availableVideoModes[i];
LuaPushNamedNumber(L, "display", avm.displayIndex);
LuaPushNamedString(L, "displayName", avm.displayName);
LuaPushNamedNumber(L, "w", avm.width);
LuaPushNamedNumber(L, "h", avm.height);
LuaPushNamedNumber(L, "bpp", avm.bpp);
LuaPushNamedNumber(L, "hz", avm.refreshRate);
lua_rawset(L, -3);
}
lua_rawset(L, -3);
LuaPushNamedNumber(L, "numDisplays", globalRendering->numDisplays);
LuaPushNamedBool(L, "glSupportNonPowerOfTwoTex", globalRendering->supportNonPowerOfTwoTex);
LuaPushNamedBool(L, "glSupportTextureQueryLOD" , globalRendering->supportTextureQueryLOD);
LuaPushNamedBool(L, "glSupportMSAAFrameBuffer" , globalRendering->supportMSAAFrameBuffer);
LuaPushNamedBool(L, "glHaveAMD", globalRendering->haveAMD);
LuaPushNamedBool(L, "glHaveNVidia", globalRendering->haveNvidia);
LuaPushNamedBool(L, "glHaveIntel", globalRendering->haveIntel);
LuaPushNamedBool(L, "glHaveGLSL", true);
LuaPushNamedBool(L, "glHaveGL4", globalRendering->haveGL4);
LuaPushNamedNumber(L, "glSupportDepthBufferBitDepth", globalRendering->supportDepthBufferBitDepth);
LuaPushNamedBool(L, "glSupportRestartPrimitive", globalRendering->supportRestartPrimitive);
LuaPushNamedBool(L, "glSupportClipSpaceControl", globalRendering->supportClipSpaceControl);
LuaPushNamedBool(L, "glSupportFragDepthLayout" , globalRendering->supportFragDepthLayout);
LuaPushNamedBool(L, "glSupportSeamlessCubeMaps", globalRendering->supportSeamlessCubeMaps);
LuaPushNamedString(L, "osName", Platform::GetOSNameStr());
LuaPushNamedString(L, "osVersion", Platform::GetOSVersionStr());
LuaPushNamedString(L, "osFamily", Platform::GetOSFamilyStr());
LuaPushNamedString(L, "hwConfig", Platform::GetHardwareStr());
LuaPushNamedNumber(L, "cpuLogicalCores", Threading::GetLogicalCpuCores());
LuaPushNamedNumber(L, "cpuPhysicalCores", Threading::GetPhysicalCpuCores());
LuaPushNamedString(L, "sysInfoHash", Platform::GetSysInfoHash());
LuaPushNamedString(L, "macAddrHash", Platform::GetMacAddrHash());
return true;
}