Revision 97dadfe5
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/dynamic/DynamicRenderer.java | ||
---|---|---|
31 | 31 |
|
32 | 32 |
import org.distorted.library.DistortedBitmap; |
33 | 33 |
import org.distorted.library.Distorted; |
34 |
import org.distorted.library.EffectTypes; |
|
35 |
import org.distorted.library.type.Static3D; |
|
36 | 34 |
|
37 | 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
38 | 36 |
|
39 |
public class DynamicRenderer implements GLSurfaceView.Renderer
|
|
37 |
class DynamicRenderer implements GLSurfaceView.Renderer |
|
40 | 38 |
{ |
41 |
public static final int BWID = 300; |
|
42 |
public static final int BHEI = 400; |
|
43 |
|
|
44 | 39 |
private GLSurfaceView mView; |
45 | 40 |
private DistortedBitmap mBackground; |
46 | 41 |
private Canvas mCanvas; |
47 | 42 |
private Bitmap mBitmap; |
48 | 43 |
private Paint mPaint; |
49 |
private int texWidth, texHeight; |
|
44 |
|
|
45 |
static int texW, texH; |
|
50 | 46 |
|
51 | 47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
52 | 48 |
|
53 |
public DynamicRenderer(GLSurfaceView v)
|
|
49 |
DynamicRenderer(GLSurfaceView v) |
|
54 | 50 |
{ |
55 | 51 |
mPaint = new Paint(); |
56 | 52 |
mPaint.setAntiAlias(true); |
... | ... | |
59 | 55 |
mPaint.setStyle(Style.FILL); |
60 | 56 |
|
61 | 57 |
mView = v; |
62 |
|
|
63 |
texWidth = BWID; |
|
64 |
texHeight= BHEI; |
|
65 | 58 |
} |
66 | 59 |
|
67 | 60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
68 | 61 |
|
69 | 62 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
70 | 63 |
{ |
71 |
mBackground = new DistortedBitmap(texWidth,texHeight, 2); |
|
72 |
mBitmap = Bitmap.createBitmap(texWidth,texHeight, Bitmap.Config.ARGB_8888); |
|
73 |
mCanvas = new Canvas(mBitmap); |
|
74 |
|
|
75 | 64 |
try |
76 | 65 |
{ |
77 | 66 |
Distorted.onSurfaceCreated(mView.getContext()); |
... | ... | |
86 | 75 |
|
87 | 76 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
88 | 77 |
{ |
89 |
mBackground.abortEffects(EffectTypes.MATRIX); |
|
90 |
mBackground.scale( new Static3D((float)width/texWidth,(float)height/texHeight,1) ); |
|
91 |
Distorted.onSurfaceChanged(width, height); |
|
92 |
DynamicSurfaceView.setScreenSize(width,height); |
|
78 |
texW = width; |
|
79 |
texH = height; |
|
80 |
|
|
81 |
mBackground = new DistortedBitmap(texW,texH, 2); |
|
82 |
mBitmap = Bitmap.createBitmap(texW,texH, Bitmap.Config.ARGB_8888); |
|
83 |
mCanvas = new Canvas(mBitmap); |
|
84 |
|
|
85 |
Distorted.onSurfaceChanged(texW,texH); |
|
93 | 86 |
} |
94 | 87 |
|
95 | 88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
100 | 93 |
|
101 | 94 |
long time = System.currentTimeMillis(); |
102 | 95 |
|
103 |
mCanvas.drawRect(0, 0, texWidth, texHeight, mPaint);
|
|
96 |
mCanvas.drawRect(0, 0, texW, texH, mPaint);
|
|
104 | 97 |
DynamicSurfaceView.drawCurve(mCanvas,time); |
105 | 98 |
mBackground.setBitmap(mBitmap); |
106 | 99 |
mBackground.draw(time); |
Also available in: Unified diff
1. Attempt to deal with unstable Orthonormal Base in Dynamic class (so far unsuccessful)
2. Improvements to the 'Dynamic' (and by necessity, 'MovingEffects') applications (to be able to debug the previous)