comparison libvo/gl_common.c @ 17220:a27e52b838e3

support negative stride (flipping) in vo_gl.
author reimar
date Sun, 18 Dec 2005 12:04:08 +0000
parents 724353364790
children 3e49b98ad314
comparison
equal deleted inserted replaced
17219:fde45c312c31 17220:a27e52b838e3
491 int x, int y, int w, int h, int slice) { 491 int x, int y, int w, int h, int slice) {
492 int y_max = y + h; 492 int y_max = y + h;
493 if (w <= 0 || h <= 0) return; 493 if (w <= 0 || h <= 0) return;
494 if (slice <= 0) 494 if (slice <= 0)
495 slice = h; 495 slice = h;
496 if (stride < 0) {
497 data += h * stride;
498 stride = -stride;
499 }
496 // this is not always correct, but should work for MPlayer 500 // this is not always correct, but should work for MPlayer
497 glAdjustAlignment(stride); 501 glAdjustAlignment(stride);
498 glPixelStorei(GL_UNPACK_ROW_LENGTH, stride / glFmt2bpp(format, type)); 502 glPixelStorei(GL_UNPACK_ROW_LENGTH, stride / glFmt2bpp(format, type));
499 for (; y + slice <= y_max; y += slice) { 503 for (; y + slice <= y_max; y += slice) {
500 glTexSubImage2D(target, 0, x, y, w, slice, format, type, data); 504 glTexSubImage2D(target, 0, x, y, w, slice, format, type, data);
908 * \param th texture part height in pixels 912 * \param th texture part height in pixels
909 * \param sx width of texture in pixels 913 * \param sx width of texture in pixels
910 * \param sy height of texture in pixels 914 * \param sy height of texture in pixels
911 * \param rect_tex whether this texture uses texture_rectangle extension 915 * \param rect_tex whether this texture uses texture_rectangle extension
912 * \param is_yv12 if set, also draw the textures from units 1 and 2 916 * \param is_yv12 if set, also draw the textures from units 1 and 2
917 * \param flip flip the texture upside down
913 * \ingroup gltexture 918 * \ingroup gltexture
914 */ 919 */
915 void glDrawTex(GLfloat x, GLfloat y, GLfloat w, GLfloat h, 920 void glDrawTex(GLfloat x, GLfloat y, GLfloat w, GLfloat h,
916 GLfloat tx, GLfloat ty, GLfloat tw, GLfloat th, 921 GLfloat tx, GLfloat ty, GLfloat tw, GLfloat th,
917 int sx, int sy, int rect_tex, int is_yv12) { 922 int sx, int sy, int rect_tex, int is_yv12, int flip) {
918 GLfloat tx2 = tx / 2, ty2 = ty / 2, tw2 = tw / 2, th2 = th / 2; 923 GLfloat tx2 = tx / 2, ty2 = ty / 2, tw2 = tw / 2, th2 = th / 2;
919 if (!rect_tex) { 924 if (!rect_tex) {
920 tx /= sx; ty /= sy; tw /= sx; th /= sy; 925 tx /= sx; ty /= sy; tw /= sx; th /= sy;
921 tx2 = tx, ty2 = ty, tw2 = tw, th2 = th; 926 tx2 = tx, ty2 = ty, tw2 = tw, th2 = th;
927 }
928 if (flip) {
929 y += h;
930 h = -h;
922 } 931 }
923 glBegin(GL_QUADS); 932 glBegin(GL_QUADS);
924 glTexCoord2f(tx, ty); 933 glTexCoord2f(tx, ty);
925 if (is_yv12) { 934 if (is_yv12) {
926 MultiTexCoord2f(GL_TEXTURE1, tx2, ty2); 935 MultiTexCoord2f(GL_TEXTURE1, tx2, ty2);