Revision dc10a48d
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/examples/projection/ProjectionRenderer.java | ||
---|---|---|
33 | 33 |
import org.distorted.library.type.Static3D; |
34 | 34 |
import org.distorted.library.type.Static4D; |
35 | 35 |
|
36 |
import android.app.ActivityManager; |
|
37 |
import android.content.Context; |
|
38 |
import android.content.pm.ConfigurationInfo; |
|
39 |
import android.content.res.Resources; |
|
36 | 40 |
import android.graphics.Bitmap; |
37 | 41 |
import android.graphics.Canvas; |
38 | 42 |
import android.graphics.Paint; |
39 | 43 |
import android.graphics.Paint.Style; |
40 | 44 |
import android.opengl.GLSurfaceView; |
41 | 45 |
|
46 |
import java.io.InputStream; |
|
47 |
|
|
42 | 48 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
43 | 49 |
|
44 |
class ProjectionRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
|
50 |
class ProjectionRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
|
45 | 51 |
{ |
46 |
private GLSurfaceView mView; |
|
47 |
private DistortedEffects mEffects; |
|
48 |
private DistortedScreen mScreen; |
|
52 |
private final GLSurfaceView mView; |
|
53 |
private final Resources mResources; |
|
54 |
private final DistortedEffects mEffects; |
|
55 |
private final DistortedScreen mScreen; |
|
56 |
private final DistortedTexture mTexture; |
|
57 |
private final Static3D mScale; |
|
58 |
|
|
49 | 59 |
private MeshSquare mMesh; |
50 |
private DistortedTexture mTexture; |
|
51 | 60 |
private float mF, mNear; |
52 |
private Static3D mScale; |
|
53 | 61 |
|
54 | 62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
55 | 63 |
|
56 | 64 |
ProjectionRenderer(GLSurfaceView view) |
57 | 65 |
{ |
58 |
mView = view; |
|
66 |
mView = view; |
|
67 |
mResources = view.getResources(); |
|
68 |
|
|
59 | 69 |
mEffects= new DistortedEffects(); |
60 | 70 |
mScreen = new DistortedScreen(); |
61 | 71 |
|
... | ... | |
145 | 155 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
146 | 156 |
{ |
147 | 157 |
VertexEffectDeform.enable(); |
148 |
|
|
149 |
DistortedLibrary.onSurfaceCreated(mView.getContext(), this); |
|
158 |
DistortedLibrary.onSurfaceCreated(this); |
|
150 | 159 |
} |
151 | 160 |
|
152 | 161 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
155 | 164 |
{ |
156 | 165 |
android.util.Log.e("Projection", ex.getMessage() ); |
157 | 166 |
} |
167 |
|
|
168 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
169 |
|
|
170 |
public int openGlVersion() |
|
171 |
{ |
|
172 |
Context context = mView.getContext(); |
|
173 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
174 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
175 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
176 |
int major = glESversion >> 16; |
|
177 |
int minor = glESversion & 0xff; |
|
178 |
|
|
179 |
return 100*major + 10*minor; |
|
180 |
} |
|
181 |
|
|
182 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
183 |
|
|
184 |
public InputStream localFile(int fileID) |
|
185 |
{ |
|
186 |
return mResources.openRawResource(fileID); |
|
187 |
} |
|
188 |
|
|
189 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
190 |
|
|
191 |
public void logMessage(String message) |
|
192 |
{ |
|
193 |
android.util.Log.e("Projection", message ); |
|
194 |
} |
|
158 | 195 |
} |
Also available in: Unified diff
Decouple (to a large degree) the OpenGL Library from Android.