Project

General

Profile

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

magiccube / src / main / java / org / distorted / purchase / PurchaseRenderer.java @ 71cda061

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.purchase;
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
///////////////////////////////////////////////////////////////////////////////////////////////////
26

    
27
public class PurchaseRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
28
{
29
   private final PurchaseSurfaceView mView;
30
   private final DistortedScreen mScreen;
31

    
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

    
34
   PurchaseRenderer(PurchaseSurfaceView v)
35
     {
36
     final float BRIGHTNESS = 0.333f;
37

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

    
43
///////////////////////////////////////////////////////////////////////////////////////////////////
44

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

    
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

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

    
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63

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

    
72
      DistortedLibrary.onSurfaceCreated(mView.getContext(),this,1);
73
      }
74

    
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76

    
77
   public void distortedException(Exception ex)
78
     {
79
     android.util.Log.e("PURCHASE", "unexpected exception: "+ex.getMessage() );
80
     }
81

    
82
///////////////////////////////////////////////////////////////////////////////////////////////////
83

    
84
   DistortedScreen getScreen()
85
     {
86
     return mScreen;
87
     }
88
}
(3-3/6)