Project

General

Profile

« Previous | Next » 

Revision 6ab5da9a

Added by Leszek Koltunski about 7 years ago

Improve Olimpic.

View differences:

src/main/java/org/distorted/examples/olimpic/OlimpicActivity.java
25 25
import android.app.Activity;
26 26
import android.opengl.GLSurfaceView;
27 27
import android.os.Bundle;
28
import android.view.View;
29
import android.widget.Button;
28 30
import android.widget.TextView;
29 31

  
30 32
///////////////////////////////////////////////////////////////////////////////////////////////////
......
40 42
      mText.setText(text);
41 43
      }
42 44

  
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46

  
47
  public void onClick(View view)
48
    {
49
    Button tmp = (Button)view;
50
    int id = tmp.getId();
51
    OlimpicSurfaceView sView = (OlimpicSurfaceView) this.findViewById(R.id.olimpicSurfaceView);
52

  
53
    switch(id)
54
      {
55
      case R.id.olimpicCheckBoxBlue0  : sView.getRenderer().pressed(0,0); break;
56
      case R.id.olimpicCheckBoxBlue1  : sView.getRenderer().pressed(0,1); break;
57
      case R.id.olimpicCheckBoxBlue2  : sView.getRenderer().pressed(0,2); break;
58
      case R.id.olimpicCheckBoxBlue3  : sView.getRenderer().pressed(0,3); break;
59
      case R.id.olimpicCheckBoxBlue4  : sView.getRenderer().pressed(0,4); break;
60
      case R.id.olimpicCheckBoxBlue5  : sView.getRenderer().pressed(0,5); break;
61
      case R.id.olimpicCheckBoxBlue6  : sView.getRenderer().pressed(0,6); break;
62
      case R.id.olimpicCheckBoxBlue7  : sView.getRenderer().pressed(0,7); break;
63
      case R.id.olimpicCheckBoxBlue8  : sView.getRenderer().pressed(0,8); break;
64

  
65
      case R.id.olimpicCheckBoxBlack0 : sView.getRenderer().pressed(1,0); break;
66
      case R.id.olimpicCheckBoxBlack1 : sView.getRenderer().pressed(1,1); break;
67
      case R.id.olimpicCheckBoxBlack2 : sView.getRenderer().pressed(1,2); break;
68
      case R.id.olimpicCheckBoxBlack3 : sView.getRenderer().pressed(1,3); break;
69
      case R.id.olimpicCheckBoxBlack4 : sView.getRenderer().pressed(1,4); break;
70
      case R.id.olimpicCheckBoxBlack5 : sView.getRenderer().pressed(1,5); break;
71
      case R.id.olimpicCheckBoxBlack6 : sView.getRenderer().pressed(1,6); break;
72
      case R.id.olimpicCheckBoxBlack7 : sView.getRenderer().pressed(1,7); break;
73
      case R.id.olimpicCheckBoxBlack8 : sView.getRenderer().pressed(1,8); break;
74

  
75
      case R.id.olimpicCheckBoxRed0   : sView.getRenderer().pressed(2,0); break;
76
      case R.id.olimpicCheckBoxRed1   : sView.getRenderer().pressed(2,1); break;
77
      case R.id.olimpicCheckBoxRed2   : sView.getRenderer().pressed(2,2); break;
78
      case R.id.olimpicCheckBoxRed3   : sView.getRenderer().pressed(2,3); break;
79
      case R.id.olimpicCheckBoxRed4   : sView.getRenderer().pressed(2,4); break;
80
      case R.id.olimpicCheckBoxRed5   : sView.getRenderer().pressed(2,5); break;
81
      case R.id.olimpicCheckBoxRed6   : sView.getRenderer().pressed(2,6); break;
82
      case R.id.olimpicCheckBoxRed7   : sView.getRenderer().pressed(2,7); break;
83
      case R.id.olimpicCheckBoxRed8   : sView.getRenderer().pressed(2,8); break;
84

  
85
      case R.id.olimpicCheckBoxYellow0: sView.getRenderer().pressed(3,0); break;
86
      case R.id.olimpicCheckBoxYellow1: sView.getRenderer().pressed(3,1); break;
87
      case R.id.olimpicCheckBoxYellow2: sView.getRenderer().pressed(3,2); break;
88
      case R.id.olimpicCheckBoxYellow3: sView.getRenderer().pressed(3,3); break;
89
      case R.id.olimpicCheckBoxYellow4: sView.getRenderer().pressed(3,4); break;
90
      case R.id.olimpicCheckBoxYellow5: sView.getRenderer().pressed(3,5); break;
91
      case R.id.olimpicCheckBoxYellow6: sView.getRenderer().pressed(3,6); break;
92
      case R.id.olimpicCheckBoxYellow7: sView.getRenderer().pressed(3,7); break;
93
      case R.id.olimpicCheckBoxYellow8: sView.getRenderer().pressed(3,8); break;
94

  
95
      case R.id.olimpicCheckBoxGreen0 : sView.getRenderer().pressed(4,0); break;
96
      case R.id.olimpicCheckBoxGreen1 : sView.getRenderer().pressed(4,1); break;
97
      case R.id.olimpicCheckBoxGreen2 : sView.getRenderer().pressed(4,2); break;
98
      case R.id.olimpicCheckBoxGreen3 : sView.getRenderer().pressed(4,3); break;
99
      case R.id.olimpicCheckBoxGreen4 : sView.getRenderer().pressed(4,4); break;
100
      case R.id.olimpicCheckBoxGreen5 : sView.getRenderer().pressed(4,5); break;
101
      case R.id.olimpicCheckBoxGreen6 : sView.getRenderer().pressed(4,6); break;
102
      case R.id.olimpicCheckBoxGreen7 : sView.getRenderer().pressed(4,7); break;
103
      case R.id.olimpicCheckBoxGreen8 : sView.getRenderer().pressed(4,8); break;
104
      }
105
    }
106

  
43 107
///////////////////////////////////////////////////////////////////////////////////////////////////
44 108

  
45 109
    @Override
src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java
59 59
   private int mScreenW, mScreenH;
60 60
   private int mPrevRendered, mCurrRendered;
61 61

  
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63

  
64
   void pressed(int color, int number)
65
     {
66
     android.util.Log.d("Olimpic","Color: "+color+" number:"+number+" pressed!");
67
     }
68

  
62 69
///////////////////////////////////////////////////////////////////////////////////////////////////
63 70

  
64 71
   OlimpicRenderer(GLSurfaceView v)
src/main/java/org/distorted/examples/olimpic/OlimpicSurfaceView.java
29 29

  
30 30
class OlimpicSurfaceView extends GLSurfaceView 
31 31
{
32
    private OlimpicRenderer mRenderer;
33

  
32 34
///////////////////////////////////////////////////////////////////////////////////////////////////
33 35
   
34 36
    public OlimpicSurfaceView(Context context, AttributeSet attrs)
......
41 43
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
42 44
        android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
43 45
        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
44
        setRenderer(new OlimpicRenderer(this));
46

  
47
        mRenderer = new OlimpicRenderer(this);
48
        setRenderer(mRenderer);
45 49
        }
46 50
      }
51

  
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

  
54
    OlimpicRenderer getRenderer()
55
      {
56
      return mRenderer;
57
      }
47 58
}
48 59

  
src/main/res/layout/olimpiclayout.xml
25 25
                android:gravity="center_vertical|center"
26 26
                android:textAppearance="?android:attr/textAppearanceMedium" />
27 27

  
28
        <LinearLayout
29
            android:orientation="horizontal"
30
            android:layout_width="match_parent"
31
            android:layout_height="0dp"
32
            android:layout_weight="0.5">
33

  
34
            <CheckBox
35
                android:layout_width="wrap_content"
36
                android:layout_height="match_parent"
37
                android:id="@+id/olimpicCheckBoxBlue0"
38
                android:layout_weight="2"
39
                android:onClick="onClick"
40
                android:checked="true"/>
41
            <CheckBox
42
                android:layout_width="wrap_content"
43
                android:layout_height="match_parent"
44
                android:id="@+id/olimpicCheckBoxBlue1"
45
                android:layout_weight="1"
46
                android:onClick="onClick"
47
                android:checked="true"/>
48
            <CheckBox
49
                android:layout_width="wrap_content"
50
                android:layout_height="match_parent"
51
                android:id="@+id/olimpicCheckBoxBlue2"
52
                android:layout_weight="1"
53
                android:onClick="onClick"
54
                android:checked="true"/>
55
            <CheckBox
56
                android:layout_width="wrap_content"
57
                android:layout_height="match_parent"
