@@ -879,7 +879,7 @@ static void init(int argc, char *argv[])
879
879
}
880
880
}
881
881
882
- 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 ] )
883
883
{
884
884
GLfloat vertices[4 ][2 ];
885
885
#if HAVE_GLES2
@@ -893,7 +893,7 @@ static void drawBackground(const float width, const float height, const float x,
893
893
vertices[3 ][0 ] = x; vertices[3 ][1 ] = height + y;
894
894
895
895
#if !HAVE_GLES2
896
- glLoadIdentity ();
896
+ glLoadIdentity (); // Reset to ortho origin. Assumes MODELVIEW mode.
897
897
glDisable (GL_DEPTH_TEST);
898
898
glDisable (GL_LIGHTING);
899
899
glDisable (GL_TEXTURE_2D);
@@ -912,6 +912,8 @@ static void drawBackground(const float width, const float height, const float x,
912
912
glDrawArrays (GL_LINE_LOOP, 0 , 4 );
913
913
}
914
914
#else
915
+ glUseProgram (program);
916
+ glUniformMatrix4fv (uniforms[UNIFORM_MODELVIEW_PROJECTION_MATRIX], 1 , GL_FALSE, p);
915
917
glStateCacheDisableDepthTest ();
916
918
glStateCacheBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
917
919
glStateCacheEnableBlend ();
@@ -930,15 +932,17 @@ static void drawBackground(const float width, const float height, const float x,
930
932
931
933
// An animation while we're waiting.
932
934
// Designed to be drawn on background of at least 3xsquareSize wide and tall.
933
- 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 ] )
934
936
{
935
- #if !HAVE_GLES2
936
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 } };
937
938
int i;
938
939
939
940
int hundredthSeconds = (int )tp->tv_usec / 1E4 ;
941
+ int secDiv255 = (int )tp->tv_usec / 3921 ;
942
+ int secMod6 = tp->tv_sec % 6 ;
940
943
941
944
// Set up drawing.
945
+ #if !HAVE_GLES2
942
946
glPushMatrix ();
943
947
glLoadIdentity ();
944
948
glDisable (GL_DEPTH_TEST);
@@ -950,14 +954,28 @@ static void drawBusyIndicator(int positionX, int positionY, int squareSize, stru
950
954
glDisableClientState (GL_NORMAL_ARRAY);
951
955
glClientActiveTexture (GL_TEXTURE0);
952
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
953
964
954
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
955
969
glLoadIdentity ();
956
- 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
957
977
if (i == hundredthSeconds / 25 ) {
958
978
unsigned char r, g, b;
959
- int secDiv255 = (int )tp->tv_usec / 3921 ;
960
- int secMod6 = tp->tv_sec % 6 ;
961
979
if (secMod6 == 0 ) {
962
980
r = 255 ; g = secDiv255; b = 0 ;
963
981
} else if (secMod6 == 1 ) {
@@ -971,13 +989,24 @@ static void drawBusyIndicator(int positionX, int positionY, int squareSize, stru
971
989
} else {
972
990
r = 255 ; g = 0 ; b = secDiv255;
973
991
}
992
+ #if !HAVE_GLES2
974
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
975
998
glDrawArrays (GL_TRIANGLE_FAN, 0 , 4 );
976
999
}
1000
+ #if !HAVE_GLES2
977
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
978
1006
glDrawArrays (GL_LINE_LOOP, 0 , 4 );
979
1007
}
980
1008
1009
+ #if !HAVE_GLES2
981
1010
glPopMatrix ();
982
1011
#endif // !HAVE_GLES2
983
1012
}
@@ -1136,20 +1165,26 @@ void drawView(void)
1136
1165
//
1137
1166
// Setup for drawing on top of video frame, in viewPort coordinates.
1138
1167
//
1139
- #if 0
1140
- glMatrixMode(GL_PROJECTION);
1141
- glLoadIdentity();
1168
+ #if 0 // NOT USED
1142
1169
bottom = 0.0f;
1143
1170
top = (float)(viewPort[viewPortIndexHeight]);
1144
1171
left = 0.0f;
1145
1172
right = (float)(viewPort[viewPortIndexWidth]);
1173
+ # if !HAVE_GLES2
1174
+ glMatrixMode(GL_PROJECTION);
1175
+ glLoadIdentity();
1146
1176
glOrthof(left, right, bottom, top, -1.0f, 1.0f);
1147
1177
glMatrixMode(GL_MODELVIEW);
1148
1178
glLoadIdentity();
1149
-
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
1150
1185
EdenGLFontSetViewSize(right, top);
1151
1186
EdenMessageSetViewSize(right, top, gDisplayDPI);
1152
- #endif
1187
+ #endif // 0
1153
1188
1154
1189
//
1155
1190
// Setup for drawing on screen, with correct orientation for user.
@@ -1161,12 +1196,11 @@ void drawView(void)
1161
1196
right = (float )contextWidth;
1162
1197
mtxLoadIdentityf (p);
1163
1198
mtxOrthof (p, left, right, bottom, top, -1 .0f , 1 .0f );
1164
- mtxLoadIdentityf (m);
1165
1199
#if !HAVE_GLES2
1166
1200
glMatrixMode (GL_PROJECTION);
1167
1201
glLoadMatrixf (p);
1168
1202
glMatrixMode (GL_MODELVIEW);
1169
- glLoadMatrixf (m );
1203
+ glLoadIdentity ( );
1170
1204
#else
1171
1205
glUseProgram (program);
1172
1206
glUniformMatrix4fv (uniforms[UNIFORM_MODELVIEW_PROJECTION_MATRIX], 1 , GL_FALSE, p);
@@ -1179,7 +1213,7 @@ void drawView(void)
1179
1213
1180
1214
// Draw status bar with centred status message.
1181
1215
if (statusBarMessage[0 ]) {
1182
- drawBackground (right, statusBarHeight, 0 .0f , 0 .0f , false );
1216
+ drawBackground (right, statusBarHeight, 0 .0f , 0 .0f , false , p );
1183
1217
glDisable (GL_BLEND);
1184
1218
EdenGLFontDrawLine (0 , p, statusBarMessage, 0 .0f , 2 .0f , H_OFFSET_VIEW_CENTER_TO_TEXT_CENTER, V_OFFSET_VIEW_BOTTOM_TO_TEXT_BASELINE);
1185
1219
}
@@ -1196,8 +1230,8 @@ void drawView(void)
1196
1230
h = MAX (FONT_SIZE, 3 *squareSize) + 2 *4 .0f /* box margin */ ;
1197
1231
x = right - (w + 2 .0f );
1198
1232
y = statusBarHeight + 2 .0f ;
1199
- drawBackground (w, h, x, y, true );
1200
- 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 );
1201
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);
1202
1236
}
1203
1237
}
0 commit comments