- if (angle == 0.0f)
- { // unrotated blit
- glBlendFunc(blend.sfactor, blend.dfactor);
- glColor4f(color.red, color.green, color.blue, color.alpha * alpha);
- glBegin(GL_QUADS);
- glTexCoord2f(uv_left, uv_top);
- glVertex2f(left, top);
-
- glTexCoord2f(uv_right, uv_top);
- glVertex2f(right, top);
-
- glTexCoord2f(uv_right, uv_bottom);
- glVertex2f(right, bottom);
-
- glTexCoord2f(uv_left, uv_bottom);
- glVertex2f(left, bottom);
- glEnd();
- }
- else
- { // rotated blit
- float center_x = (left + right) / 2;
- float center_y = (top + bottom) / 2;
-
- float sa = sinf(angle/180.0f*M_PI);
- float ca = cosf(angle/180.0f*M_PI);
-
- left -= center_x;
- right -= center_x;
-
- top -= center_y;
- bottom -= center_y;
-
- glBlendFunc(blend.sfactor, blend.dfactor);
- glColor4f(color.red, color.green, color.blue, color.alpha * alpha);
- glBegin(GL_QUADS);
- glTexCoord2f(uv_left, uv_top);
- glVertex2f(left*ca - top*sa + center_x,
- left*sa + top*ca + center_y);
-
- glTexCoord2f(uv_right, uv_top);
- glVertex2f(right*ca - top*sa + center_x,
- right*sa + top*ca + center_y);
-
- glTexCoord2f(uv_right, uv_bottom);
- glVertex2f(right*ca - bottom*sa + center_x,
- right*sa + bottom*ca + center_y);
-
- glTexCoord2f(uv_left, uv_bottom);
- glVertex2f(left*ca - bottom*sa + center_x,
- left*sa + bottom*ca + center_y);
- glEnd();
- }
+ if (angle == 0.0f) {
+ float vertices[] = {
+ left, top,
+ right, top,
+ right, bottom,
+ left, bottom,
+ };
+ glVertexPointer(2, GL_FLOAT, 0, vertices);
+
+ float uvs[] = {
+ uv_left, uv_top,
+ uv_right, uv_top,
+ uv_right, uv_bottom,
+ uv_left, uv_bottom,
+ };
+ glTexCoordPointer(2, GL_FLOAT, 0, uvs);
+
+ glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ } else {
+ // rotated blit
+ float center_x = (left + right) / 2;
+ float center_y = (top + bottom) / 2;
+
+ float sa = sinf(angle/180.0f*M_PI);
+ float ca = cosf(angle/180.0f*M_PI);
+
+ left -= center_x;
+ right -= center_x;
+
+ top -= center_y;
+ bottom -= center_y;
+
+ float vertices[] = {
+ left*ca - top*sa + center_x, left*sa + top*ca + center_y,
+ right*ca - top*sa + center_x, right*sa + top*ca + center_y,
+ right*ca - bottom*sa + center_x, right*sa + bottom*ca + center_y,
+ left*ca - bottom*sa + center_x, left*sa + bottom*ca + center_y
+ };
+ glVertexPointer(2, GL_FLOAT, 0, vertices);
+
+ float uvs[] = {
+ uv_left, uv_top,
+ uv_right, uv_top,
+ uv_right, uv_bottom,
+ uv_left, uv_bottom,
+ };
+ glTexCoordPointer(2, GL_FLOAT, 0, uvs);
+
+ glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ }