Revision d0ad3964
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/purchase/PurchaseRenderer.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package org.distorted.purchase; |
11 | 11 |
|
12 |
import android.app.ActivityManager; |
|
13 |
import android.content.Context; |
|
14 |
import android.content.pm.ConfigurationInfo; |
|
15 |
import android.content.res.Resources; |
|
12 | 16 |
import android.opengl.GLSurfaceView; |
13 | 17 |
|
14 | 18 |
import org.distorted.library.effect.EffectType; |
... | ... | |
21 | 25 |
import org.distorted.objectlib.main.ObjectControl; |
22 | 26 |
import org.distorted.overlays.OverlayGeneric; |
23 | 27 |
|
28 |
import java.io.InputStream; |
|
29 |
|
|
24 | 30 |
import javax.microedition.khronos.egl.EGLConfig; |
25 | 31 |
import javax.microedition.khronos.opengles.GL10; |
26 | 32 |
|
27 | 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
28 | 34 |
|
29 |
public class PurchaseRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
|
35 |
public class PurchaseRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
|
30 | 36 |
{ |
31 | 37 |
private static final int NUM_SCRAMBLES = 5; |
32 | 38 |
private static final int DURATION = NUM_SCRAMBLES*2*1000; |
33 | 39 |
|
34 | 40 |
private final PurchaseSurfaceView mView; |
41 |
private final Resources mResources; |
|
35 | 42 |
private final DistortedScreen mScreen; |
36 | 43 |
|
37 | 44 |
private boolean mFirstRender; |
... | ... | |
42 | 49 |
{ |
43 | 50 |
final float BRIGHTNESS = 0.333f; |
44 | 51 |
|
45 |
mFirstRender = true; |
|
46 | 52 |
mView = v; |
53 |
mResources = v.getResources(); |
|
54 |
|
|
55 |
mFirstRender = true; |
|
47 | 56 |
mScreen = new DistortedScreen(); |
48 | 57 |
mScreen.glClearColor(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 1.0f); |
49 | 58 |
} |
... | ... | |
73 | 82 |
mView.setScreenSize(width,height); |
74 | 83 |
} |
75 | 84 |
|
85 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
86 |
|
|
87 |
DistortedScreen getScreen() |
|
88 |
{ |
|
89 |
return mScreen; |
|
90 |
} |
|
91 |
|
|
76 | 92 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
77 | 93 |
|
78 | 94 |
@Override |
... | ... | |
86 | 102 |
BaseEffect.Type.enableEffects(); |
87 | 103 |
OverlayGeneric.enableEffects(); |
88 | 104 |
|
89 |
DistortedLibrary.onSurfaceCreated(mView.getContext(),this,1);
|
|
105 |
DistortedLibrary.onSurfaceCreated(this,1); |
|
90 | 106 |
DistortedLibrary.setCull(true); |
91 | 107 |
} |
92 | 108 |
|
... | ... | |
94 | 110 |
|
95 | 111 |
public void distortedException(Exception ex) |
96 | 112 |
{ |
97 |
android.util.Log.e("PURCHASE", "unexpected exception: "+ex.getMessage() );
|
|
113 |
android.util.Log.e("Purchase", "unexpected exception: "+ex.getMessage() );
|
|
98 | 114 |
} |
99 | 115 |
|
100 | 116 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
101 | 117 |
|
102 |
DistortedScreen getScreen() |
|
103 |
{ |
|
104 |
return mScreen; |
|
105 |
} |
|
118 |
public int openGlVersion() |
|
119 |
{ |
|
120 |
Context context = mView.getContext(); |
|
121 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
122 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
123 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
124 |
int major = glESversion >> 16; |
|
125 |
int minor = glESversion & 0xff; |
|
126 |
|
|
127 |
return 100*major + 10*minor; |
|
128 |
} |
|
129 |
|
|
130 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
131 |
|
|
132 |
public InputStream localFile(int fileID) |
|
133 |
{ |
|
134 |
return mResources.openRawResource(fileID); |
|
135 |
} |
|
136 |
|
|
137 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
138 |
|
|
139 |
public void logMessage(String message) |
|
140 |
{ |
|
141 |
android.util.Log.e("Purchase", message ); |
|
142 |
} |
|
106 | 143 |
} |
Also available in: Unified diff
Decouple (to a large degree) the OpenGL Library from Android.