Revision d0ad3964
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/bandaged/BandagedPlayRenderer.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package org.distorted.bandaged; |
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; |
... | ... | |
20 | 24 |
import org.distorted.objectlib.effects.BaseEffect; |
21 | 25 |
import org.distorted.objectlib.scrambling.ScrambleStateBandagedCuboid; |
22 | 26 |
|
27 |
import java.io.InputStream; |
|
28 |
|
|
23 | 29 |
import javax.microedition.khronos.egl.EGLConfig; |
24 | 30 |
import javax.microedition.khronos.opengles.GL10; |
25 | 31 |
|
26 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
27 | 33 |
|
28 |
public class BandagedPlayRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
|
34 |
public class BandagedPlayRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
|
29 | 35 |
{ |
30 | 36 |
private final BandagedPlayView mView; |
37 |
private final Resources mResources; |
|
31 | 38 |
private final DistortedScreen mScreen; |
32 | 39 |
|
33 | 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
37 | 44 |
final float BRIGHTNESS = 0.333f; |
38 | 45 |
|
39 | 46 |
mView = v; |
47 |
mResources = v.getResources(); |
|
40 | 48 |
mScreen = new DistortedScreen(); |
41 | 49 |
mScreen.glClearColor(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 1.0f); |
42 | 50 |
} |
... | ... | |
60 | 68 |
mView.setScreenSize(width,height); |
61 | 69 |
} |
62 | 70 |
|
71 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
72 |
|
|
73 |
DistortedScreen getScreen() |
|
74 |
{ |
|
75 |
return mScreen; |
|
76 |
} |
|
77 |
|
|
63 | 78 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
64 | 79 |
|
65 | 80 |
@Override |
... | ... | |
74 | 89 |
VertexEffectQuaternion.enable(); |
75 | 90 |
BaseEffect.Type.enableEffects(); |
76 | 91 |
|
77 |
DistortedLibrary.onSurfaceCreated(mView.getContext(),this,1);
|
|
92 |
DistortedLibrary.onSurfaceCreated(this,1); |
|
78 | 93 |
DistortedLibrary.setCull(true); |
79 | 94 |
} |
80 | 95 |
|
... | ... | |
87 | 102 |
|
88 | 103 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
89 | 104 |
|
90 |
DistortedScreen getScreen() |
|
91 |
{ |
|
92 |
return mScreen; |
|
93 |
} |
|
105 |
public int openGlVersion() |
|
106 |
{ |
|
107 |
Context context = mView.getContext(); |
|
108 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
109 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
110 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
111 |
int major = glESversion >> 16; |
|
112 |
int minor = glESversion & 0xff; |
|
113 |
|
|
114 |
return 100*major + 10*minor; |
|
115 |
} |
|
116 |
|
|
117 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
118 |
|
|
119 |
public InputStream localFile(int fileID) |
|
120 |
{ |
|
121 |
return mResources.openRawResource(fileID); |
|
122 |
} |
|
123 |
|
|
124 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
125 |
|
|
126 |
public void logMessage(String message) |
|
127 |
{ |
|
128 |
android.util.Log.e("BandagedPlay", message ); |
|
129 |
} |
|
94 | 130 |
} |
Also available in: Unified diff
Decouple (to a large degree) the OpenGL Library from Android.