@@ -68,18 +68,20 @@ public class Dome extends PGraphics3D {
68
68
protected boolean requestedRenderDomeChange = false ;
69
69
protected boolean requestedRenderDome ;
70
70
71
+ protected float domeLeft , domeRight , domeTop , domeBottom ;
71
72
protected float domeDX , domeDY , domeDZ ;
72
73
protected float domeScale = 1 ;
73
74
74
- protected Method borderMethod ;
75
+ protected Method borderMethod ;
76
+ protected Method screenMethod ;
75
77
76
78
/**
77
79
* The default constructor.
78
80
*
79
81
*/
80
82
public Dome () {
81
83
super ();
82
- welcome ();
84
+ welcome ();
83
85
}
84
86
85
87
@@ -109,6 +111,11 @@ public void setParent(PApplet parent) {
109
111
borderMethod = parent .getClass ().getMethod ("border" , new Class [] {});
110
112
} catch (Exception e ) {
111
113
}
114
+
115
+ try {
116
+ screenMethod = parent .getClass ().getMethod ("screen" , new Class [] {});
117
+ } catch (Exception e ) {
118
+ }
112
119
}
113
120
114
121
@@ -128,6 +135,10 @@ public void setSize(int iwidth, int iheight) {
128
135
resolution = iwidth ;
129
136
offsetX = offsetY = 0 ;
130
137
}
138
+ domeLeft = 0 ;
139
+ domeRight = iwidth ;
140
+ domeBottom = 0 ;
141
+ domeTop = iheight ;
131
142
super .setSize (iwidth , iheight );
132
143
}
133
144
@@ -204,14 +215,18 @@ public void beginDraw() {
204
215
}
205
216
requestedRenderDomeChange = false ;
206
217
}
207
-
218
+
208
219
if (renderDome && 0 < parent .frameCount ) {
209
220
if (!cubeMapInit ) {
210
221
initDome ();
211
222
}
212
-
223
+
213
224
beginPGL ();
214
-
225
+
226
+ pgl .activeTexture (PGL .TEXTURE1 );
227
+ pgl .enable (PGL .TEXTURE_CUBE_MAP );
228
+ pgl .bindTexture (PGL .TEXTURE_CUBE_MAP , cubeMapTex .get (0 ));
229
+
215
230
// bind fbo
216
231
pgl .bindFramebuffer (PGL .FRAMEBUFFER , cubeMapFbo .get (0 ));
217
232
@@ -230,19 +245,29 @@ public void endDraw() {
230
245
// Draw the rest of the cubemap faces
231
246
for (int face = PGL .TEXTURE_CUBE_MAP_NEGATIVE_X ;
232
247
face <= PGL .TEXTURE_CUBE_MAP_POSITIVE_Z ; face ++) {
233
- beginFaceDraw (face );
248
+ beginFaceDraw (face );
234
249
parent .draw ();
235
250
endFaceDraw ();
236
251
}
237
-
252
+
238
253
endPGL ();
239
-
240
254
renderDome ();
241
- }
255
+ pgl .disable (PGL .TEXTURE_CUBE_MAP );
256
+ pgl .bindTexture (PGL .TEXTURE_CUBE_MAP , 0 );
257
+
258
+ }
242
259
super .endDraw ();
243
260
}
244
261
245
262
263
+ protected void setOrthoParams (float left , float right , float bottom , float top ) {
264
+ domeLeft = left ;
265
+ domeRight = right ;
266
+ domeBottom = bottom ;
267
+ domeTop = top ;
268
+ }
269
+
270
+
246
271
protected void setOrigin (float dx , float dy , float dz ) {
247
272
domeDX = dx ;
248
273
domeDY = dy ;
@@ -334,10 +359,6 @@ private void initDome() {
334
359
// Attach depth buffer to FBO
335
360
pgl .framebufferRenderbuffer (PGL .FRAMEBUFFER , PGL .DEPTH_ATTACHMENT ,
336
361
PGL .RENDERBUFFER , cubeMapRbo .get (0 ));
337
-
338
- pgl .enable (PGL .TEXTURE_CUBE_MAP );
339
- pgl .activeTexture (PGL .TEXTURE1 );
340
- pgl .bindTexture (PGL .TEXTURE_CUBE_MAP , cubeMapTex .get (0 ));
341
362
342
363
endPGL ();
343
364
@@ -383,8 +404,8 @@ private void endFaceDraw() {
383
404
384
405
private void renderDome () {
385
406
renderBorder ();
386
- camera (0 , 0 , resolution * 0.5f + domeDZ , 0 , 0 , 0 , 0 , 1 , 0 );
387
- ortho (- width / 2 , width / 2 , - height / 2 , height / 2 );
407
+ camera ();
408
+ ortho (domeLeft , domeRight , domeBottom , domeTop );
388
409
resetMatrix ();
389
410
translate (domeDX , domeDY , domeDZ );
390
411
scale (domeScale );
@@ -395,6 +416,7 @@ private void renderDome() {
395
416
shape (domeSphere );
396
417
resetShader ();
397
418
}
419
+ renderScreen ();
398
420
}
399
421
400
422
@@ -408,6 +430,16 @@ private void renderBorder() {
408
430
}
409
431
}
410
432
433
+ private void renderScreen () {
434
+ if (screenMethod != null ) {
435
+ try {
436
+ screenMethod .invoke (parent , new Object [] {});
437
+ } catch (Exception e ) {
438
+ e .printStackTrace ();
439
+ }
440
+ }
441
+ }
442
+
411
443
412
444
private static int nextPowerOfTwo (int val ) {
413
445
int ret = 1 ;
0 commit comments