Revision 9c3e749e
Added by Leszek Koltunski almost 6 years ago
src/main/java/org/distorted/examples/cubes/CubesActivity.java | ||
---|---|---|
30 | 30 |
import android.os.Bundle; |
31 | 31 |
import android.view.Gravity; |
32 | 32 |
import android.view.View; |
33 |
import android.widget.AdapterView; |
|
34 |
import android.widget.ArrayAdapter; |
|
33 | 35 |
import android.widget.Button; |
34 | 36 |
import android.widget.LinearLayout; |
35 | 37 |
import android.widget.NumberPicker; |
36 | 38 |
import android.widget.NumberPicker.OnValueChangeListener; |
39 |
import android.widget.SeekBar; |
|
40 |
import android.widget.Spinner; |
|
37 | 41 |
import android.widget.TableRow; |
38 | 42 |
|
39 | 43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
40 | 44 |
|
41 |
public class CubesActivity extends Activity implements View.OnClickListener |
|
45 |
public class CubesActivity extends Activity implements View.OnClickListener, SeekBar.OnSeekBarChangeListener, AdapterView.OnItemSelectedListener
|
|
42 | 46 |
{ |
43 | 47 |
private static final int COLOR_OFF = 0xffffe81f; |
44 | 48 |
private static final int COLOR_ON = 0xff0000ff; |
... | ... | |
61 | 65 |
|
62 | 66 |
setContentView(R.layout.cubespickerlayout); |
63 | 67 |
|
64 |
mLay = (LinearLayout)findViewById(R.id.cubespicker_buttongrid);
|
|
68 |
mLay = findViewById(R.id.cubespicker_buttongrid); |
|
65 | 69 |
|
66 |
mColsPicker = (NumberPicker)findViewById(R.id.cubespicker_cols);
|
|
67 |
mRowsPicker = (NumberPicker)findViewById(R.id.cubespicker_rows);
|
|
68 |
mSlicPicker = (NumberPicker)findViewById(R.id.cubespicker_slices);
|
|
70 |
mColsPicker = findViewById(R.id.cubespicker_cols); |
|
71 |
mRowsPicker = findViewById(R.id.cubespicker_rows); |
|
72 |
mSlicPicker = findViewById(R.id.cubespicker_slices); |
|
69 | 73 |
|
70 | 74 |
mColsPicker.setMaxValue(40); |
71 | 75 |
mColsPicker.setMinValue( 0); |
... | ... | |
178 | 182 |
@Override |
179 | 183 |
protected void onPause() |
180 | 184 |
{ |
181 |
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.cubesSurfaceView);
|
|
185 |
GLSurfaceView mView = this.findViewById(R.id.cubesSurfaceView); |
|
182 | 186 |
if( mView!=null ) mView.onPause(); |
183 | 187 |
|
184 | 188 |
Distorted.onPause(); |
... | ... | |
192 | 196 |
{ |
193 | 197 |
super.onResume(); |
194 | 198 |
|
195 |
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.cubesSurfaceView);
|
|
199 |
GLSurfaceView mView = this.findViewById(R.id.cubesSurfaceView); |
|
196 | 200 |
if( mView!=null ) mView.onResume(); |
197 | 201 |
} |
198 | 202 |
|
... | ... | |
218 | 222 |
mTexture = new DistortedTexture(mNumCols,mNumRows); |
219 | 223 |
|
220 | 224 |
setContentView(R.layout.cubeslayout); |
225 |
|
|
226 |
Spinner renderSpinner = findViewById(R.id.cubes_spinnerMode); |
|
227 |
renderSpinner.setOnItemSelectedListener(this); |
|
228 |
|
|
229 |
String[] objectBitmap = new String[] { "Render: Normal", "Render: OIT" }; |
|
230 |
|
|
231 |
ArrayAdapter<String> adapterBitmap = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, objectBitmap); |
|
232 |
adapterBitmap.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|
233 |
renderSpinner.setAdapter(adapterBitmap); |
|
234 |
|
|
235 |
SeekBar transparencyBar = findViewById(R.id.cubesTransparency); |
|
236 |
|
|
237 |
transparencyBar.setOnSeekBarChangeListener(this); |
|
238 |
|
|
239 |
CubesSurfaceView view = this.findViewById(R.id.cubesSurfaceView); |
|
240 |
view.getRenderer().setTransparency(50); |
|
241 |
transparencyBar.setProgress(50); |
|
242 |
} |
|
243 |
|
|
244 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
245 |
|
|
246 |
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) |
|
247 |
{ |
|
248 |
CubesSurfaceView v = this.findViewById(R.id.cubesSurfaceView); |
|
249 |
CubesRenderer renderer = v.getRenderer(); |
|
250 |
|
|
251 |
switch(parent.getId()) |
|
252 |
{ |
|
253 |
case R.id.cubes_spinnerMode: renderer.setRenderModeToOIT(pos==1); |
|
254 |
break; |
|
255 |
} |
|
256 |
} |
|
257 |
|
|
258 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
259 |
|
|
260 |
public void onNothingSelected(AdapterView<?> parent) |
|
261 |
{ |
|
262 |
} |
|
263 |
|
|
264 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
265 |
|
|
266 |
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) |
|
267 |
{ |
|
268 |
switch (bar.getId()) |
|
269 |
{ |
|
270 |
case R.id.cubesTransparency: CubesSurfaceView view = this.findViewById(R.id.cubesSurfaceView); |
|
271 |
view.getRenderer().setTransparency(progress); |
|
272 |
break; |
|
273 |
} |
|
221 | 274 |
} |
222 | 275 |
|
276 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
277 |
|
|
278 |
public void onStartTrackingTouch(SeekBar bar) { } |
|
279 |
|
|
280 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
281 |
|
|
282 |
public void onStopTrackingTouch(SeekBar bar) { } |
|
283 |
|
|
223 | 284 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
224 | 285 |
|
225 | 286 |
public DistortedTexture getTexture() |
Also available in: Unified diff
Make the Cubes App capable of testing unprocessed OIT.