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.info;
|
11
|
|
12
|
import android.content.res.Resources;
|
13
|
import android.opengl.GLSurfaceView;
|
14
|
|
15
|
import org.distorted.library.effect.EffectType;
|
16
|
import org.distorted.library.effect.VertexEffectQuaternion;
|
17
|
import org.distorted.library.effect.VertexEffectRotate;
|
18
|
import org.distorted.library.main.DistortedLibrary;
|
19
|
import org.distorted.library.main.DistortedScreen;
|
20
|
import org.distorted.objectlib.effects.BaseEffect;
|
21
|
import org.distorted.objectlib.main.ObjectControl;
|
22
|
|
23
|
import java.io.InputStream;
|
24
|
|
25
|
import javax.microedition.khronos.egl.EGLConfig;
|
26
|
import javax.microedition.khronos.opengles.GL10;
|
27
|
|
28
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
29
|
|
30
|
public class InfoRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
31
|
{
|
32
|
private final InfoSurfaceView mView;
|
33
|
private final Resources mResources;
|
34
|
private final DistortedScreen mScreen;
|
35
|
|
36
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
37
|
|
38
|
InfoRenderer(InfoSurfaceView v)
|
39
|
{
|
40
|
mView = v;
|
41
|
mResources = v.getResources();
|
42
|
mScreen = new DistortedScreen();
|
43
|
|
44
|
InfoActivity act = (InfoActivity)v.getContext();
|
45
|
act.setUpBackgroundColor(mScreen);
|
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
|
|
58
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
59
|
|
60
|
@Override
|
61
|
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
62
|
{
|
63
|
mScreen.resize(width,height);
|
64
|
mView.setScreenSize(width,height);
|
65
|
}
|
66
|
|
67
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
68
|
|
69
|
DistortedScreen getScreen()
|
70
|
{
|
71
|
return mScreen;
|
72
|
}
|
73
|
|
74
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
75
|
|
76
|
@Override
|
77
|
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
78
|
{
|
79
|
DistortedLibrary.setMax(EffectType.VERTEX, ObjectControl.MAX_QUATS+1);
|
80
|
VertexEffectRotate.enable();
|
81
|
VertexEffectQuaternion.enable();
|
82
|
BaseEffect.Type.enableEffects();
|
83
|
|
84
|
DistortedLibrary.onSurfaceCreated(this,1);
|
85
|
DistortedLibrary.setCull(true);
|
86
|
}
|
87
|
|
88
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
89
|
|
90
|
public void distortedException(Exception ex)
|
91
|
{
|
92
|
android.util.Log.e("Info", "unexpected exception: "+ex.getMessage() );
|
93
|
}
|
94
|
|
95
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
96
|
|
97
|
public InputStream localFile(int fileID)
|
98
|
{
|
99
|
return mResources.openRawResource(fileID);
|
100
|
}
|
101
|
|
102
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
103
|
|
104
|
public void logMessage(String message)
|
105
|
{
|
106
|
android.util.Log.e("Info", message );
|
107
|
}
|
108
|
}
|