|
@@ -49,6 +49,8 @@ public class ThreatIndicatorGLRenderer implements Renderer {
|
|
|
mNextThreatLevel = threatLevel;
|
|
|
}
|
|
|
|
|
|
+ public static boolean showSpeechBubble = false;
|
|
|
+
|
|
|
/**
|
|
|
* Match the background color of the view holding this renderer
|
|
|
* @param color 32 bit integer encoding the color
|
|
@@ -158,7 +160,8 @@ public class ThreatIndicatorGLRenderer implements Renderer {
|
|
|
+ " vertexTexCoord = texCoord;"
|
|
|
+ " gl_Position = vec4(2.0 * (position / resolution) - 1.0, 0.0, 1.0);"
|
|
|
+ "}",
|
|
|
- "uniform sampler2D colormap;" // fragment
|
|
|
+ "precision mediump float;"
|
|
|
+ + "uniform sampler2D colormap;" // fragment
|
|
|
+ "uniform vec3 color;"
|
|
|
+ "varying vec2 vertexTexCoord;"
|
|
|
+ "void main() {"
|
|
@@ -316,44 +319,48 @@ public class ThreatIndicatorGLRenderer implements Renderer {
|
|
|
updateAndroidAndBee();
|
|
|
drawAndroidAndBee(animTime);
|
|
|
|
|
|
- GLES20.glDisable(GLES20.GL_DEPTH_TEST);
|
|
|
- GLES20.glEnable(GLES20.GL_BLEND);
|
|
|
- GLES20.glDisable(GLES20.GL_CULL_FACE);
|
|
|
- GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
|
|
|
- GLES20.glUseProgram(mTexturedProgram);
|
|
|
- int resolutionUniformLoc = GLES20.glGetUniformLocation(mTexturedProgram, "resolution");
|
|
|
- int textureUniformLoc = GLES20.glGetUniformLocation(mTexturedProgram, "colormap");
|
|
|
- int colorUniformLoc = GLES20.glGetUniformLocation(mTexturedProgram, "color");
|
|
|
- GLES20.glUniform2f(resolutionUniformLoc, 1024.0f, 1024.0f);
|
|
|
- GLES20.glUniform1i(textureUniformLoc, 0);
|
|
|
- GLES20.glUniform3f(colorUniformLoc, 1.0f, 1.0f, 1.0f);
|
|
|
- String message = "???";
|
|
|
- switch (mNextThreatLevel) {
|
|
|
- case NOT_MONITORING:
|
|
|
- message = ctx.getString(R.string.honeypot_not_monitoring);
|
|
|
- break;
|
|
|
- case NO_THREAT:
|
|
|
- message = ctx.getString(R.string.honeypot_no_threat);
|
|
|
- break;
|
|
|
- case PAST_THREAT:
|
|
|
- message = ctx.getString(R.string.honeypot_past_threat);
|
|
|
- break;
|
|
|
- case LIVE_THREAT:
|
|
|
- message = ctx.getString(R.string.honeypot_live_threat);
|
|
|
- break;
|
|
|
+ if (showSpeechBubble) {
|
|
|
+ Log.i("GL", "drawing bubble");
|
|
|
+ GLES20.glDisable(GLES20.GL_DEPTH_TEST);
|
|
|
+ GLES20.glEnable(GLES20.GL_BLEND);
|
|
|
+ GLES20.glDisable(GLES20.GL_CULL_FACE);
|
|
|
+ GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
|
|
|
+ GLES20.glUseProgram(mTexturedProgram);
|
|
|
+ int resolutionUniformLoc = GLES20.glGetUniformLocation(mTexturedProgram, "resolution");
|
|
|
+ int textureUniformLoc = GLES20.glGetUniformLocation(mTexturedProgram, "colormap");
|
|
|
+ int colorUniformLoc = GLES20.glGetUniformLocation(mTexturedProgram, "color");
|
|
|
+ GLES20.glUniform2f(resolutionUniformLoc, 1024.0f, 1024.0f);
|
|
|
+ GLES20.glUniform1i(textureUniformLoc, 0);
|
|
|
+ GLES20.glUniform3f(colorUniformLoc, 1.0f, 1.0f, 1.0f);
|
|
|
+ String message = "???";
|
|
|
+ switch (mNextThreatLevel) {
|
|
|
+ case NOT_MONITORING:
|
|
|
+ message = ctx.getString(R.string.honeypot_not_monitoring);
|
|
|
+ break;
|
|
|
+ case NO_THREAT:
|
|
|
+ message = ctx.getString(R.string.honeypot_no_threat);
|
|
|
+ break;
|
|
|
+ case PAST_THREAT:
|
|
|
+ message = ctx.getString(R.string.honeypot_past_threat);
|
|
|
+ break;
|
|
|
+ case LIVE_THREAT:
|
|
|
+ message = ctx.getString(R.string.honeypot_live_threat);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ float textWidth = font.getTextWidth(message);
|
|
|
+ float textHeight = 40.0f;
|
|
|
+ float bubbleSize = textWidth + 100.0f;
|
|
|
+ float y = 0.75f * 1024.0f + 32.0f * (float) Math.sin(2.0 * animTime);
|
|
|
+ float x = 0.5f * 1024.0f + 16.0f * (float) Math.cos(1.0 * animTime);
|
|
|
+ drawTexturedQuad(speechBubbleTexture, x - 0.5f * bubbleSize, y - 0.25f * bubbleSize,
|
|
|
+ bubbleSize, 0.5f * bubbleSize);
|
|
|
+ GLES20.glUniform3f(colorUniformLoc, 0.0f, 0.0f, 0.0f);
|
|
|
+ font.drawText(mTexturedProgram, message, x - 0.5f * textWidth,
|
|
|
+ y - 0.5f * textHeight);
|
|
|
+ GLES20.glUseProgram(0);
|
|
|
+ GLES20.glEnable(GLES20.GL_DEPTH_TEST);
|
|
|
+ GLES20.glDisable(GLES20.GL_BLEND);
|
|
|
}
|
|
|
- float textWidth = font.getTextWidth(message);
|
|
|
- float textHeight = 40.0f;
|
|
|
- float bubbleSize = textWidth + 100.0f;
|
|
|
- float y = 0.75f * 1024.0f + 32.0f * (float)Math.sin(2.0*animTime);
|
|
|
- float x = 0.5f * 1024.0f + 16.0f * (float)Math.cos(1.0*animTime);
|
|
|
- drawTexturedQuad(speechBubbleTexture, x - 0.5f*bubbleSize, y - 0.25f*bubbleSize, bubbleSize, 0.5f*bubbleSize);
|
|
|
- GLES20.glUniform3f(colorUniformLoc, 0.0f, 0.0f, 0.0f);
|
|
|
- font.drawText(mTexturedProgram, message, x - 0.5f*textWidth,
|
|
|
- y - 0.5f*textHeight);
|
|
|
- GLES20.glUseProgram(0);
|
|
|
- GLES20.glEnable(GLES20.GL_DEPTH_TEST);
|
|
|
- GLES20.glDisable(GLES20.GL_BLEND);
|
|
|
|
|
|
long deltaTime = System.currentTimeMillis() - mStartTimeMillis - timeMillis; // time for one frame
|
|
|
if (deltaTime < 33) {
|