58
                android:id="@+id/olimpicCheckBoxBlue3"
59
                android:layout_weight="1"
60
                android:onClick="onClick"
61
                android:checked="true"/>
62
             <CheckBox
63
                 android:layout_width="wrap_content"
64
                 android:layout_height="match_parent"
65
                 android:id="@+id/olimpicCheckBoxBlue4"
66
                 android:layout_weight="1"
67
                 android:onClick="onClick"
68
                 android:checked="true"/>
69
             <CheckBox
70
                 android:layout_width="wrap_content"
71
                 android:layout_height="match_parent"
72
                 android:id="@+id/olimpicCheckBoxBlue5"
73
                 android:layout_weight="1"
74
                 android:onClick="onClick"
75
                 android:checked="true"/>
76
             <CheckBox
77
                 android:layout_width="wrap_content"
78
                 android:layout_height="match_parent"
79
                 android:id="@+id/olimpicCheckBoxBlue6"
80
                 android:layout_weight="1"
81
                 android:onClick="onClick"
82
                 android:checked="true"/>
83
             <CheckBox
84
                 android:layout_width="wrap_content"
85
                 android:layout_height="match_parent"
86
                 android:id="@+id/olimpicCheckBoxBlue7"
87
                 android:layout_weight="1"
88
                 android:onClick="onClick"
89
                 android:checked="true"/>
90
             <CheckBox
91
                 android:layout_width="wrap_content"
92
                 android:layout_height="match_parent"
93
                 android:id="@+id/olimpicCheckBoxBlue8"
94
                 android:layout_weight="1"
95
                 android:onClick="onClick"
96
                 android:checked="true"/>
97
        </LinearLayout>
98

  
99
        <LinearLayout
100
            android:orientation="horizontal"
101
            android:layout_width="match_parent"
102
            android:layout_height="0dp"
103
            android:layout_weight="0.5">
104

  
105
            <CheckBox
106
                android:layout_width="wrap_content"
107
                android:layout_height="match_parent"
108
                android:id="@+id/olimpicCheckBoxBlack0"
109
                android:layout_weight="2"
110
                android:onClick="onClick"
111
                android:checked="true"/>
112
            <CheckBox
113
                android:layout_width="wrap_content"
114
                android:layout_height="match_parent"
115
                android:id="@+id/olimpicCheckBoxBlack1"
116
                android:layout_weight="1"
117
                android:onClick="onClick"
118
                android:checked="true"/>
119
            <CheckBox
120
                android:layout_width="wrap_content"
121
                android:layout_height="match_parent"
122
                android:id="@+id/olimpicCheckBoxBlack2"
123
                android:layout_weight="1"
124
                android:onClick="onClick"
125
                android:checked="true"/>
126
            <CheckBox
127
                android:layout_width="wrap_content"
128
                android:layout_height="match_parent"
129
                android:id="@+id/olimpicCheckBoxBlack3"
130
                android:layout_weight="1"
131
                android:onClick="onClick"
132
                android:checked="true"/>
133
             <CheckBox
134
                 android:layout_width="wrap_content"
135
                 android:layout_height="match_parent"
136
                 android:id="@+id/olimpicCheckBoxBlack4"
137
                 android:layout_weight="1"
138
                 android:onClick="onClick"
139
                 android:checked="true"/>
140
             <CheckBox
141
                 android:layout_width="wrap_content"
142
                 android:layout_height="match_parent"
143
                 android:id="@+id/olimpicCheckBoxBlack5"
144
                 android:layout_weight="1"
145
                 android:onClick="onClick"
146
                 android:checked="true"/>
147
             <CheckBox
148
                 android:layout_width="wrap_content"
149
                 android:layout_height="match_parent"
150
                 android:id="@+id/olimpicCheckBoxBlack6"
151
                 android:layout_weight="1"
152
                 android:onClick="onClick"
153
                 android:checked="true"/>
154
             <CheckBox
155
                 android:layout_width="wrap_content"
156
                 android:layout_height="match_parent"
157
                 android:id="@+id/olimpicCheckBoxBlack7"
158
                 android:layout_weight="1"
159
                 android:onClick="onClick"
160
                 android:checked="true"/>
161
             <CheckBox
162
                 android:layout_width="wrap_content"
163
                 android:layout_height="match_parent"
164
                 android:id="@+id/olimpicCheckBoxBlack8"
