Project

General

Profile

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

magiccube / src / main / java / org / distorted / main / RubikRenderer.java @ 1f9772f3

1 0c52af30 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4 fdec60a3 Leszek Koltunski
// This file is part of Magic Cube.                                                              //
5 0c52af30 Leszek Koltunski
//                                                                                               //
6 fdec60a3 Leszek Koltunski
// Magic Cube is free software: you can redistribute it and/or modify                            //
7 0c52af30 Leszek Koltunski
// 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 fdec60a3 Leszek Koltunski
// Magic Cube is distributed in the hope that it will be useful,                                 //
12 0c52af30 Leszek Koltunski
// 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 fdec60a3 Leszek Koltunski
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18 0c52af30 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
19
20 1f9772f3 Leszek Koltunski
package org.distorted.main;
21 0c52af30 Leszek Koltunski
22
import android.opengl.GLSurfaceView;
23 1f9772f3 Leszek Koltunski
import org.distorted.effects.BaseEffect;
24 0c52af30 Leszek Koltunski
import org.distorted.library.effect.VertexEffectSink;
25 e1111500 Leszek Koltunski
import org.distorted.library.main.DistortedLibrary;
26 0c52af30 Leszek Koltunski
import org.distorted.library.main.DistortedScreen;
27
28
import javax.microedition.khronos.egl.EGLConfig;
29
import javax.microedition.khronos.opengles.GL10;
30
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32
33 8becce57 Leszek Koltunski
public class RubikRenderer implements GLSurfaceView.Renderer
34 0c52af30 Leszek Koltunski
{
35 8becce57 Leszek Koltunski
   private RubikSurfaceView mView;
36
   private DistortedScreen mScreen;
37 47ba5ddc Leszek Koltunski
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39
40 8becce57 Leszek Koltunski
   RubikRenderer(RubikSurfaceView v)
41 47ba5ddc Leszek Koltunski
     {
42 8becce57 Leszek Koltunski
     mView = v;
43
     mScreen = new DistortedScreen();
44 47ba5ddc Leszek Koltunski
     }
45
46 0c52af30 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
47
// various things are done here delayed, 'after the next render' as not to be done mid-render and
48
// cause artifacts.
49
50 a7a7cc9c Leszek Koltunski
   @Override
51
   public void onDrawFrame(GL10 glUnused)
52
     {
53
     mScreen.render( System.currentTimeMillis() );
54 8becce57 Leszek Koltunski
     mView.getPostRender().postRender();
55 a7a7cc9c Leszek Koltunski
     }
56 0c52af30 Leszek Koltunski
57
///////////////////////////////////////////////////////////////////////////////////////////////////
58 aa8b36aa Leszek Koltunski
59
   @Override
60
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
61
      {
62 8becce57 Leszek Koltunski
      mScreen.resize(width,height);
63 123d6172 Leszek Koltunski
      mView.setScreenSize(width,height);
64 8becce57 Leszek Koltunski
      mView.getPostRender().setScreenSize(width,height);
65 aa8b36aa Leszek Koltunski
      }
66
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68
69
   @Override
70
   public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
71
      {
72
      VertexEffectSink.enable();
73 64975793 Leszek Koltunski
      BaseEffect.Type.enableEffects();
74 aa8b36aa Leszek Koltunski
75
      try
76
        {
77
        DistortedLibrary.onCreate(mView.getContext());
78
        }
79
      catch(Exception ex)
80
        {
81
        android.util.Log.e("Rubik", ex.getMessage() );
82
        }
83
      }
84
85
///////////////////////////////////////////////////////////////////////////////////////////////////
86 0c52af30 Leszek Koltunski
87 8becce57 Leszek Koltunski
   DistortedScreen getScreen()
88 434f2f5a Leszek Koltunski
     {
89 64975793 Leszek Koltunski
     return mScreen;
90 434f2f5a Leszek Koltunski
     }
91 0c52af30 Leszek Koltunski
}