1 |
bc0a685b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2016 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
71c8884f
|
Leszek Koltunski
|
// This file is part of Distorted. //
|
5 |
bc0a685b
|
Leszek Koltunski
|
// //
|
6 |
71c8884f
|
Leszek Koltunski
|
// Distorted is free software: you can redistribute it and/or modify //
|
7 |
bc0a685b
|
Leszek Koltunski
|
// 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 |
71c8884f
|
Leszek Koltunski
|
// Distorted is distributed in the hope that it will be useful, //
|
12 |
bc0a685b
|
Leszek Koltunski
|
// 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 |
71c8884f
|
Leszek Koltunski
|
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18 |
bc0a685b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19 |
427ab7bf
|
Leszek Koltunski
|
|
20 |
10d53839
|
Leszek Koltunski
|
package org.distorted.examples.projection;
|
21 |
427ab7bf
|
Leszek Koltunski
|
|
22 |
e3900503
|
Leszek Koltunski
|
import org.distorted.library.main.DistortedLibrary;
|
23 |
5068fa06
|
Leszek Koltunski
|
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 |
18174881
|
Leszek Koltunski
|
protected void onCreate(Bundle savedState)
|
42 |
427ab7bf
|
Leszek Koltunski
|
{
|
43 |
18174881
|
Leszek Koltunski
|
super.onCreate(savedState);
|
44 |
a9df241d
|
Leszek Koltunski
|
DistortedLibrary.onCreate();
|
45 |
10d53839
|
Leszek Koltunski
|
setContentView(R.layout.projectionlayout);
|
46 |
|
|
|
47 |
6e18bd32
|
Leszek Koltunski
|
textF = findViewById(R.id.projectionTextFOV);
|
48 |
|
|
textN = findViewById(R.id.projectionTextNear);
|
49 |
10d53839
|
Leszek Koltunski
|
|
50 |
6e18bd32
|
Leszek Koltunski
|
SeekBar bar1 = findViewById(R.id.projectionSeekFOV);
|
51 |
|
|
SeekBar bar2 = findViewById(R.id.projectionSeekNear);
|
52 |
10d53839
|
Leszek Koltunski
|
|
53 |
18174881
|
Leszek Koltunski
|
bar1.setOnSeekBarChangeListener(this);
|
54 |
|
|
bar2.setOnSeekBarChangeListener(this);
|
55 |
|
|
|
56 |
|
|
if(savedState==null )
|
57 |
|
|
{
|
58 |
|
|
bar1.setProgress(50);
|
59 |
|
|
bar2.setProgress(50);
|
60 |
|
|
}
|
61 |
|
|
else
|
62 |
|
|
{
|
63 |
|
|
textF.setText(getString(R.string.fov_placeholder ,0));
|
64 |
|
|
textN.setText(getString(R.string.near_placeholder,0.0f));
|
65 |
|
|
}
|
66 |
427ab7bf
|
Leszek Koltunski
|
}
|
67 |
|
|
|
68 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
69 |
|
|
|
70 |
|
|
@Override
|
71 |
|
|
protected void onPause()
|
72 |
|
|
{
|
73 |
|
|
super.onPause();
|
74 |
c0f27889
|
Leszek Koltunski
|
GLSurfaceView view = findViewById(R.id.surfaceViewProjection);
|
75 |
|
|
view.onPause();
|
76 |
|
|
DistortedLibrary.onPause();
|
77 |
427ab7bf
|
Leszek Koltunski
|
}
|
78 |
|
|
|
79 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
80 |
|
|
|
81 |
|
|
@Override
|
82 |
|
|
protected void onResume()
|
83 |
|
|
{
|
84 |
|
|
super.onResume();
|
85 |
c0f27889
|
Leszek Koltunski
|
GLSurfaceView view = findViewById(R.id.surfaceViewProjection);
|
86 |
|
|
view.onResume();
|
87 |
427ab7bf
|
Leszek Koltunski
|
}
|
88 |
|
|
|
89 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
90 |
|
|
|
91 |
|
|
@Override
|
92 |
|
|
protected void onDestroy()
|
93 |
|
|
{
|
94 |
e3900503
|
Leszek Koltunski
|
DistortedLibrary.onDestroy();
|
95 |
427ab7bf
|
Leszek Koltunski
|
super.onDestroy();
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
99 |
|
|
|
100 |
|
|
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
|
101 |
|
|
{
|
102 |
af662543
|
leszek
|
float ret;
|
103 |
6e18bd32
|
Leszek Koltunski
|
ProjectionSurfaceView view = findViewById(R.id.surfaceViewProjection);
|
104 |
392e16fd
|
Leszek Koltunski
|
ProjectionRenderer renderer = view.getRenderer();
|
105 |
10d53839
|
Leszek Koltunski
|
|
106 |
427ab7bf
|
Leszek Koltunski
|
switch (bar.getId())
|
107 |
|
|
{
|
108 |
af662543
|
leszek
|
case R.id.projectionSeekFOV : ret = renderer.setFOV(progress);
|
109 |
|
|
textF.setText(getString(R.string.fov_placeholder,(int)ret));
|
110 |
|
|
break;
|
111 |
|
|
case R.id.projectionSeekNear: ret = renderer.setNear(progress);
|
112 |
|
|
textN.setText(getString(R.string.near_placeholder,ret));
|
113 |
|
|
break;
|
114 |
427ab7bf
|
Leszek Koltunski
|
}
|
115 |
|
|
}
|
116 |
|
|
|
117 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
118 |
|
|
|
119 |
|
|
public void onStartTrackingTouch(SeekBar bar) { }
|
120 |
|
|
|
121 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
122 |
|
|
|
123 |
|
|
public void onStopTrackingTouch(SeekBar bar) { }
|
124 |
|
|
|
125 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
126 |
|
|
|
127 |
|
|
}
|