Project

General

Profile

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

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

1 bc0a685b Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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 427ab7bf Leszek Koltunski
20 10d53839 Leszek Koltunski
package org.distorted.examples.projection;
21 427ab7bf Leszek Koltunski
22 5068fa06 Leszek Koltunski
import org.distorted.library.Distorted;
23
import org.distorted.examples.R;
24 427ab7bf Leszek Koltunski
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 10d53839 Leszek Koltunski
public class ProjectionActivity extends Activity implements OnSeekBarChangeListener
35 427ab7bf Leszek Koltunski
{
36 af662543 leszek
    private TextView textF, textN;
37 427ab7bf Leszek Koltunski
    
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39
    
40
    @Override
41
    protected void onCreate(Bundle icicle) 
42
      {
43
      super.onCreate(icicle);
44 10d53839 Leszek Koltunski
      setContentView(R.layout.projectionlayout);
45
46
      textF = (TextView)findViewById(R.id.projectionTextFOV);
47 af662543 leszek
      textN = (TextView)findViewById(R.id.projectionTextNear);
48 10d53839 Leszek Koltunski
49
      SeekBar bar;
50
51
      bar = (SeekBar)findViewById(R.id.projectionSeekFOV);
52
      bar.setOnSeekBarChangeListener(this);
53
      bar.setProgress(50);
54 af662543 leszek
      bar = (SeekBar)findViewById(R.id.projectionSeekNear);
55 10d53839 Leszek Koltunski
      bar.setOnSeekBarChangeListener(this);
56
      bar.setProgress(50);
57 427ab7bf Leszek Koltunski
      }
58
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60
    
61
    @Override
62
    protected void onPause() 
63
      {
64 10d53839 Leszek Koltunski
      GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.surfaceViewProjection);
65 427ab7bf Leszek Koltunski
      mView.onPause();
66
      
67
      super.onPause();
68
      }
69
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71
    
72
    @Override
73
    protected void onResume() 
74
      {
75
      super.onResume();
76
      
77 10d53839 Leszek Koltunski
      GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.surfaceViewProjection);
78 427ab7bf Leszek Koltunski
      mView.onResume();    
79
      }
80
 
81
///////////////////////////////////////////////////////////////////////////////////////////////////
82
    
83
    @Override
84
    protected void onDestroy() 
85
      {
86
      Distorted.onDestroy();  
87
      super.onDestroy();
88
      }
89
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91
    
92
    public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) 
93
      {
94 af662543 leszek
      float ret;
95 392e16fd Leszek Koltunski
      ProjectionSurfaceView view = (ProjectionSurfaceView)findViewById(R.id.surfaceViewProjection);
96
      ProjectionRenderer renderer = view.getRenderer();
97 10d53839 Leszek Koltunski
98 427ab7bf Leszek Koltunski
      switch (bar.getId()) 
99
        {
100 af662543 leszek
        case R.id.projectionSeekFOV : ret = renderer.setFOV(progress);
101
                                      textF.setText(getString(R.string.fov_placeholder,(int)ret));
102
                                      break;
103
        case R.id.projectionSeekNear: ret = renderer.setNear(progress);
104
                                      textN.setText(getString(R.string.near_placeholder,ret));
105
                                      break;
106 427ab7bf Leszek Koltunski
        }
107
      }
108
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110
111
    public void onStartTrackingTouch(SeekBar bar) { }
112
    
113
///////////////////////////////////////////////////////////////////////////////////////////////////
114
115
    public void onStopTrackingTouch(SeekBar bar)  { }
116
117
///////////////////////////////////////////////////////////////////////////////////////////////////
118
    
119
}