Project

General

Profile

Download (3.6 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / bandaged / BandagedPlayRenderer.java @ 306aa049

1 9530f6b0 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2 da56b12f Leszek Koltunski
// Copyright 2022 Leszek Koltunski                                                               //
3 9530f6b0 Leszek Koltunski
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6 44fec653 Leszek Koltunski
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8 9530f6b0 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
9
10
package org.distorted.bandaged;
11
12
import android.opengl.GLSurfaceView;
13
14
import org.distorted.library.effect.EffectType;
15
import org.distorted.library.effect.VertexEffectQuaternion;
16
import org.distorted.library.effect.VertexEffectRotate;
17
import org.distorted.library.main.DistortedLibrary;
18
import org.distorted.library.main.DistortedScreen;
19 6dff7924 Leszek Koltunski
import org.distorted.library.mesh.MeshBase;
20 9530f6b0 Leszek Koltunski
import org.distorted.objectlib.effects.BaseEffect;
21 306aa049 Leszek Koltunski
import org.distorted.objectlib.scrambling.ScrambleStateBandagedCuboid;
22 9530f6b0 Leszek Koltunski
23
import javax.microedition.khronos.egl.EGLConfig;
24
import javax.microedition.khronos.opengles.GL10;
25
26
///////////////////////////////////////////////////////////////////////////////////////////////////
27
28
public class BandagedPlayRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
29
{
30
   private final BandagedPlayView mView;
31
   private final DistortedScreen mScreen;
32
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34
35
   BandagedPlayRenderer(BandagedPlayView v)
36
     {
37
     final float BRIGHTNESS = 0.333f;
38
39
     mView = v;
40
     mScreen = new DistortedScreen();
41
     mScreen.glClearColor(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 1.0f);
42
     }
43
44
///////////////////////////////////////////////////////////////////////////////////////////////////
45
46
   @Override
47
   public void onDrawFrame(GL10 glUnused)
48
     {
49
     long time = System.currentTimeMillis();
50
     mView.getObjectControl().preRender();
51
     mScreen.render(time);
52
     }
53
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55
56
   @Override
57
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
58
      {
59
      mScreen.resize(width,height);
60
      mView.setScreenSize(width,height);
61
      }
62
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64
65
   @Override
66
   public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
67
      {
68 306aa049 Leszek Koltunski
      int maxS = ScrambleStateBandagedCuboid.MAX_SUPPORTED_SIZE;
69
      int numComponents = maxS*maxS*maxS - (maxS-2)*(maxS-2)*(maxS-2);
70
71 af3f487c Leszek Koltunski
      DistortedLibrary.setMax(EffectType.VERTEX,25); // 24 quaternions + rotation
72 306aa049 Leszek Koltunski
      MeshBase.setMaxEffComponents(numComponents);
73 9530f6b0 Leszek Koltunski
      VertexEffectRotate.enable();
74
      VertexEffectQuaternion.enable();
75
      BaseEffect.Type.enableEffects();
76
77
      DistortedLibrary.onSurfaceCreated(mView.getContext(),this,1);
78 6dff7924 Leszek Koltunski
      DistortedLibrary.setCull(true);
79 9530f6b0 Leszek Koltunski
      }
80
81
///////////////////////////////////////////////////////////////////////////////////////////////////
82
83
   public void distortedException(Exception ex)
84
     {
85
     android.util.Log.e("BandagedPlay", "unexpected exception: "+ex.getMessage() );
86
     }
87
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89
90
   DistortedScreen getScreen()
91
     {
92
     return mScreen;
93
     }
94
}