@@ -47,10 +47,7 @@ public class Dome extends PGraphics3D {
4747 public final static int NORMAL = 0 ;
4848 public final static int GRID = 1 ;
4949
50- protected PShader cubeMapShader ;
5150 protected PShader cubeMapQuadShader ;
52- protected PShape domeSphere ;
53- protected PShape gridSphere ;
5451 protected PShape domeQuad ;
5552
5653 protected int resolution ;
@@ -64,8 +61,6 @@ public class Dome extends PGraphics3D {
6461 protected int cubeMapSize = 1024 ;
6562
6663 protected boolean renderDomeQuad = true ;
67- //protected boolean renderDome = true;
68- //protected boolean renderGrid = false;
6964 protected int currentFace ;
7065
7166 protected boolean requestedRenderDomeChange = false ;
@@ -306,86 +301,18 @@ protected int getCurrentFace() {
306301 return currentFace ;
307302 }
308303
309-
310- private void initDome () {
311- if (domeSphere == null ) {
312- domeSphere = createShape (SPHERE , resolution * 0.5f );
313- domeSphere .rotateX (HALF_PI );
314- domeSphere .setStroke (false );
315- }
316-
317- if (gridSphere == null ) {
318- gridSphere = createShape (SPHERE , resolution * 0.5f );
319- gridSphere .rotateX (HALF_PI );
320- gridSphere .setFill (0xFF000000 );
321- gridSphere .setStroke (0xFFFFFFFF );
322- }
323-
324- if (cubeMapShader == null ) {
325- cubeMapShader = parent .loadShader ("cubeMapFrag.glsl" ,
326- "cubeMapVert.glsl" );
327- cubeMapShader .set ("cubemap" , 1 );
328- }
329-
330-
331- if (!cubeMapInit ) {
332- PGL pgl = beginPGL ();
333-
334- cubeMapSize = PApplet .min (nextPowerOfTwo (resolution ), maxTextureSize );
335-
336- cubeMapTex = IntBuffer .allocate (1 );
337- pgl .genTextures (1 , cubeMapTex );
338- pgl .bindTexture (PGL .TEXTURE_CUBE_MAP , cubeMapTex .get (0 ));
339- pgl .texParameteri (PGL .TEXTURE_CUBE_MAP , PGL .TEXTURE_WRAP_S ,
340- PGL .CLAMP_TO_EDGE );
341- pgl .texParameteri (PGL .TEXTURE_CUBE_MAP , PGL .TEXTURE_WRAP_T ,
342- PGL .CLAMP_TO_EDGE );
343- pgl .texParameteri (PGL .TEXTURE_CUBE_MAP , PGL .TEXTURE_WRAP_R , PGL .CLAMP_TO_EDGE );
344- pgl .texParameteri (PGL .TEXTURE_CUBE_MAP , PGL .TEXTURE_MIN_FILTER ,
345- PGL .NEAREST );
346- pgl .texParameteri (PGL .TEXTURE_CUBE_MAP , PGL .TEXTURE_MAG_FILTER ,
347- PGL .NEAREST );
348- for (int i = PGL .TEXTURE_CUBE_MAP_POSITIVE_X ; i <
349- PGL .TEXTURE_CUBE_MAP_POSITIVE_X + 6 ; i ++) {
350- pgl .texImage2D (i , 0 , PGL .RGBA8 , cubeMapSize , cubeMapSize , 0 ,
351- PGL .RGBA , PGL .UNSIGNED_BYTE , null );
352- }
353-
354- // Init fbo, rbo
355- cubeMapFbo = IntBuffer .allocate (1 );
356- cubeMapRbo = IntBuffer .allocate (1 );
357- pgl .genFramebuffers (1 , cubeMapFbo );
358- pgl .bindFramebuffer (PGL .FRAMEBUFFER , cubeMapFbo .get (0 ));
359- pgl .framebufferTexture2D (PGL .FRAMEBUFFER , PGL .COLOR_ATTACHMENT0 ,
360- PGL .TEXTURE_CUBE_MAP_POSITIVE_X ,
361- cubeMapTex .get (0 ), 0 );
362-
363- pgl .genRenderbuffers (1 , cubeMapRbo );
364- pgl .bindRenderbuffer (PGL .RENDERBUFFER , cubeMapRbo .get (0 ));
365- pgl .renderbufferStorage (PGL .RENDERBUFFER , PGL .DEPTH_COMPONENT24 ,
366- cubeMapSize , cubeMapSize );
367-
368- // Attach depth buffer to FBO
369- pgl .framebufferRenderbuffer (PGL .FRAMEBUFFER , PGL .DEPTH_ATTACHMENT ,
370- PGL .RENDERBUFFER , cubeMapRbo .get (0 ));
371-
372- endPGL ();
373-
374- cubeMapInit = true ;
375- }
376- }
377-
378304 private void initDomeQuad () {
379305 if (domeQuad == null ) {
380306 domeQuad = createShape ();
381307 domeQuad .beginShape ();
382308 domeQuad .fill (255 ,255 ,0 );
383309 domeQuad .textureMode (NORMAL );
384310 domeQuad .noStroke ();
385- domeQuad .vertex (0 , 0 , 0 , 0 , 0 );
386- domeQuad .vertex (300 , 0 , 0 , 1 , 0 );
387- domeQuad .vertex (300 , 300 , 0 , 1 , 1 );
388- domeQuad .vertex (0 , 300 , 0 , 0 , 1 );
311+ //TODO
312+ domeQuad .vertex (-width *0.5f , -height *0.5f , 0 , 0 , 0 );
313+ domeQuad .vertex (width *0.5f , -height *0.5f , 0 , 1 , 0 );
314+ domeQuad .vertex (width *0.5f , height *0.5f , 0 , 1 , 1 );
315+ domeQuad .vertex (-width *0.5f , height *0.5f , 0 , 0 , 1 );
389316 domeQuad .endShape ();
390317 }
391318
@@ -479,44 +406,21 @@ private void endFaceDraw() {
479406 currentFace , 0 , 0 );
480407 }
481408
482- /*
483- private void renderDome() {
484- renderBorder();
485-
486- //This setting might be better for 2.1.2+:
487- //camera(0, 0, resolution * 0.5f, 0, 0, 0, 0, 1, 0);
488- //ortho(-width/2, width/2, -height/2, height/2);
489-
490- camera();
491- ortho(domeLeft, domeRight, domeBottom, domeTop);
492- resetMatrix();
493- translate(domeDX, domeDY, domeDZ);
494- scale(domeScale);
495- if (renderGrid) {
496- shape(gridSphere);
497- } else {
498- shader(cubeMapShader);
499- shape(domeSphere);
500- resetShader();
501- }
502- renderScreen();
503- }
504- */
505409 private void renderDomeQuad () {
506410 renderBorder ();
507411
508412 //This setting might be better for 2.1.2+:
509- //camera(0, 0, resolution * 0.5f, 0, 0, 0, 0, 1, 0);
510- //ortho(-width/2, width/2, -height/2, height/2);
413+ camera (0 , 0 , resolution * 0.5f , 0 , 0 , 0 , 0 , 1 , 0 );
414+ ortho (-width /2 , width /2 , -height /2 , height /2 );
415+ //ortho(-width, 0, -height, 0);
511416 /*
512417 camera();
513418 ortho(domeLeft, domeRight, domeBottom, domeTop);
419+ */
514420 resetMatrix ();
515421 translate (domeDX , domeDY , domeDZ );
516422 scale (domeScale );
517423 shader (cubeMapQuadShader );
518- */
519- resetMatrix ();
520424 shape (domeQuad );
521425 resetShader ();
522426 renderScreen ();
0 commit comments