Project

General

Profile

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

examples / src / main / java / org / distorted / examples / effects2d / Effects2DActivity.java @ f9afbbf3

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.effects2d;
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.view.View;
29
import android.widget.AdapterView;
30
import android.widget.ArrayAdapter;
31
import android.widget.Spinner;
32

    
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34

    
35
public class Effects2DActivity extends Activity implements AdapterView.OnItemSelectedListener
36
  {
37
  private Spinner mID, mName, mType;
38
  private ArrayAdapter<String> mAdapterID, mAdapterName, mAdapterType;
39

    
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41

    
42
  @Override
43
  protected void onCreate(Bundle savedInstanceState) 
44
    {
45
    super.onCreate(savedInstanceState);
46
 
47
    setContentView(R.layout.effects2dlayout);
48

    
49
    mID   = (Spinner)findViewById(R.id.effects2d_spinnerID  );
50
    mName = (Spinner)findViewById(R.id.effects2d_spinnerName);
51
    mType = (Spinner)findViewById(R.id.effects2d_spinnerType);
52

    
53
    mID.setOnItemSelectedListener(this);
54
    mName.setOnItemSelectedListener(this);
55
    mType.setOnItemSelectedListener(this);
56

    
57
    String[] itemsID   = new String[] {"1", "2", "3"};
58
    String[] itemsName = new String[] { getText(R.string.distort     ).toString(),
59
                                        getText(R.string.sink        ).toString(),
60
                                        getText(R.string.transparency).toString(),
61
                                        getText(R.string.macroblock  ).toString(),
62
                                        getText(R.string.chroma      ).toString()};
63
    String[] itemsType = new String[] {"VERTEX", "FRAGMENT"};
64

    
65
    mAdapterID = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, itemsID);
66
    mAdapterID.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
67
    mID.setAdapter(mAdapterID);
68

    
69
    mAdapterName = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, itemsName);
70
    mAdapterName.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
71
    mName.setAdapter(mAdapterName);
72

    
73
    mAdapterType = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, itemsType);
74
    mAdapterType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
75
    mType.setAdapter(mAdapterType);
76
    }
77

    
78
///////////////////////////////////////////////////////////////////////////////////////////////////
79

    
80
  @Override
81
  protected void onResume() 
82
    {
83
    super.onResume();
84
      
85
    GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.scratchpadSurfaceView);
86
    mView.onResume();
87
    }
88

    
89
///////////////////////////////////////////////////////////////////////////////////////////////////
90

    
91
  @Override
92
  protected void onPause() 
93
    {
94
    GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.scratchpadSurfaceView);
95
    mView.onPause();
96
      
97
    super.onPause();
98
    }
99
    
100
///////////////////////////////////////////////////////////////////////////////////////////////////
101

    
102
  @Override
103
  public void onStop()
104
    {
105
    super.onStop();
106
    }
107

    
108
///////////////////////////////////////////////////////////////////////////////////////////////////
109

    
110
  @Override
111
  public void onDestroy()
112
    {
113
    Distorted.onDestroy();
114
    super.onDestroy();
115
    }     
116
 
117
///////////////////////////////////////////////////////////////////////////////////////////////////
118
    
119
  public void Distort(View v)
120
    {
121
    Effects2DSurfaceView.setEffect(0);
122
    }     
123
    
124
///////////////////////////////////////////////////////////////////////////////////////////////////
125

    
126
  public void Sink(View v)
127
    {
128
    Effects2DSurfaceView.setEffect(1);
129
    }       
130

    
131
///////////////////////////////////////////////////////////////////////////////////////////////////
132
    
133
  public void Transparency(View v)
134
    {
135
    Effects2DSurfaceView.setEffect(2);
136
    }     
137
    
138
///////////////////////////////////////////////////////////////////////////////////////////////////
139

    
140
  public void Macroblock(View v)
141
    {
142
    Effects2DSurfaceView.setEffect(3);
143
    }       
144
 
145
///////////////////////////////////////////////////////////////////////////////////////////////////
146

    
147
  public void Chroma(View v)
148
    {
149
    Effects2DSurfaceView.setEffect(4);
150
    }
151

    
152
///////////////////////////////////////////////////////////////////////////////////////////////////
153

    
154
  public void onItemSelected(AdapterView<?> parent, View view, int pos, long id)
155
    {
156
    // An item was selected. You can retrieve the selected item using
157
    // parent.getItemAtPosition(pos)
158

    
159
    switch(parent.getId())
160
      {
161
      case R.id.effects2d_spinnerID  : android.util.Log.d("EFFECTS2D", "ID spinner!!"  ); break;
162
      case R.id.effects2d_spinnerName: android.util.Log.d("EFFECTS2D", "Name spinner!!"); break;
163
      case R.id.effects2d_spinnerType: android.util.Log.d("EFFECTS2D", "Type spinner!!"); break;
164
      }
165
    }
166

    
167
///////////////////////////////////////////////////////////////////////////////////////////////////
168

    
169
  public void onNothingSelected(AdapterView<?> parent)
170
    {
171
    switch(parent.getId())
172
      {
173
      case R.id.effects2d_spinnerID  : android.util.Log.d("EFFECTS2D", "(nothing) ID spinner!!"  ); break;
174
      case R.id.effects2d_spinnerName: android.util.Log.d("EFFECTS2D", "(nothing) Name spinner!!"); break;
175
      case R.id.effects2d_spinnerType: android.util.Log.d("EFFECTS2D", "(nothing) Type spinner!!"); break;
176
      }
177
    }
178
  }
(1-1/3)