1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2022 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.bandaged;
|
11
|
|
12
|
import android.app.ActivityManager;
|
13
|
import android.content.Context;
|
14
|
import android.content.pm.ConfigurationInfo;
|
15
|
import android.content.res.Resources;
|
16
|
import android.opengl.GLSurfaceView;
|
17
|
|
18
|
import org.distorted.library.effect.EffectType;
|
19
|
import org.distorted.library.effect.VertexEffectQuaternion;
|
20
|
import org.distorted.library.effect.VertexEffectRotate;
|
21
|
import org.distorted.library.main.DistortedLibrary;
|
22
|
import org.distorted.library.main.DistortedScreen;
|
23
|
import org.distorted.library.mesh.MeshBase;
|
24
|
import org.distorted.objectlib.effects.BaseEffect;
|
25
|
import org.distorted.objectlib.scrambling.ScrambleStateBandagedCuboid;
|
26
|
|
27
|
import java.io.InputStream;
|
28
|
|
29
|
import javax.microedition.khronos.egl.EGLConfig;
|
30
|
import javax.microedition.khronos.opengles.GL10;
|
31
|
|
32
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
33
|
|
34
|
public class BandagedPlayRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
35
|
{
|
36
|
private final BandagedPlayView mView;
|
37
|
private final Resources mResources;
|
38
|
private final DistortedScreen mScreen;
|
39
|
|
40
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
41
|
|
42
|
BandagedPlayRenderer(BandagedPlayView v)
|
43
|
{
|
44
|
final float BRIGHTNESS = 0.333f;
|
45
|
|
46
|
mView = v;
|
47
|
mResources = v.getResources();
|
48
|
mScreen = new DistortedScreen();
|
49
|
mScreen.glClearColor(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 1.0f);
|
50
|
}
|
51
|
|
52
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
53
|
|
54
|
@Override
|
55
|
public void onDrawFrame(GL10 glUnused)
|
56
|
{
|
57
|
long time = System.currentTimeMillis();
|
58
|
mView.getObjectControl().preRender();
|
59
|
mScreen.render(time);
|
60
|
}
|
61
|
|
62
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
63
|
|
64
|
@Override
|
65
|
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
66
|
{
|
67
|
mScreen.resize(width,height);
|
68
|
mView.setScreenSize(width,height);
|
69
|
}
|
70
|
|
71
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
72
|
|
73
|
DistortedScreen getScreen()
|
74
|
{
|
75
|
return mScreen;
|
76
|
}
|
77
|
|
78
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
79
|
|
80
|
@Override
|
81
|
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
82
|
{
|
83
|
int maxS = ScrambleStateBandagedCuboid.MAX_SUPPORTED_SIZE;
|
84
|
int numComponents = maxS*maxS*maxS - (maxS-2)*(maxS-2)*(maxS-2);
|
85
|
|
86
|
DistortedLibrary.setMax(EffectType.VERTEX,25); // 24 quaternions + rotation
|
87
|
MeshBase.setMaxEffComponents(numComponents);
|
88
|
VertexEffectRotate.enable();
|
89
|
VertexEffectQuaternion.enable();
|
90
|
BaseEffect.Type.enableEffects();
|
91
|
|
92
|
DistortedLibrary.onSurfaceCreated(this,1);
|
93
|
DistortedLibrary.setCull(true);
|
94
|
}
|
95
|
|
96
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
97
|
|
98
|
public void distortedException(Exception ex)
|
99
|
{
|
100
|
android.util.Log.e("BandagedPlay", "unexpected exception: "+ex.getMessage() );
|
101
|
}
|
102
|
|
103
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
104
|
|
105
|
public InputStream localFile(int fileID)
|
106
|
{
|
107
|
return mResources.openRawResource(fileID);
|
108
|
}
|
109
|
|
110
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
111
|
|
112
|
public void logMessage(String message)
|
113
|
{
|
114
|
android.util.Log.e("BandagedPlay", message );
|
115
|
}
|
116
|
}
|