Project

General

Profile

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

magiccube / src / main / java / org / distorted / bandaged / BandagedCreatorRenderer.java @ f802924b

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.bandaged;
21

    
22
import android.opengl.GLSurfaceView;
23

    
24
import org.distorted.library.effect.EffectType;
25
import org.distorted.library.effect.VertexEffectQuaternion;
26
import org.distorted.library.effect.VertexEffectRotate;
27
import org.distorted.library.main.DistortedLibrary;
28
import org.distorted.library.main.DistortedScreen;
29

    
30
import javax.microedition.khronos.egl.EGLConfig;
31
import javax.microedition.khronos.opengles.GL10;
32

    
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34

    
35
public class BandagedCreatorRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
36
{
37
   private final BandagedCreatorView mView;
38
   private final DistortedScreen mScreen;
39

    
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41

    
42
   BandagedCreatorRenderer(BandagedCreatorView v)
43
     {
44
     final float BRIGHTNESS = 0.333f;
45

    
46
     mView = v;
47
     mScreen = new DistortedScreen();
48
     mScreen.glClearColor(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 1.0f);
49
     }
50

    
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52

    
53
   @Override
54
   public void onDrawFrame(GL10 glUnused)
55
     {
56
     long time = System.currentTimeMillis();
57
     mScreen.render(time);
58
     }
59

    
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61

    
62
   @Override
63
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
64
      {
65
      mScreen.resize(width,height);
66
      }
67

    
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69

    
70
   @Override
71
   public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
72
      {
73
      DistortedLibrary.setMax(EffectType.VERTEX,25);
74
      VertexEffectRotate.enable();
75
      VertexEffectQuaternion.enable();
76

    
77
      DistortedLibrary.onSurfaceCreated(mView.getContext(),this,1);
78
      }
79

    
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81

    
82
   public void distortedException(Exception ex)
83
     {
84
     android.util.Log.e("CREATOR", "unexpected exception: "+ex.getMessage() );
85
     }
86

    
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88

    
89
   DistortedScreen getScreen()
90
     {
91
     return mScreen;
92
     }
93
}
(2-2/9)