Project

General

Profile

Download (4.01 KB) Statistics
| Branch: | Revision:

phasedsolver / src / main / java / org / distorted / phasedsolver / SolverRenderer.java @ 41aff64e

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2024 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.phasedsolver;
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.PostprocessEffectGlow;
17
import org.distorted.library.effect.VertexEffectQuaternion;
18
import org.distorted.library.effect.VertexEffectRotate;
19
import org.distorted.library.main.DistortedLibrary;
20
import org.distorted.library.main.DistortedScreen;
21
import org.distorted.library.mesh.MeshBase;
22
import org.distorted.objectlib.main.ObjectControl;
23

    
24
import java.io.InputStream;
25

    
26
import javax.microedition.khronos.egl.EGLConfig;
27
import javax.microedition.khronos.opengles.GL10;
28

    
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30

    
31
class SolverRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
32
{
33
    static final float BRIGHTNESS = 0.30f;
34

    
35
    private final SolverSurfaceView mView;
36
    private final DistortedScreen mScreen;
37
    private final Resources mResources;
38

    
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40

    
41
    SolverRenderer(SolverSurfaceView v)
42
      {
43
      mView = v;
44
      mResources = v.getResources();
45
      mScreen = new DistortedScreen();
46
      mScreen.glClearColor(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 1.0f);
47
      }
48

    
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50

    
51
    DistortedScreen getScreen()
52
      {
53
      return mScreen;
54
      }
55

    
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57

    
58
    public void onDrawFrame(GL10 glUnused) 
59
      {
60
      long time = System.currentTimeMillis();
61
      mView.getObjectControl().preRender();
62
      mScreen.render(time);
63
      }
64

    
65
///////////////////////////////////////////////////////////////////////////////////////////////////
66
    
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
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
76
      {
77
      DistortedLibrary.setMax(EffectType.VERTEX,ObjectControl.MAX_QUATS+1);
78
      MeshBase.setMaxEffComponents(ObjectControl.MAX_MOVING_PARTS);
79

    
80
      VertexEffectRotate.enable();
81
      VertexEffectQuaternion.enable();
82
      PostprocessEffectGlow.enable();
83

    
84
      DistortedLibrary.onSurfaceCreated(this);
85
      }
86

    
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88

    
89
    public void distortedException(Exception ex)
90
      {
91
      android.util.Log.e("Solver", ex.getMessage() );
92
      }
93

    
94
///////////////////////////////////////////////////////////////////////////////////////////////////
95

    
96
    public InputStream localFile(int fileID)
97
      {
98
      return mResources.openRawResource(fileID);
99
      }
100

    
101
///////////////////////////////////////////////////////////////////////////////////////////////////
102

    
103
    public void logMessage(String message)
104
      {
105
      android.util.Log.e("Solver", message );
106
      }
107
}
(4-4/5)