Revision 9c3e749e
Added by Leszek Koltunski almost 6 years ago
src/main/java/org/distorted/examples/cubes/CubesRenderer.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
import org.distorted.examples.R; |
29 | 29 |
|
30 |
import org.distorted.library.effect.FragmentEffectAlpha; |
|
30 | 31 |
import org.distorted.library.effect.MatrixEffectMove; |
31 | 32 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
32 | 33 |
import org.distorted.library.effect.MatrixEffectScale; |
... | ... | |
35 | 36 |
import org.distorted.library.main.DistortedTexture; |
36 | 37 |
import org.distorted.library.main.MeshObject; |
37 | 38 |
import org.distorted.library.type.DynamicQuat; |
39 |
import org.distorted.library.type.Static1D; |
|
38 | 40 |
import org.distorted.library.type.Static4D; |
39 | 41 |
import org.distorted.library.type.Static3D; |
40 | 42 |
import org.distorted.library.main.Distorted; |
... | ... | |
54 | 56 |
private DistortedScreen mScreen; |
55 | 57 |
private int mObjWidth, mObjHeight, mObjDepth; |
56 | 58 |
private Static3D mMove, mScale, mCenter; |
59 |
private Static1D mAlpha; |
|
57 | 60 |
|
58 | 61 |
Static4D mQuat1, mQuat2; |
59 | 62 |
int mScreenMin; |
60 |
|
|
63 |
|
|
61 | 64 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
62 | 65 |
|
63 | 66 |
CubesRenderer(GLSurfaceView v) |
64 | 67 |
{ |
65 | 68 |
mView = v; |
66 | 69 |
|
70 |
mAlpha = new Static1D(1.0f); |
|
71 |
|
|
67 | 72 |
mMove = new Static3D(0,0,0); |
68 | 73 |
mScale= new Static3D(1,1,1); |
69 | 74 |
mCenter=new Static3D(0,0,0); |
... | ... | |
91 | 96 |
mEffects.apply( new MatrixEffectScale(mScale)); |
92 | 97 |
mEffects.apply( new MatrixEffectQuaternion(quatInt1, mCenter) ); |
93 | 98 |
mEffects.apply( new MatrixEffectQuaternion(quatInt2, mCenter) ); |
99 |
mEffects.apply( new FragmentEffectAlpha(mAlpha)); |
|
94 | 100 |
|
95 | 101 |
mScreen = new DistortedScreen(); |
102 |
mScreen.glClearColor(1.0f,1.0f,1.0f,0.0f); |
|
96 | 103 |
} |
97 | 104 |
|
98 | 105 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
114 | 121 |
mScreen.resize(width, height); |
115 | 122 |
} |
116 | 123 |
|
124 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
125 |
|
|
126 |
void setRenderModeToOIT(boolean oit) |
|
127 |
{ |
|
128 |
mScreen.setOrderIndependentTransparency(oit); |
|
129 |
} |
|
130 |
|
|
131 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
132 |
|
|
133 |
void setTransparency(int level) |
|
134 |
{ |
|
135 |
mAlpha.set((float)level/100.0f); |
|
136 |
} |
|
137 |
|
|
117 | 138 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
118 | 139 |
|
119 | 140 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
... | ... | |
139 | 160 |
mScreen.detachAll(); |
140 | 161 |
mScreen.attach(mTexture,mEffects,mMesh); |
141 | 162 |
|
163 |
FragmentEffectAlpha.enable(); |
|
164 |
|
|
142 | 165 |
try |
143 | 166 |
{ |
144 | 167 |
Distorted.onCreate(mView.getContext()); |
Also available in: Unified diff
Make the Cubes App capable of testing unprocessed OIT.