Project

General

Profile

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

magiccube / src / main / java / org / distorted / config / ConfigRenderer.java @ af0710b6

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// 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
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
package org.distorted.config;
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
import org.distorted.objectlib.effects.BaseEffect;
20
import org.distorted.objectlib.main.ObjectControl;
21

    
22
import javax.microedition.khronos.egl.EGLConfig;
23
import javax.microedition.khronos.opengles.GL10;
24

    
25
import static org.distorted.config.ConfigScreenPane.PADDING_RATIO;
26

    
27
///////////////////////////////////////////////////////////////////////////////////////////////////
28

    
29
public class ConfigRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
30
{
31
   private final ConfigSurfaceView mView;
32
   private final DistortedScreen mScreen;
33

    
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

    
36
   ConfigRenderer(ConfigSurfaceView v)
37
     {
38
     final float BRIGHTNESS = 0.333f;
39

    
40
     mView = v;
41
     mScreen = new DistortedScreen();
42
     mScreen.glClearColor(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 1.0f);
43
     }
44

    
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46

    
47
   @Override
48
   public void onDrawFrame(GL10 glUnused)
49
     {
50
     long time = System.currentTimeMillis();
51
     mView.getObjectControl().preRender();
52
     mScreen.render(time);
53
     }
54

    
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56

    
57
   @Override
58
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
59
      {
60
      mScreen.resize(width,height);
61
      mView.setScreenSize(width,height);
62
      }
63

    
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65

    
66
   @Override
67
   public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
68
      {
69
      DistortedLibrary.setMax(EffectType.VERTEX, ObjectControl.MAX_QUATS+1);
70
      VertexEffectRotate.enable();
71
      VertexEffectQuaternion.enable();
72
      BaseEffect.Type.enableEffects();
73

    
74
      DistortedLibrary.onSurfaceCreated(mView.getContext(),this,1);
75
      DistortedLibrary.setCull(true);
76
      }
77

    
78
///////////////////////////////////////////////////////////////////////////////////////////////////
79

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

    
85
///////////////////////////////////////////////////////////////////////////////////////////////////
86

    
87
   DistortedScreen getScreen()
88
     {
89
     return mScreen;
90
     }
91
}
(3-3/6)