Project

General

Profile

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

magiccube / src / main / java / org / distorted / magic / RubikRenderer.java @ d12bb11b

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
package org.distorted.magic;
21
22
import android.opengl.GLSurfaceView;
23 64975793 Leszek Koltunski
import org.distorted.effect.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
   public static final int NODE_FBO_SIZE = 600;
36 47ba5ddc Leszek Koltunski
37 8becce57 Leszek Koltunski
   private RubikSurfaceView mView;
38
   private DistortedScreen mScreen;
39 47ba5ddc Leszek Koltunski
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41
42 8becce57 Leszek Koltunski
   RubikRenderer(RubikSurfaceView v)
43 47ba5ddc Leszek Koltunski
     {
44 8becce57 Leszek Koltunski
     mView = v;
45
     mScreen = new DistortedScreen();
46 47ba5ddc Leszek Koltunski
     }
47
48 0c52af30 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
49
// various things are done here delayed, 'after the next render' as not to be done mid-render and
50
// cause artifacts.
51
52 a7a7cc9c Leszek Koltunski
   @Override
53
   public void onDrawFrame(GL10 glUnused)
54
     {
55
     mScreen.render( System.currentTimeMillis() );
56 8becce57 Leszek Koltunski
     mView.getPostRender().postRender();
57 a7a7cc9c Leszek Koltunski
     }
58 0c52af30 Leszek Koltunski
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60 aa8b36aa Leszek Koltunski
61
   @Override
62
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
63
      {
64 8becce57 Leszek Koltunski
      mScreen.resize(width,height);
65 123d6172 Leszek Koltunski
      mView.setScreenSize(width,height);
66 8becce57 Leszek Koltunski
      mView.getPostRender().setScreenSize(width,height);
67 aa8b36aa Leszek Koltunski
      }
68
69
///////////////////////////////////////////////////////////////////////////////////////////////////
70
71
   @Override
72
   public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
73
      {
74
      VertexEffectSink.enable();
75 64975793 Leszek Koltunski
      BaseEffect.Type.enableEffects();
76 aa8b36aa Leszek Koltunski
77
      try
78
        {
79
        DistortedLibrary.onCreate(mView.getContext());
80
        }
81
      catch(Exception ex)
82
        {
83
        android.util.Log.e("Rubik", ex.getMessage() );
84
        }
85
      }
86
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88 0c52af30 Leszek Koltunski
89 8becce57 Leszek Koltunski
   DistortedScreen getScreen()
90 434f2f5a Leszek Koltunski
     {
91 64975793 Leszek Koltunski
     return mScreen;
92 434f2f5a Leszek Koltunski
     }
93 0c52af30 Leszek Koltunski
}