1 |
1237d25d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2019 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Magic Cube. //
|
5 |
|
|
// //
|
6 |
9d51b9d6
|
Leszek Koltunski
|
// 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 |
1237d25d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 |
34bc9f31
|
Leszek Koltunski
|
import org.distorted.objectlib.main.ObjectControl;
|
21 |
1237d25d
|
Leszek Koltunski
|
|
22 |
|
|
import javax.microedition.khronos.egl.EGLConfig;
|
23 |
|
|
import javax.microedition.khronos.opengles.GL10;
|
24 |
|
|
|
25 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
26 |
|
|
|
27 |
|
|
public class ConfigRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
28 |
|
|
{
|
29 |
|
|
private final ConfigSurfaceView mView;
|
30 |
|
|
private final DistortedScreen mScreen;
|
31 |
|
|
|
32 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
33 |
|
|
|
34 |
|
|
ConfigRenderer(ConfigSurfaceView v)
|
35 |
|
|
{
|
36 |
97a4ae23
|
Leszek Koltunski
|
final float BRIGHTNESS = 0.333f;
|
37 |
1237d25d
|
Leszek Koltunski
|
|
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 |
34bc9f31
|
Leszek Koltunski
|
DistortedLibrary.setMax(EffectType.VERTEX, ObjectControl.MAX_QUATS+1);
|
68 |
1237d25d
|
Leszek Koltunski
|
VertexEffectRotate.enable();
|
69 |
|
|
VertexEffectQuaternion.enable();
|
70 |
|
|
BaseEffect.Type.enableEffects();
|
71 |
|
|
|
72 |
|
|
DistortedLibrary.onSurfaceCreated(mView.getContext(),this,1);
|
73 |
af0710b6
|
Leszek Koltunski
|
DistortedLibrary.setCull(true);
|
74 |
1237d25d
|
Leszek Koltunski
|
}
|
75 |
|
|
|
76 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
77 |
|
|
|
78 |
|
|
public void distortedException(Exception ex)
|
79 |
|
|
{
|
80 |
|
|
android.util.Log.e("CONFIG", "unexpected exception: "+ex.getMessage() );
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
84 |
|
|
|
85 |
|
|
DistortedScreen getScreen()
|
86 |
|
|
{
|
87 |
|
|
return mScreen;
|
88 |
|
|
}
|
89 |
|
|
}
|