Revision c840136b
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/library/main/DistortedScreen.java | ||
---|---|---|
70 | 70 |
private int mToBeBlittedFBO; // FBO one we have rendered. Then, we keep blitting the one we |
71 | 71 |
private boolean mFirstCircle; // rendered FBO_QUEUE_SIZE ago. |
72 | 72 |
|
73 |
private int mDebugWidth, mDebugHeight, mDebugGap, mDebugTextColor, mDebugBackColor; |
|
74 |
|
|
73 | 75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
74 | 76 |
// PUBLIC API |
75 | 77 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
119 | 121 |
frameNumber++; |
120 | 122 |
} |
121 | 123 |
|
122 |
int width = (int)(mWidth*DEBUG_SCR_FRAC); |
|
123 |
int height= (int)(mWidth*DEBUG_SCR_FRAC*DEBUG_FRAC); |
|
124 |
|
|
125 | 124 |
if( !mDebugAllocated ) |
126 |
{ |
|
127 |
mDebugAllocated = true; |
|
128 |
debugString = ""; |
|
129 |
|
|
130 |
debugBitmap = Bitmap.createBitmap( width, height, Bitmap.Config.ARGB_8888);
|
|
131 |
debugMesh = new MeshQuad(); |
|
132 |
debugTexture = new DistortedTexture(); |
|
133 |
debugTexture.setTexture(debugBitmap); |
|
134 |
debugCanvas = new Canvas(debugBitmap); |
|
135 |
debugEffects = new DistortedEffects(); |
|
136 |
debugEffects.apply( new MatrixEffectScale( new Static3D(width,height,1) ) );
|
|
137 |
debugEffects.apply(mMoveEffect); |
|
138 |
|
|
139 |
mPaint = new Paint(); |
|
140 |
mPaint.setAntiAlias(true); |
|
141 |
mPaint.setTextAlign(Paint.Align.CENTER); |
|
142 |
mPaint.setTextSize(0.7f*height);
|
|
143 |
} |
|
144 |
|
|
145 |
mPaint.setColor(0xffffffff);
|
|
146 |
debugCanvas.drawRect(0, 0, width, height, mPaint);
|
|
147 |
mPaint.setColor(0xff000000);
|
|
148 |
debugCanvas.drawText(debugString, 0.5f*width, 0.75f*height, mPaint);
|
|
125 |
{
|
|
126 |
mDebugAllocated = true;
|
|
127 |
debugString = "";
|
|
128 |
|
|
129 |
debugBitmap = Bitmap.createBitmap( mDebugWidth, mDebugHeight, Bitmap.Config.ARGB_8888);
|
|
130 |
debugMesh = new MeshQuad();
|
|
131 |
debugTexture = new DistortedTexture();
|
|
132 |
debugTexture.setTexture(debugBitmap);
|
|
133 |
debugCanvas = new Canvas(debugBitmap);
|
|
134 |
debugEffects = new DistortedEffects();
|
|
135 |
debugEffects.apply( new MatrixEffectScale( new Static3D(mDebugWidth,mDebugHeight,1) ) );
|
|
136 |
debugEffects.apply(mMoveEffect);
|
|
137 |
|
|
138 |
mPaint = new Paint();
|
|
139 |
mPaint.setAntiAlias(true);
|
|
140 |
mPaint.setTextAlign(Paint.Align.CENTER);
|
|
141 |
mPaint.setTextSize(0.7f*mDebugHeight);
|
|
142 |
}
|
|
143 |
|
|
144 |
mPaint.setColor(mDebugBackColor);
|
|
145 |
debugCanvas.drawRect(0, 0, mDebugWidth, mDebugHeight, mPaint);
|
|
146 |
mPaint.setColor(mDebugTextColor);
|
|
147 |
debugCanvas.drawText(debugString, 0.5f*mDebugWidth, 0.75f*mDebugHeight, mPaint);
|
|
149 | 148 |
debugTexture.setTexture(debugBitmap); |
150 | 149 |
|
151 |
mMoveVector.set( (-mWidth+width)*0.5f +5, (mHeight-height)*0.5f -5, 0);
|
|
150 |
mMoveVector.set( (-mWidth+mDebugWidth)*0.5f +mDebugGap, (mHeight-mDebugHeight)*0.5f -mDebugGap, 0);
|
|
152 | 151 |
|
153 | 152 |
lastTime = time; |
154 | 153 |
} |
... | ... | |
202 | 201 |
*/ |
203 | 202 |
public void showFPS() |
204 | 203 |
{ |
204 |
int width = (int)(mWidth*DEBUG_SCR_FRAC); |
|
205 |
int height = (int)(mWidth*DEBUG_SCR_FRAC*DEBUG_FRAC); |
|
206 |
int gap = 5; |
|
207 |
int textColor = 0xffffffff; |
|
208 |
int backColor = 0xff000000; |
|
209 |
|
|
210 |
showFPS(width,height,gap,textColor,backColor); |
|
211 |
} |
|
212 |
|
|
213 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
214 |
/** |
|
215 |
* Make the library show Frames Per Second in the upper-left corner. |
|
216 |
* Set appropriate params. |
|
217 |
* <p> |
|
218 |
*/ |
|
219 |
public void showFPS(int width, int height, int gap, int textColor, int backColor) |
|
220 |
{ |
|
221 |
mDebugWidth = width; |
|
222 |
mDebugHeight = height; |
|
223 |
mDebugGap = gap; |
|
224 |
mDebugBackColor = backColor; |
|
225 |
mDebugTextColor = textColor; |
|
226 |
|
|
205 | 227 |
if( mDebugMode!=DEBUG_MODE_FPS ) |
206 | 228 |
{ |
207 | 229 |
mDebugMode = DEBUG_MODE_FPS; |
Also available in: Unified diff
Add info about FPS.