165
                 android:layout_weight="1"
166
                 android:onClick="onClick"
167
                 android:checked="true"/>
168
        </LinearLayout>
169

  
170
        <LinearLayout
171
            android:orientation="horizontal"
172
            android:layout_width="match_parent"
173
            android:layout_height="0dp"
174
            android:layout_weight="0.5">
175

  
176
            <CheckBox
177
                android:layout_width="wrap_content"
178
                android:layout_height="match_parent"
179
                android:id="@+id/olimpicCheckBoxRed0"
180
                android:layout_weight="2"
181
                android:onClick="onClick"
182
                android:checked="true"/>
183
            <CheckBox
184
                android:layout_width="wrap_content"
185
                android:layout_height="match_parent"
186
                android:id="@+id/olimpicCheckBoxRed1"
187
                android:layout_weight="1"
188
                android:onClick="onClick"
189
                android:checked="true"/>
190
            <CheckBox
191
                android:layout_width="wrap_content"
192
                android:layout_height="match_parent"
193
                android:id="@+id/olimpicCheckBoxRed2"
194
                android:layout_weight="1"
195
                android:onClick="onClick"
196
                android:checked="true"/>
197
            <CheckBox
198
                android:layout_width="wrap_content"
199
                android:layout_height="match_parent"
200
                android:id="@+id/olimpicCheckBoxRed3"
201
                android:layout_weight="1"
202
                android:onClick="onClick"
203
                android:checked="true"/>
204
             <CheckBox
205
                 android:layout_width="wrap_content"
206
                 android:layout_height="match_parent"
207
                 android:id="@+id/olimpicCheckBoxRed4"
208
                 android:layout_weight="1"
209
                 android:onClick="onClick"
210
                 android:checked="true"/>
211
             <CheckBox
212
                 android:layout_width="wrap_content"
213
                 android:layout_height="match_parent"
214
                 android:id="@+id/olimpicCheckBoxRed5"
215
                 android:layout_weight="1"
216
                 android:onClick="onClick"
217
                 android:checked="true"/>
218
             <CheckBox
219
                 android:layout_width="wrap_content"
220
                 android:layout_height="match_parent"
221
                 android:id="@+id/olimpicCheckBoxRed6"
222
                 android:layout_weight="1"
223
                 android:onClick="onClick"
224
                 android:checked="true"/>
225
             <CheckBox
226
                 android:layout_width="wrap_content"
227
                 android:layout_height="match_parent"
228
                 android:id="@+id/olimpicCheckBoxRed7"
229
                 android:layout_weight="1"
230
                 android:onClick="onClick"
231
                 android:checked="true"/>
232
             <CheckBox
233
                 android:layout_width="wrap_content"
234
                 android:layout_height="match_parent"
235
                 android:id="@+id/olimpicCheckBoxRed8"
236
                 android:layout_weight="1"
237
                 android:onClick="onClick"
238
                 android:checked="true"/>
239
        </LinearLayout>
240

  
241
        <LinearLayout
242
            android:orientation="horizontal"
243
            android:layout_width="match_parent"
244
            android:layout_height="0dp"
245
            android:layout_weight="0.5">
246

  
247
            <CheckBox
248
                android:layout_width="wrap_content"
249
                android:layout_height="match_parent"
250
                android:id="@+id/olimpicCheckBoxYellow0"
251
                android:layout_weight="2"
252
                android:onClick="onClick"
253
                android:checked="true"/>
254
            <CheckBox
255
                android:layout_width="wrap_content"
256
                android:layout_height="match_parent"
257
                android:id="@+id/olimpicCheckBoxYellow1"
258
                android:layout_weight="1"
259
                android:onClick="onClick"
260
                android:checked="true"/>
261
            <CheckBox
262
                android:layout_width="wrap_content"
263
                android:layout_height="match_parent"
264
                android:id="@+id/olimpicCheckBoxYellow2"
265
                android:layout_weight="1"
266
                android:onClick="onClick"
267
                android:checked="true"/>
268
            <CheckBox
269
                android:layout_width="wrap_content"
270
                android:layout_height="match_parent"
271
                android:id="@+id/olimpicCheckBoxYellow3"
272
                android:layout_weight="1"
273
                android:onClick="onClick"
274
                android:checked="true"/>
275
             <CheckBox
276
                 android:layout_width="wrap_content"
