Project

General

Profile

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

examples / src / main / java / org / distorted / examples / projection / ProjectionActivity.java @ c0f27889

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.projection;
21

    
22
import org.distorted.library.main.DistortedLibrary;
23
import org.distorted.examples.R;
24

    
25
import android.app.Activity;
26
import android.opengl.GLSurfaceView;
27
import android.os.Bundle;
28
import android.widget.SeekBar;
29
import android.widget.TextView;
30
import android.widget.SeekBar.OnSeekBarChangeListener;
31

    
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

    
34
public class ProjectionActivity extends Activity implements OnSeekBarChangeListener
35
{
36
    private TextView textF, textN;
37
    
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39
    
40
    @Override
41
    protected void onCreate(Bundle savedState)
42
      {
43
      super.onCreate(savedState);
44
      setContentView(R.layout.projectionlayout);
45

    
46
      textF = findViewById(R.id.projectionTextFOV);
47
      textN = findViewById(R.id.projectionTextNear);
48

    
49
      SeekBar bar1 = findViewById(R.id.projectionSeekFOV);
50
      SeekBar bar2 = findViewById(R.id.projectionSeekNear);
51

    
52
      bar1.setOnSeekBarChangeListener(this);
53
      bar2.setOnSeekBarChangeListener(this);
54

    
55
      if(savedState==null )
56
        {
57
        bar1.setProgress(50);
58
        bar2.setProgress(50);
59
        }
60
      else
61
        {
62
        textF.setText(getString(R.string.fov_placeholder ,0));
63
        textN.setText(getString(R.string.near_placeholder,0.0f));
64
        }
65
      }
66

    
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68
    
69
    @Override
70
    protected void onPause() 
71
      {
72
      super.onPause();
73
      GLSurfaceView view = findViewById(R.id.surfaceViewProjection);
74
      view.onPause();
75
      DistortedLibrary.onPause();
76
      }
77

    
78
///////////////////////////////////////////////////////////////////////////////////////////////////
79
    
80
    @Override
81
    protected void onResume() 
82
      {
83
      super.onResume();
84
      GLSurfaceView view = findViewById(R.id.surfaceViewProjection);
85
      view.onResume();
86
      }
87
 
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89
    
90
    @Override
91
    protected void onDestroy() 
92
      {
93
      DistortedLibrary.onDestroy();
94
      super.onDestroy();
95
      }
96

    
97
///////////////////////////////////////////////////////////////////////////////////////////////////
98
    
99
    public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) 
100
      {
101
      float ret;
102
      ProjectionSurfaceView view = findViewById(R.id.surfaceViewProjection);
103
      ProjectionRenderer renderer = view.getRenderer();
104

    
105
      switch (bar.getId()) 
106
        {
107
        case R.id.projectionSeekFOV : ret = renderer.setFOV(progress);
108
                                      textF.setText(getString(R.string.fov_placeholder,(int)ret));
109
                                      break;
110
        case R.id.projectionSeekNear: ret = renderer.setNear(progress);
111
                                      textN.setText(getString(R.string.near_placeholder,ret));
112
                                      break;
113
        }
114
      }
115

    
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117

    
118
    public void onStartTrackingTouch(SeekBar bar) { }
119
    
120
///////////////////////////////////////////////////////////////////////////////////////////////////
121

    
122
    public void onStopTrackingTouch(SeekBar bar)  { }
123

    
124
///////////////////////////////////////////////////////////////////////////////////////////////////
125
    
126
}
(1-1/3)