Revision a4b182d4
Added by Leszek Koltunski over 6 years ago
src/main/java/org/distorted/library/main/DistortedFramebuffer.java | ||
---|---|---|
54 | 54 |
GLES31.glTexParameteri(GLES31.GL_TEXTURE_2D, GLES31.GL_TEXTURE_WRAP_T, GLES31.GL_REPEAT); |
55 | 55 |
GLES31.glTexParameterf(GLES31.GL_TEXTURE_2D, GLES31.GL_TEXTURE_MIN_FILTER, GLES31.GL_NEAREST); |
56 | 56 |
GLES31.glTexParameterf(GLES31.GL_TEXTURE_2D, GLES31.GL_TEXTURE_MAG_FILTER, GLES31.GL_LINEAR); |
57 |
GLES31.glTexImage2D(GLES31.GL_TEXTURE_2D, 0, GLES31.GL_RGBA, mWidth, mHeight, 0, GLES31.GL_RGBA, GLES31.GL_UNSIGNED_BYTE, null);
|
|
57 |
GLES31.glTexImage2D(GLES31.GL_TEXTURE_2D, 0, GLES31.GL_RGBA, mRealWidth, mRealHeight, 0, GLES31.GL_RGBA, GLES31.GL_UNSIGNED_BYTE, null);
|
|
58 | 58 |
} |
59 | 59 |
GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_COLOR_ATTACHMENT0, GLES31.GL_TEXTURE_2D, mColorH[0], 0); |
60 | 60 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, 0); |
... | ... | |
73 | 73 |
|
74 | 74 |
if( mDepthStencil==DEPTH_NO_STENCIL ) |
75 | 75 |
{ |
76 |
GLES31.glTexImage2D(GLES31.GL_TEXTURE_2D, 0, GLES31.GL_DEPTH_COMPONENT, mWidth, mHeight, 0, GLES31.GL_DEPTH_COMPONENT, GLES31.GL_UNSIGNED_INT, null);
|
|
76 |
GLES31.glTexImage2D(GLES31.GL_TEXTURE_2D, 0, GLES31.GL_DEPTH_COMPONENT, mRealWidth, mRealHeight, 0, GLES31.GL_DEPTH_COMPONENT, GLES31.GL_UNSIGNED_INT, null);
|
|
77 | 77 |
} |
78 | 78 |
else if( mDepthStencil==BOTH_DEPTH_STENCIL ) |
79 | 79 |
{ |
80 |
GLES31.glTexImage2D(GLES31.GL_TEXTURE_2D, 0, GLES31.GL_DEPTH24_STENCIL8, mWidth, mHeight, 0, GLES31.GL_DEPTH_STENCIL, GLES31.GL_UNSIGNED_INT_24_8, null);
|
|
80 |
GLES31.glTexImage2D(GLES31.GL_TEXTURE_2D, 0, GLES31.GL_DEPTH24_STENCIL8, mRealWidth, mRealHeight, 0, GLES31.GL_DEPTH_STENCIL, GLES31.GL_UNSIGNED_INT_24_8, null);
|
|
81 | 81 |
} |
82 | 82 |
|
83 | 83 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, 0); |
src/main/java/org/distorted/library/main/DistortedInputSurface.java | ||
---|---|---|
24 | 24 |
* A Surface that we can set as an Input (take its rectangle of pixels and skin a Mesh with it). |
25 | 25 |
*/ |
26 | 26 |
|
27 |
// This really ought to be an abstract class instead, but effing Java has no multiple inheritance... |
|
28 |
|
|
27 | 29 |
public interface DistortedInputSurface |
28 | 30 |
{ |
29 | 31 |
/** |
src/main/java/org/distorted/library/main/DistortedOutputSurface.java | ||
---|---|---|
99 | 99 |
|
100 | 100 |
private int mDebugLevel; |
101 | 101 |
|
102 |
protected int mRealWidth; // the Surface can be backed up with a texture that is |
|
103 |
protected int mRealHeight; // larger than the viewport we have to it. |
|
104 |
// mWidth,mHeight are the sizes of the Viewport, those - |
|
105 |
// sizes of the backing up texture. |
|
106 |
|
|
102 | 107 |
//////////////////////////////////////////////////////////////////////////////// |
103 | 108 |
// section dealing with Shader Storage Buffer Object (for counting transparency) |
104 | 109 |
private static final int FRAME_DELAY = 3; |
... | ... | |
138 | 143 |
{ |
139 | 144 |
super(width,height,createColor,numcolors,type); |
140 | 145 |
|
146 |
mRealWidth = width; |
|
147 |
mRealHeight= height; |
|
148 |
|
|
141 | 149 |
mProjectionMatrix = new float[16]; |
142 | 150 |
|
143 | 151 |
mFOV = 60.0f; |
... | ... | |
290 | 298 |
mBuffer[j].mMipmap = mipmap; |
291 | 299 |
mBuffer[j].mNear = mNear; // copy mNear as well (for blitting- see PostprocessEffect.apply() ) |
292 | 300 |
mBuffer[j].glClearColor(1.0f,1.0f,1.0f,0.0f); |
301 |
|
|
293 | 302 |
mipmap *= EffectQuality.MULTIPLIER; |
294 | 303 |
} |
295 | 304 |
|
... | ... | |
314 | 323 |
} |
315 | 324 |
} |
316 | 325 |
|
326 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
327 |
|
|
328 |
private void cloneSize(DistortedOutputSurface from) |
|
329 |
{ |
|
330 |
mWidth = from.mWidth; |
|
331 |
mHeight= from.mHeight; |
|
332 |
|
|
333 |
createProjection(); |
|
334 |
|
|
335 |
int maxw = mWidth >mRealWidth ? mWidth :mRealWidth ; |
|
336 |
int maxh = mHeight>mRealHeight ? mHeight:mRealHeight; |
|
337 |
|
|
338 |
if( maxw>mRealWidth || maxh>mRealHeight ) |
|
339 |
{ |
|
340 |
mRealWidth = maxw; |
|
341 |
mRealHeight= maxh; |
|
342 |
|
|
343 |
recreateSurface(); |
|
344 |
createSurface(); |
|
345 |
} |
|
346 |
} |
|
347 |
|
|
317 | 348 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
318 | 349 |
|
319 | 350 |
private int blitWithDepth(long currTime, DistortedOutputSurface buffer) |
... | ... | |
534 | 565 |
{ |
535 | 566 |
android.util.Log.d("surface", "id " + mSurfaceID + |
536 | 567 |
(mType == TYPE_USER ? " USER" : (mType == TYPE_SYST ? " SYST" : " TREE")) + |
537 |
" (" + mWidth + "x" + mHeight + ") last frame: " + (value - mLastValue[mLastIndex]) |
|
568 |
"viewport: (" + mWidth + "x" + mHeight + ") last frame: " + (value - mLastValue[mLastIndex])
|
|
538 | 569 |
+ " avg: " + (mAvgSum/RUNNING_AVERAGE) |
539 | 570 |
); |
540 | 571 |
} |
... | ... | |
706 | 737 |
{ |
707 | 738 |
if( mWidth!=width || mHeight!=height ) |
708 | 739 |
{ |
709 |
mWidth = width; |
|
710 |
mHeight= height; |
|
740 |
mWidth = mRealWidth = width;
|
|
741 |
mHeight= mRealHeight= height;
|
|
711 | 742 |
|
712 | 743 |
createProjection(); |
713 | 744 |
|
Also available in: Unified diff
Introduce possibility that an OutputSurface is backed up by a larger texture than necessary and the 'cloneSize()' method.