Project

General

Profile

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

examples / src / main / java / org / distorted / examples / projection / ProjectionActivity.java @ 392e16fd

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.Distorted;
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, textX, textY;
37
    
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39
    
40
    @Override
41
    protected void onCreate(Bundle icicle) 
42
      {
43
      super.onCreate(icicle);
44
      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
      }
62

    
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64
    
65
    @Override
66
    protected void onPause() 
67
      {
68
      GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.surfaceViewProjection);
69
      mView.onPause();
70
      
71
      super.onPause();
72
      }
73

    
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75
    
76
    @Override
77
    protected void onResume() 
78
      {
79
      super.onResume();
80
      
81
      GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.surfaceViewProjection);
82
      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
      int ret;
99
      ProjectionSurfaceView view = (ProjectionSurfaceView)findViewById(R.id.surfaceViewProjection);
100
      ProjectionRenderer renderer = view.getRenderer();
101

    
102
      switch (bar.getId()) 
103
        {
104
        case R.id.projectionSeekFOV: ret = renderer.setFOV(progress);
105
                                     textF.setText("FOV: "+ret);
106
                                     break;
107
        case R.id.projectionSeekX  : ret = renderer.setX(progress);
108
                                     textX.setText("X: "+ret);
109
                                     break;
110
        case R.id.projectionSeekY  : ret = renderer.setY(progress);
111
                                     textY.setText("Y: "+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)