1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2016 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Distorted. //
|
5
|
// //
|
6
|
// Distorted is free software: you can redistribute it and/or modify //
|
7
|
// it under the terms of the GNU General Public License as published by //
|
8
|
// the Free Software Foundation, either version 2 of the License, or //
|
9
|
// (at your option) any later version. //
|
10
|
// //
|
11
|
// Distorted is distributed in the hope that it will be useful, //
|
12
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14
|
// GNU General Public License for more details. //
|
15
|
// //
|
16
|
// You should have received a copy of the GNU General Public License //
|
17
|
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19
|
|
20
|
package org.distorted.examples.matrix3d;
|
21
|
|
22
|
import android.opengl.GLES20;
|
23
|
import android.opengl.GLSurfaceView;
|
24
|
|
25
|
import org.distorted.library.Distorted;
|
26
|
import org.distorted.library.DistortedObject;
|
27
|
import org.distorted.library.EffectTypes;
|
28
|
|
29
|
import javax.microedition.khronos.egl.EGLConfig;
|
30
|
import javax.microedition.khronos.opengles.GL10;
|
31
|
|
32
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
33
|
|
34
|
class Matrix3DRenderer implements GLSurfaceView.Renderer
|
35
|
{
|
36
|
private GLSurfaceView mView;
|
37
|
private DistortedObject mObject;
|
38
|
|
39
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
40
|
|
41
|
Matrix3DRenderer(GLSurfaceView v)
|
42
|
{
|
43
|
mView = v;
|
44
|
|
45
|
mObject= ((Matrix3DActivity)v.getContext()).getObject();
|
46
|
}
|
47
|
|
48
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
49
|
|
50
|
public void onDrawFrame(GL10 glUnused)
|
51
|
{
|
52
|
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
|
53
|
|
54
|
long time = System.currentTimeMillis();
|
55
|
|
56
|
mObject.draw(time);
|
57
|
}
|
58
|
|
59
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
60
|
|
61
|
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
62
|
{
|
63
|
mObject.abortEffects(EffectTypes.MATRIX);
|
64
|
|
65
|
Distorted.onSurfaceChanged(width, height);
|
66
|
}
|
67
|
|
68
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
69
|
|
70
|
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
71
|
{
|
72
|
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
73
|
|
74
|
Matrix3DActivity act = (Matrix3DActivity)mView.getContext();
|
75
|
|
76
|
mObject.setBitmap( act.getBitmap() );
|
77
|
|
78
|
try
|
79
|
{
|
80
|
Distorted.onSurfaceCreated(mView.getContext());
|
81
|
}
|
82
|
catch(Exception ex)
|
83
|
{
|
84
|
android.util.Log.e("Matrix3D", ex.getMessage() );
|
85
|
}
|
86
|
}
|
87
|
}
|