@@ -636,7 +636,16 @@ int main(int argc, char *argv[])
636
636
}
637
637
#endif
638
638
if (!gPostVideoSetupDone ) {
639
-
639
+ #ifdef ANDROID
640
+ char *toast;
641
+ if (asprintf (&toast, " Camera: %dx%d" , vs->getVideoWidth (), vs->getVideoHeight ()) < 0 ) {
642
+ ARLOGe (" asprintf" );
643
+ } else {
644
+ SDL_AndroidShowToast (toast, 1 , -1 , 0 , 0 ); // int duration = 1 = long, int gravity = -1 = don't care, int xoffset, int yoffset
645
+ free (toast);
646
+ }
647
+ #endif
648
+
640
649
gCameraIsFrontFacing = false ;
641
650
AR2VideoParamT *vid = vs->getAR2VideoParam ();
642
651
@@ -870,7 +879,7 @@ static void init(int argc, char *argv[])
870
879
}
871
880
}
872
881
873
- static void drawBackground (const float width, const float height, const float x, const float y, const bool drawBorder)
882
+ static void drawBackground (const float width, const float height, const float x, const float y, const bool drawBorder, const GLfloat p[ 16 ] )
874
883
{
875
884
GLfloat vertices[4 ][2 ];
876
885
#if HAVE_GLES2
@@ -884,7 +893,7 @@ static void drawBackground(const float width, const float height, const float x,
884
893
vertices[3 ][0 ] = x; vertices[3 ][1 ] = height + y;
885
894
886
895
#if !HAVE_GLES2
887
- glLoadIdentity ();
896
+ glLoadIdentity (); // Reset to ortho origin. Assumes MODELVIEW mode.
888
897
glDisable (GL_DEPTH_TEST);
889
898
glDisable (GL_LIGHTING);
890
899
glDisable (GL_TEXTURE_2D);
@@ -903,6 +912,8 @@ static void drawBackground(const float width, const float height, const float x,
903
912
glDrawArrays (GL_LINE_LOOP, 0 , 4 );
904
913
}
905
914
#else
915
+ glUseProgram (program);
916
+ glUniformMatrix4fv (uniforms[UNIFORM_MODELVIEW_PROJECTION_MATRIX], 1 , GL_FALSE, p);
906
917
glStateCacheDisableDepthTest ();
907
918
glStateCacheBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
908
919
glStateCacheEnableBlend ();
@@ -921,15 +932,17 @@ static void drawBackground(const float width, const float height, const float x,
921
932
922
933
// An animation while we're waiting.
923
934
// Designed to be drawn on background of at least 3xsquareSize wide and tall.
924
- static void drawBusyIndicator (int positionX, int positionY, int squareSize, struct timeval *tp)
935
+ static void drawBusyIndicator (int positionX, int positionY, int squareSize, struct timeval *tp, const GLfloat p[ 16 ] )
925
936
{
926
- #if !HAVE_GLES2
927
937
const GLfloat square_vertices [4 ][2 ] = { {0 .5f , 0 .5f }, {squareSize - 0 .5f , 0 .5f }, {squareSize - 0 .5f , squareSize - 0 .5f }, {0 .5f , squareSize - 0 .5f } };
928
938
int i;
929
939
930
940
int hundredthSeconds = (int )tp->tv_usec / 1E4 ;
941
+ int secDiv255 = (int )tp->tv_usec / 3921 ;
942
+ int secMod6 = tp->tv_sec % 6 ;
931
943
932
944
// Set up drawing.
945
+ #if !HAVE_GLES2
933
946
glPushMatrix ();
934
947
glLoadIdentity ();
935
948
glDisable (GL_DEPTH_TEST);
@@ -941,14 +954,28 @@ static void drawBusyIndicator(int positionX, int positionY, int squareSize, stru
941
954
glDisableClientState (GL_NORMAL_ARRAY);
942
955
glClientActiveTexture (GL_TEXTURE0);
943
956
glDisableClientState (GL_TEXTURE_COORD_ARRAY);
957
+ #else
958
+ GLfloat mvp[16 ];
959
+ glStateCacheDisableDepthTest ();
960
+ glStateCacheDisableBlend ();
961
+ glVertexAttribPointer (ATTRIBUTE_VERTEX, 2 , GL_FLOAT, GL_FALSE, 0 , square_vertices);
962
+ glEnableVertexAttribArray (ATTRIBUTE_VERTEX);
963
+ #endif
944
964
945
965
for (i = 0 ; i < 4 ; i++) {
966
+ float tx = (float )(positionX + ((i + 1 )/2 != 1 ? -squareSize : 0 .0f ));
967
+ float ty = (float )(positionY + (i / 2 == 0 ? 0 .0f : -squareSize));
968
+ #if !HAVE_GLES2
946
969
glLoadIdentity ();
947
- glTranslatef ((float )(positionX + ((i + 1 )/2 != 1 ? -squareSize : 0 .0f )), (float )(positionY + (i / 2 == 0 ? 0 .0f : -squareSize)), 0 .0f ); // Order: UL, UR, LR, LL.
970
+ glTranslatef (tx, ty , 0 .0f ); // Order: UL, UR, LR, LL.
971
+ #else
972
+ mtxLoadMatrixf (mvp, p);
973
+ mtxTranslatef (mvp, tx, ty, 0 .0f );
974
+ glUseProgram (program);
975
+ glUniformMatrix4fv (uniforms[UNIFORM_MODELVIEW_PROJECTION_MATRIX], 1 , GL_FALSE, mvp);
976
+ #endif
948
977
if (i == hundredthSeconds / 25 ) {
949
978
unsigned char r, g, b;
950
- int secDiv255 = (int )tp->tv_usec / 3921 ;
951
- int secMod6 = tp->tv_sec % 6 ;
952
979
if (secMod6 == 0 ) {
953
980
r = 255 ; g = secDiv255; b = 0 ;
954
981
} else if (secMod6 == 1 ) {
@@ -962,13 +989,24 @@ static void drawBusyIndicator(int positionX, int positionY, int squareSize, stru
962
989
} else {
963
990
r = 255 ; g = 0 ; b = secDiv255;
964
991
}
992
+ #if !HAVE_GLES2
965
993
glColor4ub (r, g, b, 255 );
994
+ #else
995
+ const float color[4 ] = {(float )r/255 .0f , (float )g/255 .0f , (float )b/255 .0f , 1 .0f };
996
+ glUniform4fv (uniforms[UNIFORM_COLOR], 1 , color);
997
+ #endif
966
998
glDrawArrays (GL_TRIANGLE_FAN, 0 , 4 );
967
999
}
1000
+ #if !HAVE_GLES2
968
1001
glColor4ub (255 , 255 , 255 , 255 );
1002
+ #else
1003
+ const float colorWhite[4 ] = {1 .0f , 1 .0f , 1 .0f , 1 .0f };
1004
+ glUniform4fv (uniforms[UNIFORM_COLOR], 1 , colorWhite);
1005
+ #endif
969
1006
glDrawArrays (GL_LINE_LOOP, 0 , 4 );
970
1007
}
971
1008
1009
+ #if !HAVE_GLES2
972
1010
glPopMatrix ();
973
1011
#endif // !HAVE_GLES2
974
1012
}
@@ -1127,20 +1165,26 @@ void drawView(void)
1127
1165
//
1128
1166
// Setup for drawing on top of video frame, in viewPort coordinates.
1129
1167
//
1130
- #if 0
1131
- glMatrixMode(GL_PROJECTION);
1132
- glLoadIdentity();
1168
+ #if 0 // NOT USED
1133
1169
bottom = 0.0f;
1134
1170
top = (float)(viewPort[viewPortIndexHeight]);
1135
1171
left = 0.0f;
1136
1172
right = (float)(viewPort[viewPortIndexWidth]);
1173
+ # if !HAVE_GLES2
1174
+ glMatrixMode(GL_PROJECTION);
1175
+ glLoadIdentity();
1137
1176
glOrthof(left, right, bottom, top, -1.0f, 1.0f);
1138
1177
glMatrixMode(GL_MODELVIEW);
1139
1178
glLoadIdentity();
1140
-
1179
+ # else
1180
+ mtxLoadIdentityf(p);
1181
+ mtxOrthof(p, left, right, bottom, top, -1.0f, 1.0f);
1182
+ glUseProgram(program);
1183
+ glUniformMatrix4fv(uniforms[UNIFORM_MODELVIEW_PROJECTION_MATRIX], 1, GL_FALSE, p);
1184
+ # endif
1141
1185
EdenGLFontSetViewSize(right, top);
1142
1186
EdenMessageSetViewSize(right, top, gDisplayDPI);
1143
- #endif
1187
+ #endif // 0
1144
1188
1145
1189
//
1146
1190
// Setup for drawing on screen, with correct orientation for user.
@@ -1152,12 +1196,11 @@ void drawView(void)
1152
1196
right = (float )contextWidth;
1153
1197
mtxLoadIdentityf (p);
1154
1198
mtxOrthof (p, left, right, bottom, top, -1 .0f , 1 .0f );
1155
- mtxLoadIdentityf (m);
1156
1199
#if !HAVE_GLES2
1157
1200
glMatrixMode (GL_PROJECTION);
1158
1201
glLoadMatrixf (p);
1159
1202
glMatrixMode (GL_MODELVIEW);
1160
- glLoadMatrixf (m );
1203
+ glLoadIdentity ( );
1161
1204
#else
1162
1205
glUseProgram (program);
1163
1206
glUniformMatrix4fv (uniforms[UNIFORM_MODELVIEW_PROJECTION_MATRIX], 1 , GL_FALSE, p);
@@ -1170,7 +1213,7 @@ void drawView(void)
1170
1213
1171
1214
// Draw status bar with centred status message.
1172
1215
if (statusBarMessage[0 ]) {
1173
- drawBackground (right, statusBarHeight, 0 .0f , 0 .0f , false );
1216
+ drawBackground (right, statusBarHeight, 0 .0f , 0 .0f , false , p );
1174
1217
glDisable (GL_BLEND);
1175
1218
EdenGLFontDrawLine (0 , p, statusBarMessage, 0 .0f , 2 .0f , H_OFFSET_VIEW_CENTER_TO_TEXT_CENTER, V_OFFSET_VIEW_BOTTOM_TO_TEXT_BASELINE);
1176
1219
}
@@ -1187,8 +1230,8 @@ void drawView(void)
1187
1230
h = MAX (FONT_SIZE, 3 *squareSize) + 2 *4 .0f /* box margin */ ;
1188
1231
x = right - (w + 2 .0f );
1189
1232
y = statusBarHeight + 2 .0f ;
1190
- drawBackground (w, h, x, y, true );
1191
- if (status == 1 ) drawBusyIndicator ((int )(x + 4 .0f + 1 .5f *squareSize), (int )(y + 4 .0f + 1 .5f *squareSize), squareSize, &time);
1233
+ drawBackground (w, h, x, y, true , p );
1234
+ if (status == 1 ) drawBusyIndicator ((int )(x + 4 .0f + 1 .5f *squareSize), (int )(y + 4 .0f + 1 .5f *squareSize), squareSize, &time, p );
1192
1235
EdenGLFontDrawLine (0 , p, (unsigned char *)uploadStatus, x + 4 .0f + 3 *squareSize, y + (h - FONT_SIZE)/2 .0f , H_OFFSET_VIEW_LEFT_EDGE_TO_TEXT_LEFT_EDGE, V_OFFSET_VIEW_BOTTOM_TO_TEXT_BASELINE);
1193
1236
}
1194
1237
}
0 commit comments