-
Notifications
You must be signed in to change notification settings - Fork 514
/
device_initialization.ts
196 lines (167 loc) · 8.97 KB
/
device_initialization.ts
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*{# Copyright (c) 2010-2012 Turbulenz Limited #}*/
/*
* @title: Device initialization
* @description:
* This sample shows how to create all the Turbulenz devices and how to discover the OS version and the hardware capabilities.
*/
/*global TurbulenzEngine: true */
TurbulenzEngine.onload = function onloadFn()
{
var systemInfo = TurbulenzEngine.getSystemInfo();
var graphicsDeviceParameters = { };
var graphicsDevice = TurbulenzEngine.createGraphicsDevice(graphicsDeviceParameters);
var physicsDeviceParameters = { };
var physicsDevice = TurbulenzEngine.createPhysicsDevice(physicsDeviceParameters);
var dynamicsWorldParameters = { };
var dynamicsWorld = physicsDevice.createDynamicsWorld(dynamicsWorldParameters);
var soundDeviceParameters = { };
var soundDevice = TurbulenzEngine.createSoundDevice(soundDeviceParameters);
var inputDeviceParameters = { };
var inputDevice = TurbulenzEngine.createInputDevice(inputDeviceParameters);
var plDiv = document.getElementById("pl_details");
var write = function(msg, elt?)
{
if (!elt)
{
elt = plDiv;
}
if (elt)
{
plDiv.innerHTML += msg;
}
else
{
window.console.log(msg);
}
};
write("<h3>Turbulenz Engine Details<\/h3>");
write(
"<ul>" +
"<li>Version: " + TurbulenzEngine.version + "<\/li>" +
"<\/ul>");
var sysDiv = document.getElementById("sys_details");
write("<h3>System Details<\/h3>", sysDiv);
write(
"<ul>" +
"<li>CpuDescription: " + systemInfo.cpuDescription + "<\/li>" +
"<li>CpuVendor: " + systemInfo.cpuVendor + "<\/li>" +
"<li>NumPhysicalCores: " + systemInfo.numPhysicalCores + "<\/li>" +
"<li>NumLogicalCores: " + systemInfo.numLogicalCores + "<\/li>" +
"<li>RamInMegabytes: " + systemInfo.ramInMegabytes + "<\/li>" +
"<li>FrequencyInMegaHz: " + systemInfo.frequencyInMegaHZ + "<\/li>" +
"<li>EngineArchitecture: " + systemInfo.architecture + "<\/li>" +
"<li>OSName: " + systemInfo.osName + "<\/li>" +
"<li>OSVersionMajor: " + systemInfo.osVersionMajor + "<\/li>" +
"<li>OSVersionMinor: " + systemInfo.osVersionMinor + "<\/li>" +
"<li>OSVersionBuild: " + systemInfo.osVersionBuild + "<\/li>" +
"<li>UserLocale: " + systemInfo.userLocale + "<\/li>" +
"<\/ul>",
sysDiv);
var gdDiv = document.getElementById("gd_details");
write("<h3>Graphics Device Details<\/h3>", gdDiv);
if (graphicsDevice)
{
write(
"<ul>" +
"<li>Vendor: " + graphicsDevice.vendor + "<\/li>" +
"<li>Renderer: " + graphicsDevice.renderer + "<\/li>" +
"<li>Renderer Version: " + graphicsDevice.rendererVersion + "<\/li>" +
"<li>Shading Language Version: " + graphicsDevice.shadingLanguageVersion + "<\/li>" +
"<li>Video Ram: " + graphicsDevice.videoRam + " MB<\/li>" +
"<li>OCCLUSION_QUERIES: " + graphicsDevice.isSupported("OCCLUSION_QUERIES") + " <\/li>" +
"<li>TIMER_QUERIES: " + graphicsDevice.isSupported("TIMER_QUERIES") + " <\/li>" +
"<li>NPOT_MIPMAPPED_TEXTURES: " + graphicsDevice.isSupported("NPOT_MIPMAPPED_TEXTURES") + " <\/li>" +
"<li>TEXTURE_DXT1: " + graphicsDevice.isSupported("TEXTURE_DXT1") + " <\/li>" +
"<li>TEXTURE_DXT3: " + graphicsDevice.isSupported("TEXTURE_DXT3") + " <\/li>" +
"<li>TEXTURE_DXT5: " + graphicsDevice.isSupported("TEXTURE_DXT5") + " <\/li>" +
"<li>TEXTURE_ETC1: " + graphicsDevice.isSupported("TEXTURE_ETC1") + " <\/li>" +
"<li>TEXTURE_HALF_FLOAT: " + graphicsDevice.isSupported("TEXTURE_HALF_FLOAT") + " <\/li>" +
"<li>TEXTURE_FLOAT: " + graphicsDevice.isSupported("TEXTURE_FLOAT") + " <\/li>" +
"<li>INDEXFORMAT_UINT: " + graphicsDevice.isSupported("INDEXFORMAT_UINT") + " <\/li>" +
"<li>VERTEX_SHADER_PRECISION: " + graphicsDevice.maxSupported("VERTEX_SHADER_PRECISION") + "-bits<\/li>" +
"<li>FRAGMENT_SHADER_PRECISION: " + graphicsDevice.maxSupported("FRAGMENT_SHADER_PRECISION") + "-bits<\/li>" +
"<li>ANISOTROPY: " + graphicsDevice.maxSupported("ANISOTROPY") + " <\/li>" +
"<li>TEXTURE_SIZE: " + graphicsDevice.maxSupported("TEXTURE_SIZE") + " <\/li>" +
"<li>CUBEMAP_TEXTURE_SIZE: " + graphicsDevice.maxSupported("CUBEMAP_TEXTURE_SIZE") + " <\/li>" +
"<li>3D_TEXTURE_SIZE: " + graphicsDevice.maxSupported("3D_TEXTURE_SIZE") + " <\/li>" +
"<li>TEXTURE_UNITS: " + graphicsDevice.maxSupported("TEXTURE_UNITS") + " <\/li>" +
"<li>VERTEX_TEXTURE_UNITS: " + graphicsDevice.maxSupported("VERTEX_TEXTURE_UNITS") + " <\/li>" +
"<li>RENDERTARGET_COLOR_TEXTURES: " + graphicsDevice.maxSupported("RENDERTARGET_COLOR_TEXTURES") + " <\/li>" +
"<li>RENDERBUFFER_SIZE: " + graphicsDevice.maxSupported("RENDERBUFFER_SIZE") + " <\/li>" +
"<li>FILEFORMAT_WEBM: " + graphicsDevice.isSupported("FILEFORMAT_WEBM") + " <\/li>" +
"<li>FILEFORMAT_MP4: " + graphicsDevice.isSupported("FILEFORMAT_MP4") + " <\/li>" +
"<li>FILEFORMAT_JPG: " + graphicsDevice.isSupported("FILEFORMAT_JPG") + " <\/li>" +
"<li>FILEFORMAT_PNG: " + graphicsDevice.isSupported("FILEFORMAT_PNG") + " <\/li>" +
"<li>FILEFORMAT_DDS: " + graphicsDevice.isSupported("FILEFORMAT_DDS") + " <\/li>" +
"<li>FILEFORMAT_TGA: " + graphicsDevice.isSupported("FILEFORMAT_TGA") + " <\/li>" +
"<li>DEPTH_TEXTURE: " + graphicsDevice.isSupported("DEPTH_TEXTURE") + " <\/li>" +
"<li>STANDARD_DERIVATIVES: " + graphicsDevice.isSupported("STANDARD_DERIVATIVES") + " <\/li>" +
"<li>Extensions: " + graphicsDevice.extensions + "<\/li>" +
"<\/ul>",
gdDiv);
}
else
{
write(
"<ul>" +
"<li>No GraphicsDevice support<\/li>" +
"<\/ul>", gdDiv);
}
var pdDiv = document.getElementById("pd_details");
write("<h3>Physics Device Details<\/h3>", pdDiv);
var gravity = dynamicsWorld.gravity;
write(
"<ul>" +
"<li>Vendor: " + physicsDevice.vendor + "<\/li>" +
"<li>Version: " + physicsDevice.version + "<\/li>" +
"<li>MaxSubSteps: " + dynamicsWorld.maxSubSteps + "<\/li>" +
"<li>FixedTimeStep: " + dynamicsWorld.fixedTimeStep + "<\/li>" +
"<li>Gravity: [" + gravity[0] + ", " + gravity[1] + ", " + gravity[2] + "]<\/li>" +
"<\/ul>", pdDiv);
var sdDiv = document.getElementById("sd_details");
write("<h3>Sound Device Details<\/h3>", sdDiv);
if (soundDevice)
{
var transform = soundDevice.listenerTransform;
var transformString = "<li>ListenerTransform: [" +
transform[0] + ", " + transform[1] + ", " + transform[2] + ", " +
transform[3] + ", " + transform[4] + ", " + transform[5] + ", " +
transform[6] + ", " + transform[7] + ", " + transform[8] + ", " +
transform[9] + ", " + transform[10] + ", " + transform[11] +
"]<\/li>";
var velocity = soundDevice.listenerVelocity;
write(
"<ul>" +
"<li>Vendor: " + soundDevice.vendor + "<\/li>" +
"<li>Renderer: " + soundDevice.renderer + "<\/li>" +
"<li>Version: " + soundDevice.version + "<\/li>" +
"<li>Device: " + soundDevice.deviceSpecifier + "<\/li>" +
"<li>Frequency: " + soundDevice.frequency + "<\/li>" +
"<li>DopplerFactor: " + soundDevice.dopplerFactor + "<\/li>" +
"<li>DopplerVelocity: " + soundDevice.dopplerVelocity + "<\/li>" +
"<li>SpeedOfSound: " + soundDevice.speedOfSound + "<\/li>" +
"<li>ListenerGain: " + soundDevice.listenerGain + "<\/li>" +
transformString +
"<li>ListenerVelocity: [" + velocity[0] + ", " + velocity[1] + ", " + velocity[2] + "]<\/li>" +
"<li>FILEFORMAT_OGG: " + soundDevice.isSupported("FILEFORMAT_OGG") + " <\/li>" +
"<li>FILEFORMAT_MP3: " + soundDevice.isSupported("FILEFORMAT_MP3") + " <\/li>" +
"<li>FILEFORMAT_M4A: " + soundDevice.isSupported("FILEFORMAT_M4A") + " <\/li>" +
"<li>FILEFORMAT_AAC: " + soundDevice.isSupported("FILEFORMAT_AAC") + " <\/li>" +
"<li>FILEFORMAT_WAV: " + soundDevice.isSupported("FILEFORMAT_WAV") + " <\/li>" +
"<li>Extensions: " + soundDevice.extensions + "<\/li>" +
"<\/ul>", sdDiv);
}
else
{
write(
"<ul>" +
"<li>No SoundDevice support<\/li>" +
"<\/ul>", sdDiv);
}
var idDiv = document.getElementById("id_details");
write("<h3>Input Device Details<\/h3>", idDiv);
write(
"<ul>" +
"<li>POINTER_LOCK: " + inputDevice.isSupported("POINTER_LOCK") + "<\/li>" +
"<\/ul>", idDiv);
};