Revision f6d884d5
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java | ||
---|---|---|
27 | 27 |
import org.distorted.examples.R; |
28 | 28 |
import org.distorted.library.Distorted; |
29 | 29 |
import org.distorted.library.GridFlat; |
30 |
import org.distorted.library.DistortedObject; |
|
30 |
import org.distorted.library.DistortedEffectQueues; |
|
31 |
import org.distorted.library.DistortedTexture; |
|
31 | 32 |
import org.distorted.library.EffectTypes; |
32 | 33 |
import org.distorted.library.type.Static3D; |
33 | 34 |
|
... | ... | |
42 | 43 |
class AroundTheWorldRenderer implements GLSurfaceView.Renderer |
43 | 44 |
{ |
44 | 45 |
private GLSurfaceView mView; |
45 |
private DistortedObject mObject; |
|
46 |
private DistortedEffectQueues mQueues; |
|
47 |
private DistortedTexture mTexture; |
|
46 | 48 |
private GridFlat mGrid; |
47 | 49 |
private AroundTheWorldEffectsManager mEffects; |
48 | 50 |
private int mObjWidth, mObjHeight; |
... | ... | |
51 | 53 |
|
52 | 54 |
AroundTheWorldRenderer(GLSurfaceView view) |
53 | 55 |
{ |
54 |
mView = view; |
|
55 |
mEffects = new AroundTheWorldEffectsManager(); |
|
56 |
|
|
57 | 56 |
Distorted.setMaxVertex(12); |
58 | 57 |
Distorted.setMaxFragment(9); |
58 |
|
|
59 |
mView = view; |
|
60 |
mEffects = new AroundTheWorldEffectsManager(); |
|
61 |
mQueues = new DistortedEffectQueues(); |
|
62 |
mEffects.apply(mQueues); |
|
59 | 63 |
} |
60 | 64 |
|
61 | 65 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
70 | 74 |
public void onDrawFrame(GL10 glUnused) |
71 | 75 |
{ |
72 | 76 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
73 |
mObject.draw(System.currentTimeMillis(), mGrid);
|
|
77 |
mQueues.draw(System.currentTimeMillis(), mTexture, mGrid);
|
|
74 | 78 |
} |
75 | 79 |
|
76 | 80 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
77 | 81 |
|
78 | 82 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
79 | 83 |
{ |
80 |
mObject.abortEffects(EffectTypes.MATRIX);
|
|
84 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
81 | 85 |
|
82 | 86 |
if( (float)mObjHeight/mObjWidth > (float)height/width ) |
83 | 87 |
{ |
84 | 88 |
int w = (height*mObjWidth)/mObjHeight; |
85 | 89 |
float factor = (float)height/mObjHeight; |
86 |
mObject.move( new Static3D((width-w)/2,0,0) );
|
|
87 |
mObject.scale(factor);
|
|
90 |
mQueues.move( new Static3D((width-w)/2,0,0) );
|
|
91 |
mQueues.scale(factor);
|
|
88 | 92 |
} |
89 | 93 |
else |
90 | 94 |
{ |
91 | 95 |
int h = (width*mObjHeight)/mObjWidth; |
92 | 96 |
float factor = (float)width/mObjWidth; |
93 |
mObject.move( new Static3D(0,(height-h)/2,0) );
|
|
94 |
mObject.scale(factor);
|
|
97 |
mQueues.move( new Static3D(0,(height-h)/2,0) );
|
|
98 |
mQueues.scale(factor);
|
|
95 | 99 |
} |
96 | 100 |
|
97 | 101 |
Distorted.onSurfaceChanged(width, height); |
... | ... | |
122 | 126 |
mObjWidth = bitmap.getWidth(); |
123 | 127 |
mObjHeight= bitmap.getHeight(); |
124 | 128 |
|
125 |
mObject = new DistortedObject(mObjWidth,mObjHeight,0); |
|
126 |
mObject.setTexture(bitmap); |
|
127 |
mEffects.apply(mObject); |
|
129 |
mTexture = new DistortedTexture(mObjWidth,mObjHeight,0); |
|
130 |
mTexture.setTexture(bitmap); |
|
128 | 131 |
|
129 | 132 |
mGrid = new GridFlat(30,30*mObjHeight/mObjWidth); |
130 | 133 |
|
Also available in: Unified diff
Complete the split DistortedObject -> (DistortedTexture,DistortedEffectQueue)