Project

General

Profile

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

examples / src / main / java / org / distorted / examples / projection / ProjectionActivity.java @ 6f3024ae

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 10d53839 Leszek Koltunski
    private TextView textF, textX, textY;
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
      textX = (TextView)findViewById(R.id.projectionTextX);
48
      textY = (TextView)findViewById(R.id.projectionTextY);
49
50
      SeekBar bar;
51
52
      bar = (SeekBar)findViewById(R.id.projectionSeekFOV);
53
      bar.setOnSeekBarChangeListener(this);
54
      bar.setProgress(50);
55
      bar = (SeekBar)findViewById(R.id.projectionSeekX);
56
      bar.setOnSeekBarChangeListener(this);
57
      bar.setProgress(50);
58
      bar = (SeekBar)findViewById(R.id.projectionSeekY);
59
      bar.setOnSeekBarChangeListener(this);
60
      bar.setProgress(50);
61 427ab7bf Leszek Koltunski
      }
62
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64
    
65
    @Override
66
    protected void onPause() 
67
      {
68 10d53839 Leszek Koltunski
      GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.surfaceViewProjection);
69 427ab7bf Leszek Koltunski
      mView.onPause();
70
      
71
      super.onPause();
72
      }
73
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75
    
76
    @Override
77
    protected void onResume() 
78
      {
79
      super.onResume();
80
      
81 10d53839 Leszek Koltunski
      GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.surfaceViewProjection);
82 427ab7bf Leszek Koltunski
      mView.onResume();    
83
      }
84
 
85
///////////////////////////////////////////////////////////////////////////////////////////////////
86
    
87
    @Override
88
    protected void onDestroy() 
89
      {
90
      Distorted.onDestroy();  
91
      super.onDestroy();
92
      }
93
94
///////////////////////////////////////////////////////////////////////////////////////////////////
95
    
96
    public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) 
97
      {
98 10d53839 Leszek Koltunski
      int ret;
99 392e16fd Leszek Koltunski
      ProjectionSurfaceView view = (ProjectionSurfaceView)findViewById(R.id.surfaceViewProjection);
100
      ProjectionRenderer renderer = view.getRenderer();
101 10d53839 Leszek Koltunski
102 427ab7bf Leszek Koltunski
      switch (bar.getId()) 
103
        {
104 392e16fd Leszek Koltunski
        case R.id.projectionSeekFOV: ret = renderer.setFOV(progress);
105 6f3024ae Leszek Koltunski
                                     textF.setText(getString(R.string.fov_placeholder,ret));
106 10d53839 Leszek Koltunski
                                     break;
107 392e16fd Leszek Koltunski
        case R.id.projectionSeekX  : ret = renderer.setX(progress);
108 6f3024ae Leszek Koltunski
                                     textX.setText(getString(R.string.x_placeholder,ret));
109 10d53839 Leszek Koltunski
                                     break;
110 392e16fd Leszek Koltunski
        case R.id.projectionSeekY  : ret = renderer.setY(progress);
111 6f3024ae Leszek Koltunski
                                     textY.setText(getString(R.string.y_placeholder,ret));
112 10d53839 Leszek Koltunski
                                     break;
113 427ab7bf Leszek Koltunski
        }
114
      }
115
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117
118
    public void onStartTrackingTouch(SeekBar bar) { }
119
    
120
///////////////////////////////////////////////////////////////////////////////////////////////////
121
122
    public void onStopTrackingTouch(SeekBar bar)  { }
123
124
///////////////////////////////////////////////////////////////////////////////////////////////////
125
    
126
}