Revision 9ed80185
Added by Leszek Koltunski almost 7 years ago
src/main/java/org/distorted/library/DistortedFramebuffer.java | ||
---|---|---|
38 | 38 |
{ |
39 | 39 |
if( mColorCreated==NOT_CREATED_YET ) |
40 | 40 |
{ |
41 |
GLES30.glGenTextures(1, mColorH, 0); |
|
42 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mColorH[0]); |
|
43 |
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_S, GLES30.GL_REPEAT); |
|
44 |
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_T, GLES30.GL_REPEAT); |
|
45 |
GLES30.glTexParameterf(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MIN_FILTER, GLES30.GL_NEAREST); |
|
46 |
GLES30.glTexParameterf(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_LINEAR); |
|
47 |
GLES30.glTexImage2D(GLES30.GL_TEXTURE_2D, 0, GLES30.GL_RGBA, mWidth, mHeight, 0, GLES30.GL_RGBA, GLES30.GL_UNSIGNED_BYTE, null); |
|
48 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0); |
|
49 |
|
|
41 |
GLES30.glGenTextures( mNumColors, mColorH, 0); |
|
50 | 42 |
GLES30.glGenFramebuffers(1, mFBOH, 0); |
51 | 43 |
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, mFBOH[0]); |
52 |
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0, GLES30.GL_TEXTURE_2D, mColorH[0], 0); |
|
44 |
|
|
45 |
for(int i=0; i<mNumColors; i++) |
|
46 |
{ |
|
47 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mColorH[i]); |
|
48 |
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_S, GLES30.GL_REPEAT); |
|
49 |
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_T, GLES30.GL_REPEAT); |
|
50 |
GLES30.glTexParameterf(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MIN_FILTER, GLES30.GL_NEAREST); |
|
51 |
GLES30.glTexParameterf(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_LINEAR); |
|
52 |
GLES30.glTexImage2D(GLES30.GL_TEXTURE_2D, 0, GLES30.GL_RGBA, mWidth, mHeight, 0, GLES30.GL_RGBA, GLES30.GL_UNSIGNED_BYTE, null); |
|
53 |
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0+i, GLES30.GL_TEXTURE_2D, mColorH[i], 0); |
|
54 |
} |
|
55 |
|
|
56 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0); |
|
53 | 57 |
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0); |
54 | 58 |
|
55 | 59 |
mColorCreated = checkStatus("color"); |
... | ... | |
162 | 166 |
// inside a Tree of DistortedNodes (TREE) |
163 | 167 |
// SYSTEM surfaces do not get removed in onDestroy(). |
164 | 168 |
|
165 |
DistortedFramebuffer(int depthStencil, int type, int width, int height) |
|
169 |
DistortedFramebuffer(int numcolors, int depthStencil, int type, int width, int height)
|
|
166 | 170 |
{ |
167 |
super(width,height,NOT_CREATED_YET,depthStencil,NOT_CREATED_YET, type); |
|
171 |
super(width,height,NOT_CREATED_YET,numcolors,depthStencil,NOT_CREATED_YET, type);
|
|
168 | 172 |
} |
169 | 173 |
|
170 | 174 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
186 | 190 |
// PUBLIC API |
187 | 191 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
188 | 192 |
/** |
189 |
* Create a new offscreen Framebuffer.
|
|
193 |
* Create new offscreen Framebuffer with configurable number of COLOR, DEPTH and STENCIL attachments.
|
|
190 | 194 |
* |
191 |
* @param width Width of the COLOR attachment. |
|
192 |
* @param height Height of the COLOR attachment. |
|
195 |
* @param width Width of all the COLOR attachments. |
|
196 |
* @param height Height of all the COLOR attachments. |
|
197 |
* @param numcolors How many COLOR attachments to create? |
|
193 | 198 |
* @param depthStencil Add DEPTH or STENCIL attachment? |
194 | 199 |
* Valid values: NO_DEPTH_NO_STENCIL, DEPTH_NO_STENCIL, BOTH_DEPTH_STENCIL. |
195 | 200 |
*/ |
196 | 201 |
@SuppressWarnings("unused") |
197 |
public DistortedFramebuffer(int width, int height, int depthStencil) |
|
202 |
public DistortedFramebuffer(int width, int height, int numcolors, int depthStencil)
|
|
198 | 203 |
{ |
199 |
super(width,height,NOT_CREATED_YET,depthStencil,NOT_CREATED_YET,TYPE_USER); |
|
204 |
super(width,height,NOT_CREATED_YET,numcolors,depthStencil,NOT_CREATED_YET,TYPE_USER);
|
|
200 | 205 |
} |
201 | 206 |
|
202 | 207 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
203 | 208 |
|
204 | 209 |
/** |
205 |
* Create a new offscreen Framebuffer. No DEPTH or STENCIL buffer will be created.
|
|
210 |
* Create new offscreen Framebuffer with COLOR0 attachment only.
|
|
206 | 211 |
* |
207 |
* @param width Width of the COLOR attachment. |
|
208 |
* @param height Height of the COLOR attachment. |
|
212 |
* @param width Width of the COLOR0 attachment.
|
|
213 |
* @param height Height of the COLOR0 attachment.
|
|
209 | 214 |
*/ |
210 | 215 |
@SuppressWarnings("unused") |
211 | 216 |
public DistortedFramebuffer(int width, int height) |
212 | 217 |
{ |
213 |
super(width,height,NOT_CREATED_YET, NO_DEPTH_NO_STENCIL,NOT_CREATED_YET,TYPE_USER); |
|
218 |
super(width,height,NOT_CREATED_YET, 1, NO_DEPTH_NO_STENCIL,NOT_CREATED_YET,TYPE_USER);
|
|
214 | 219 |
} |
215 | 220 |
|
216 | 221 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Beginnings of support for multi-COLOR attachment Framebuffers.
This will be used in OutputSurface's Postprocessing Buffer.