-
Notifications
You must be signed in to change notification settings - Fork 7
/
app.cxs
151 lines (113 loc) · 2.1 KB
/
app.cxs
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
#BINARY_FILES += "|*.obj|*.b3d|*.mtl"
'' allows opengles20 on GLFW
'#OPENGL_GLES20_ENABLED=0 ''pre v75d
#If OPENGL_GLES20_ENABLED=1
Import minib3d.opengl.opengles20
#Else
Import minib3d
#Endif
Class MiniB3DApp Extends App
Global _resumed:Bool = False
Global _suspend:Bool = False
Field init:Int=0
' used by fps code
Field old_ms:Int
Field renders:Int
Field fps:Int
Field timer:Int =0
Field preload_list:StringList = New StringList
Method PreLoad(f$)
preload_list.AddLast(f)
End
Method PreLoad(f$[])
For Local s$ = Eachin f
preload_list.AddLast(s)
Next
End
Method OnCreate()
SetUpdateRate 30
SetRender()
PreLoad("mojo_font.png")
Create()
Minib3dInit()
End
Method Create()
End
Method Minib3dInit:Void()
If init Then Return
If Not TPixmap.PreLoadPixmap(preload_list.ToArray()) Then Return
init=1
Init()
init=2
End
Method Init()
End
Method OnUpdate()
If Not init
Minib3dInit()
Return
Endif
Update()
' calculate fps
If Millisecs()-old_ms >= 1000
old_ms=Millisecs()
fps=renders
renders=0
'Print "fps "+fps
Endif
End
Method Update()
End
Method OnRender()
If Not init
PreLoadRender()
Return
Endif
If _resumed
'' only reset shaders, textures on mobile
'' currently no way to detect lost context
#If TARGET="android" Or TARGET="ios" Or TARGET="winrt"
Graphics3DInit ()
ReloadAllSurfaces ()
ReloadAllTextures ()
TShader.ResetDefaultShader()
#endif
_resumed = False
Endif
Render()
RenderWorld
renders=renders+1
End
Method PreLoadRender()
End
Method Render()
End
Method OnSupsend()
_suspend=True
_resumed=false
Suspend()
End
Method Suspend()
End
Method OnResume()
_resumed = True
If _suspend
_suspend = False
'TTexture.ReloadAllTextures()
Endif
Resume()
End
Method Resume()
End
End
'' TO USE
'' extend the Minib3dApp
'' and overload Methods
''
'' Method Create ()
'' SetUpdateRate 30
'' AddPreLoad(files) here
'' End
'' Method Init ()
'' Add camera, light, and model loading, creation, texture modifying here
'' End