Revision dc10a48d
Added by Leszek Koltunski over 2 years ago
| src/main/java/org/distorted/examples/effectqueue/EffectQueueRenderer.java | ||
|---|---|---|
| 22 | 22 |
import javax.microedition.khronos.egl.EGLConfig; |
| 23 | 23 |
import javax.microedition.khronos.opengles.GL10; |
| 24 | 24 |
|
| 25 |
import android.app.ActivityManager; |
|
| 26 |
import android.content.Context; |
|
| 27 |
import android.content.pm.ConfigurationInfo; |
|
| 28 |
import android.content.res.Resources; |
|
| 25 | 29 |
import android.graphics.Bitmap; |
| 26 | 30 |
import android.graphics.Canvas; |
| 27 | 31 |
import android.graphics.Paint; |
| ... | ... | |
| 42 | 46 |
import org.distorted.library.message.EffectListener; |
| 43 | 47 |
import org.distorted.library.type.Static3D; |
| 44 | 48 |
|
| 49 |
import java.io.InputStream; |
|
| 50 |
|
|
| 45 | 51 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 46 | 52 |
|
| 47 |
class EffectQueueRenderer implements GLSurfaceView.Renderer, EffectListener, DistortedLibrary.ExceptionListener
|
|
| 53 |
class EffectQueueRenderer implements GLSurfaceView.Renderer, EffectListener, DistortedLibrary.LibraryUser
|
|
| 48 | 54 |
{
|
| 49 | 55 |
private static final int NUMLINES = 10; |
| 50 | 56 |
private static final int MESH_QUALITY = 100; |
| 51 | 57 |
static final int BWID = 600; |
| 52 | 58 |
static final int BHEI = 600; |
| 53 |
|
|
| 54 |
private EffectQueueSurfaceView mView; |
|
| 55 |
private Paint mPaint; |
|
| 56 |
private int texWidth, texHeight; |
|
| 57 |
private Static3D mScale; |
|
| 58 | 59 |
|
| 59 |
private DistortedTexture mTexture; |
|
| 60 |
private MeshSquare mMesh; |
|
| 61 |
private DistortedEffects mEffects; |
|
| 62 |
private DistortedScreen mScreen; |
|
| 60 |
private final EffectQueueSurfaceView mView; |
|
| 61 |
private final Resources mResources; |
|
| 62 |
private final DistortedTexture mTexture; |
|
| 63 |
private final MeshSquare mMesh; |
|
| 64 |
private final DistortedEffects mEffects; |
|
| 65 |
private final DistortedScreen mScreen; |
|
| 66 |
private final Paint mPaint; |
|
| 67 |
private final Static3D mScale; |
|
| 68 |
private final int texWidth, texHeight; |
|
| 63 | 69 |
|
| 64 | 70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 65 | 71 |
|
| 66 | 72 |
EffectQueueRenderer(EffectQueueSurfaceView v) |
| 67 |
{
|
|
| 73 |
{
|
|
| 74 |
mView = v; |
|
| 75 |
mResources = v.getResources(); |
|
| 76 |
|
|
| 68 | 77 |
mPaint = new Paint(); |
| 69 | 78 |
mPaint.setAntiAlias(true); |
| 70 | 79 |
mPaint.setFakeBoldText(true); |
| 71 | 80 |
mPaint.setStyle(Style.FILL); |
| 72 |
|
|
| 73 |
mView = v; |
|
| 74 |
|
|
| 81 |
|
|
| 75 | 82 |
texWidth = BWID; |
| 76 | 83 |
texHeight= BHEI; |
| 77 | 84 |
mScale = new Static3D(1,1,1); |
| ... | ... | |
| 141 | 148 |
FragmentEffectChroma.enable(); |
| 142 | 149 |
FragmentEffectSaturation.enable(); |
| 143 | 150 |
|
| 144 |
DistortedLibrary.onSurfaceCreated(mView.getContext(), this); |
|
| 151 |
DistortedLibrary.onSurfaceCreated(this); |
|
| 152 |
} |
|
| 153 |
|
|
| 154 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 155 |
|
|
| 156 |
public void effectFinished(final long effectID) |
|
| 157 |
{
|
|
| 158 |
EffectQueueActivity act = (EffectQueueActivity)mView.getContext(); |
|
| 159 |
act.effectFinished(effectID); |
|
| 145 | 160 |
} |
| 146 | 161 |
|
| 147 | 162 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 153 | 168 |
|
| 154 | 169 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 155 | 170 |
|
| 156 |
public void effectFinished(final long effectID)
|
|
| 171 |
public int openGlVersion()
|
|
| 157 | 172 |
{
|
| 158 |
EffectQueueActivity act = (EffectQueueActivity)mView.getContext(); |
|
| 159 |
act.effectFinished(effectID); |
|
| 173 |
Context context = mView.getContext(); |
|
| 174 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
| 175 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
| 176 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
| 177 |
int major = glESversion >> 16; |
|
| 178 |
int minor = glESversion & 0xff; |
|
| 179 |
|
|
| 180 |
return 100*major + 10*minor; |
|
| 181 |
} |
|
| 182 |
|
|
| 183 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 184 |
|
|
| 185 |
public InputStream localFile(int fileID) |
|
| 186 |
{
|
|
| 187 |
return mResources.openRawResource(fileID); |
|
| 188 |
} |
|
| 189 |
|
|
| 190 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 191 |
|
|
| 192 |
public void logMessage(String message) |
|
| 193 |
{
|
|
| 194 |
android.util.Log.e("EffectQueue", message );
|
|
| 160 | 195 |
} |
| 161 | 196 |
} |
Also available in: Unified diff
Decouple (to a large degree) the OpenGL Library from Android.