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.PostprocessEffectGlow;
|
16
|
import org.distorted.library.main.DistortedLibrary;
|
17
|
import org.distorted.library.main.DistortedScreen;
|
18
|
import org.distorted.objectlib.main.ObjectControl;
|
19
|
import org.distorted.overlays.OverlayStars;
|
20
|
|
21
|
import javax.microedition.khronos.egl.EGLConfig;
|
22
|
import javax.microedition.khronos.opengles.GL10;
|
23
|
|
24
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
25
|
|
26
|
public class PurchaseRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
27
|
{
|
28
|
private static final int NUM_SCRAMBLES = 5;
|
29
|
private static final int DURATION = NUM_SCRAMBLES*2*1000;
|
30
|
|
31
|
private final PurchaseSurfaceView mView;
|
32
|
private final DistortedScreen mScreen;
|
33
|
|
34
|
private boolean mFirstRender;
|
35
|
|
36
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
37
|
|
38
|
PurchaseRenderer(PurchaseSurfaceView v)
|
39
|
{
|
40
|
final float BRIGHTNESS = 0.333f;
|
41
|
|
42
|
mFirstRender = true;
|
43
|
mView = v;
|
44
|
mScreen = new DistortedScreen();
|
45
|
mScreen.glClearColor(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 1.0f);
|
46
|
}
|
47
|
|
48
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
49
|
|
50
|
@Override
|
51
|
public void onDrawFrame(GL10 glUnused)
|
52
|
{
|
53
|
long time = System.currentTimeMillis();
|
54
|
mView.getObjectControl().preRender();
|
55
|
mScreen.render(time);
|
56
|
|
57
|
if( mFirstRender )
|
58
|
{
|
59
|
mFirstRender=false;
|
60
|
mView.getObjectControl().presentObject(NUM_SCRAMBLES, DURATION);
|
61
|
}
|
62
|
}
|
63
|
|
64
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
65
|
|
66
|
@Override
|
67
|
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
68
|
{
|
69
|
mScreen.resize(width,height);
|
70
|
mView.setScreenSize(width,height);
|
71
|
}
|
72
|
|
73
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
74
|
|
75
|
@Override
|
76
|
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
77
|
{
|
78
|
DistortedLibrary.setMax(EffectType.VERTEX, ObjectControl.MAX_QUATS+1);
|
79
|
OverlayStars.enableEffects();
|
80
|
PostprocessEffectGlow.enable();
|
81
|
|
82
|
DistortedLibrary.onSurfaceCreated(mView.getContext(),this,1);
|
83
|
DistortedLibrary.setCull(true);
|
84
|
}
|
85
|
|
86
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
87
|
|
88
|
public void distortedException(Exception ex)
|
89
|
{
|
90
|
android.util.Log.e("PURCHASE", "unexpected exception: "+ex.getMessage() );
|
91
|
}
|
92
|
|
93
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
94
|
|
95
|
DistortedScreen getScreen()
|
96
|
{
|
97
|
return mScreen;
|
98
|
}
|
99
|
}
|