-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathResources.qml
74 lines (62 loc) · 2.12 KB
/
Resources.qml
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
pragma Singleton
import QtQuick 2.9
Item { // This is the global resource router
readonly property var os2Prefix: {
// Compatibility for QML Creator
"android" : "file:/sdcard/Documents/QML Projects/Examples" ,
// "android" : "assets://" ,
"linux" : "file:.." ,
"osx" : "file:.." ,
"unix" : "file:.." ,
"windows" : "file:.." ,
"winrt" : "file:." ,
}
property bool appRcEnabled: false
property bool assetsRcEnabled: false
function setGlInfo(info) {
if (info.profile === GraphicsInfo.OpenGLCoreProfile) {
shaderType = "gl33";
} else {
if (info.majorVersion >= 3) {
shaderType = "es30";
} else {
shaderType = "es20";
}
}
var text = "Open%4 %1.%2 %3".arg(info.majorVersion)
.arg(info.minorVersion).arg({
0: "NoProfile",
1: "CoreProfile",
2: "CompatibilityProfile"
}[info.profile]).arg({
0: "Unspecified",
1: "GL",
2: "GLES"
}[info.renderableType])
;
console.log("[Resources] format: %1".arg(text));
console.log("[Resources] shaderType: %1".arg(shaderType));
}
property string appPrefix: (appRcEnabled?"qrc:":os2Prefix[Qt.platform.os])+ "/"
property string assetsPrefix: (assetsRcEnabled?"qrc:":os2Prefix[Qt.platform.os])+ "/"
property string shaderType: "gl33"
readonly property string shaderPrefix: appPrefix + "shared/shaders/" + shaderType + "/"
function shader(fn){return shaderPrefix + fn;}
readonly property string texturePrefix: assetsPrefix + "shared/assets/texture/"
function texture(fn){return texturePrefix + fn;}
readonly property string imagePrefix: assetsPrefix + "shared/assets/image/"
function image(fn){return imagePrefix + fn;}
readonly property string meshPrefix: assetsPrefix + "shared/assets/mesh/"
function mesh(fn){return meshPrefix + fn;}
readonly property string modelPrefix: assetsPrefix + "shared/assets/model/"
function model(fn){return modelPrefix + fn;}
onAppPrefixChanged: {
console.log("[Resources] app: %1 : %2".arg(appRcEnabled).arg(appPrefix));
}
onAssetsPrefixChanged: {
console.log("[Resources] assets: %1 : %2".arg(assetsRcEnabled).arg(assetsPrefix));
}
Component.onCompleted: {
setGlInfo(GraphicsInfo);
}
}