277
                 android:layout_height="match_parent"
278
                 android:id="@+id/olimpicCheckBoxYellow4"
279
                 android:layout_weight="1"
280
                 android:onClick="onClick"
281
                 android:checked="true"/>
282
             <CheckBox
283
                 android:layout_width="wrap_content"
284
                 android:layout_height="match_parent"
285
                 android:id="@+id/olimpicCheckBoxYellow5"
286
                 android:layout_weight="1"
287
                 android:onClick="onClick"
288
                 android:checked="true"/>
289
             <CheckBox
290
                 android:layout_width="wrap_content"
291
                 android:layout_height="match_parent"
292
                 android:id="@+id/olimpicCheckBoxYellow6"
293
                 android:layout_weight="1"
294
                 android:onClick="onClick"
295
                 android:checked="true"/>
296
             <CheckBox
297
                 android:layout_width="wrap_content"
298
                 android:layout_height="match_parent"
299
                 android:id="@+id/olimpicCheckBoxYellow7"
300
                 android:layout_weight="1"
301
                 android:onClick="onClick"
302
                 android:checked="true"/>
303
             <CheckBox
304
                 android:layout_width="wrap_content"
305
                 android:layout_height="match_parent"
306
                 android:id="@+id/olimpicCheckBoxYellow8"
307
                 android:layout_weight="1"
308
                 android:onClick="onClick"
309
                 android:checked="true"/>
310
        </LinearLayout>
311

  
312
        <LinearLayout
313
            android:orientation="horizontal"
314
            android:layout_width="match_parent"
315
            android:layout_height="0dp"
316
            android:layout_weight="0.5">
317

  
318
            <CheckBox
319
                android:layout_width="wrap_content"
320
                android:layout_height="match_parent"
321
                android:id="@+id/olimpicCheckBoxGreen0"
322
                android:layout_weight="2"
323
                android:onClick="onClick"
324
                android:checked="true"/>
325
            <CheckBox
326
                android:layout_width="wrap_content"
327
                android:layout_height="match_parent"
328
                android:id="@+id/olimpicCheckBoxGreen1"
329
                android:layout_weight="1"
330
                android:onClick="onClick"
331
                android:checked="true"/>
332
            <CheckBox
333
                android:layout_width="wrap_content"
334
                android:layout_height="match_parent"
335
                android:id="@+id/olimpicCheckBoxGreen2"
336
                android:layout_weight="1"
337
                android:onClick="onClick"
338
                android:checked="true"/>
339
            <CheckBox
340
                android:layout_width="wrap_content"
341
                android:layout_height="match_parent"
342
                android:id="@+id/olimpicCheckBoxGreen3"
343
                android:layout_weight="1"
344
                android:onClick="onClick"
345
                android:checked="true"/>
346
             <CheckBox
347
                 android:layout_width="wrap_content"
348
                 android:layout_height="match_parent"
349
                 android:id="@+id/olimpicCheckBoxGreen4"
350
                 android:layout_weight="1"
351
                 android:onClick="onClick"
352
                 android:checked="true"/>
353
             <CheckBox
354
                 android:layout_width="wrap_content"
355
                 android:layout_height="match_parent"
356
                 android:id="@+id/olimpicCheckBoxGreen5"
357
                 android:layout_weight="1"
358
                 android:onClick="onClick"
359
                 android:checked="true"/>
360
             <CheckBox
361
                 android:layout_width="wrap_content"
362
                 android:layout_height="match_parent"
363
                 android:id="@+id/olimpicCheckBoxGreen6"
364
                 android:layout_weight="1"
365
                 android:onClick="onClick"
366
                 android:checked="true"/>
367
             <CheckBox
368
                 android:layout_width="wrap_content"
369
                 android:layout_height="match_parent"
370
                 android:id="@+id/olimpicCheckBoxGreen7"
371
                 android:layout_weight="1"
372
                 android:onClick="onClick"
373
                 android:checked="true"/>
374
             <CheckBox
375
                 android:layout_width="wrap_content"
376
                 android:layout_height="match_parent"
377
                 android:id="@+id/olimpicCheckBoxGreen8"
378
                 android:layout_weight="1"
379
                 android:onClick="onClick"
380
                 android:checked="true"/>
381
        </LinearLayout>
382

  
28 383
    </LinearLayout>
29 384

  
30 385
</LinearLayout>

Also available in: Unified diff