Project

General

Profile

Download (3.48 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / tutorial / TutorialRenderer.java @ af88bf2e

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube 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
// Magic Cube 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 Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.tutorial;
21

    
22
import android.opengl.GLSurfaceView;
23

    
24
import org.distorted.library.main.DistortedScreen;
25

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

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

    
31
public class TutorialRenderer implements GLSurfaceView.Renderer
32
{
33
   private TutorialSurfaceView mView;
34
   private DistortedScreen mScreen;
35

    
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37

    
38
   TutorialRenderer(TutorialSurfaceView v)
39
     {
40
     final float BRIGHTNESS = 0.30f;
41

    
42
     mView = v;
43
     mScreen = new DistortedScreen();
44
     mScreen.glClearColor(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 1.0f);
45
     }
46

    
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48

    
49
   @Override
50
   public void onDrawFrame(GL10 glUnused)
51
     {
52
     long time = System.currentTimeMillis();
53
     mView.getPreRender().preRender();
54
     mScreen.render(time);
55
     }
56

    
57
///////////////////////////////////////////////////////////////////////////////////////////////////
58

    
59
   @Override
60
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
61
      {
62
      mScreen.resize(width,height);
63
      mView.setScreenSize(width,height);
64
      mView.getPreRender().setScreenSize(width);
65
      }
66

    
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68

    
69
   @Override
70
   public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
71
      {
72

    
73
      }
74

    
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76

    
77
   DistortedScreen getScreen()
78
     {
79
     return mScreen;
80
     }
81
}
(3-3/4)