Project

General

Profile

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

examples / src / main / java / org / distorted / examples / fbo / FBOActivity.java @ b5636dbf

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 5068fa06 Leszek Koltunski
package org.distorted.examples.fbo;
21 427ab7bf Leszek Koltunski
22 1746198f Leszek Koltunski
import org.distorted.examples.R;
23 5068fa06 Leszek Koltunski
import org.distorted.library.Distorted;
24 427ab7bf Leszek Koltunski
25
import android.app.Activity;
26
import android.os.Bundle;
27 1746198f Leszek Koltunski
import android.view.View;
28 427ab7bf Leszek Koltunski
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30
31
public class FBOActivity extends Activity 
32
{
33 b5636dbf leszek
    private boolean mDepth;
34
35 427ab7bf Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
36
    
37
    @Override
38 b5636dbf leszek
    protected void onCreate(Bundle savedState)
39 427ab7bf Leszek Koltunski
      {
40 b5636dbf leszek
      super.onCreate(savedState);
41 1746198f Leszek Koltunski
      setContentView(R.layout.fbolayout);
42 b5636dbf leszek
43
      if( savedState==null )
44
        {
45
        mDepth = true;
46
        }
47 427ab7bf Leszek Koltunski
      }
48
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50
    
51
    @Override
52
    protected void onPause() 
53
      {
54 1746198f Leszek Koltunski
      FBOSurfaceView view = (FBOSurfaceView) this.findViewById(R.id.fboSurfaceView);
55
56
      view.onPause();
57 427ab7bf Leszek Koltunski
      super.onPause();
58
      }
59
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61
    
62
    @Override
63
    protected void onResume() 
64
      {
65 1746198f Leszek Koltunski
      FBOSurfaceView view = (FBOSurfaceView) this.findViewById(R.id.fboSurfaceView);
66
67 427ab7bf Leszek Koltunski
      super.onResume();
68 1746198f Leszek Koltunski
      view.onResume();
69 427ab7bf Leszek Koltunski
      }
70
    
71
///////////////////////////////////////////////////////////////////////////////////////////////////
72
    
73
    @Override
74
    protected void onDestroy() 
75
      {
76
      Distorted.onDestroy();  
77
      super.onDestroy();
78
      }
79 1746198f Leszek Koltunski
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81
82
    public void DepthYes(View v)
83
      {
84
      FBOSurfaceView view = (FBOSurfaceView) this.findViewById(R.id.fboSurfaceView);
85
      FBORenderer renderer = view.getRenderer();
86
87
      renderer.setDepth(true);
88 b5636dbf leszek
      mDepth = true;
89 1746198f Leszek Koltunski
      }
90
91
///////////////////////////////////////////////////////////////////////////////////////////////////
92
93
    public void DepthNo(View v)
94
      {
95
      FBOSurfaceView view = (FBOSurfaceView) this.findViewById(R.id.fboSurfaceView);
96
      FBORenderer renderer = view.getRenderer();
97
98
      renderer.setDepth(false);
99 b5636dbf leszek
      mDepth = false;
100 1746198f Leszek Koltunski
      }
101 b5636dbf leszek
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103
104
    @Override
105
    public void onSaveInstanceState(Bundle savedInstanceState)
106
      {
107
      super.onSaveInstanceState(savedInstanceState);
108
      savedInstanceState.putBoolean("depth", mDepth);
109
      }
110
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112
113
    @Override
114
    public void onRestoreInstanceState(Bundle savedInstanceState)
115
      {
116
      super.onRestoreInstanceState(savedInstanceState);
117
118
      mDepth = savedInstanceState.getBoolean("depth");
119
120
      if(mDepth) DepthYes(null);
121
      else       DepthNo(null);
122
      }
123
124 427ab7bf Leszek Koltunski
}