Mercurial > sdl-ios-xcode
comparison src/video/SDL_renderer_gl.c @ 2845:1cc5d5b164e2
Added official support for GL_APPLE_ycbcr_422 and GL_MESA_ycbcr_texture
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 07 Dec 2008 04:02:23 +0000 |
parents | 70b63882d2ef |
children | 3d7833d5a4be |
comparison
equal
deleted
inserted
replaced
2844:70b63882d2ef | 2845:1cc5d5b164e2 |
---|---|
144 { | 144 { |
145 SDL_GLContext context; | 145 SDL_GLContext context; |
146 SDL_bool updateSize; | 146 SDL_bool updateSize; |
147 SDL_bool GL_ARB_texture_rectangle_supported; | 147 SDL_bool GL_ARB_texture_rectangle_supported; |
148 SDL_bool GL_EXT_paletted_texture_supported; | 148 SDL_bool GL_EXT_paletted_texture_supported; |
149 SDL_bool GL_APPLE_ycbcr_422_supported; | |
150 SDL_bool GL_MESA_ycbcr_texture_supported; | |
149 SDL_bool GL_ARB_fragment_program_supported; | 151 SDL_bool GL_ARB_fragment_program_supported; |
150 int blendMode; | 152 int blendMode; |
151 int scaleMode; | 153 int scaleMode; |
152 | 154 |
153 /* OpenGL functions */ | 155 /* OpenGL functions */ |
376 info->texture_formats[j++] = info->texture_formats[i]; | 378 info->texture_formats[j++] = info->texture_formats[i]; |
377 } | 379 } |
378 } | 380 } |
379 --info->num_texture_formats; | 381 --info->num_texture_formats; |
380 } | 382 } |
383 if (SDL_GL_ExtensionSupported("GL_APPLE_ycbcr_422")) { | |
384 data->GL_APPLE_ycbcr_422_supported = SDL_TRUE; | |
385 } | |
386 if (SDL_GL_ExtensionSupported("GL_MESA_ycbcr_texture")) { | |
387 data->GL_MESA_ycbcr_texture_supported = SDL_TRUE; | |
388 } | |
381 if (SDL_GL_ExtensionSupported("GL_APPLE_texture_range")) { | 389 if (SDL_GL_ExtensionSupported("GL_APPLE_texture_range")) { |
382 data->glTextureRangeAPPLE = | 390 data->glTextureRangeAPPLE = |
383 (void (*)(GLenum, GLsizei, const GLvoid *)) | 391 (void (*)(GLenum, GLsizei, const GLvoid *)) |
384 SDL_GL_GetProcAddress("glTextureRangeAPPLE"); | 392 SDL_GL_GetProcAddress("glTextureRangeAPPLE"); |
385 } | 393 } |
481 data->glBindProgramARB(shader_type, program); | 489 data->glBindProgramARB(shader_type, program); |
482 data->glProgramStringARB(shader_type, GL_PROGRAM_FORMAT_ASCII_ARB, | 490 data->glProgramStringARB(shader_type, GL_PROGRAM_FORMAT_ASCII_ARB, |
483 SDL_strlen(source), source); | 491 SDL_strlen(source), source); |
484 | 492 |
485 if (data->glGetError() == GL_INVALID_OPERATION) | 493 if (data->glGetError() == GL_INVALID_OPERATION) |
486 { | 494 { |
487 #if DEBUG_PROGRAM_COMPILE | 495 #if DEBUG_PROGRAM_COMPILE |
488 GLint pos = 0; | 496 GLint pos = 0; |
489 const GLubyte *errstr; | 497 const GLubyte *errstr; |
490 data->glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos); | 498 data->glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos); |
491 errstr = data->glGetString(GL_PROGRAM_ERROR_STRING_ARB); | 499 errstr = data->glGetString(GL_PROGRAM_ERROR_STRING_ARB); |
658 case SDL_PIXELFORMAT_ARGB2101010: | 666 case SDL_PIXELFORMAT_ARGB2101010: |
659 internalFormat = GL_RGB10_A2; | 667 internalFormat = GL_RGB10_A2; |
660 format = GL_BGRA; | 668 format = GL_BGRA; |
661 type = GL_UNSIGNED_INT_2_10_10_10_REV; | 669 type = GL_UNSIGNED_INT_2_10_10_10_REV; |
662 break; | 670 break; |
663 #if 0 /* Ryan's pixel shader code should be better, once it works. :) */ | 671 case SDL_PIXELFORMAT_UYVY: |
664 case SDL_PIXELFORMAT_UYVY: | 672 if (renderdata->GL_APPLE_ycbcr_422_supported) { |
665 // if (renderdata->GL_MESA_ycbcr_texture) { | 673 internalFormat = GL_RGB; |
666 // internalFormat = 3; | 674 format = GL_YCBCR_422_APPLE; |
667 // format = GL_YCBCR_MESA; | 675 #if SDL_BYTEORDER == SDL_LIL_ENDIAN |
668 // type = GL_UNSIGNED_SHORT_8_8_MESA; | 676 type = GL_UNSIGNED_SHORT_8_8_APPLE; |
669 // } else if (renderdata->GL_APPLE_ycbcr_422) { | |
670 internalFormat = GL_RGB; | |
671 format = GL_YCBCR_422_APPLE; | |
672 #if SDL_BYTEORDER == SDL_LIL_ENDIAN | |
673 type = GL_UNSIGNED_SHORT_8_8_APPLE; | |
674 #else | |
675 type = GL_UNSIGNED_SHORT_8_8_REV_APPLE; | |
676 #endif | |
677 // } else { | |
678 // SDL_SetError("Unsupported texture format"); | |
679 // return -1; | |
680 // } | |
681 break; | |
682 #else | 677 #else |
683 case SDL_PIXELFORMAT_UYVY: | 678 type = GL_UNSIGNED_SHORT_8_8_REV_APPLE; |
684 if (renderdata->GL_ARB_fragment_program_supported) { | 679 #endif |
680 } else if (renderdata->GL_MESA_ycbcr_texture_supported) { | |
681 internalFormat = GL_RGB; | |
682 format = GL_YCBCR_MESA; | |
683 #if SDL_BYTEORDER == SDL_LIL_ENDIAN | |
684 type = GL_UNSIGNED_SHORT_8_8_MESA; | |
685 #else | |
686 type = GL_UNSIGNED_SHORT_8_8_REV_MESA; | |
687 #endif | |
688 } else if (renderdata->GL_ARB_fragment_program_supported) { | |
685 if (renderdata->fragment_program_UYVY == 0) { | 689 if (renderdata->fragment_program_UYVY == 0) { |
686 renderdata->fragment_program_UYVY = | 690 renderdata->fragment_program_UYVY = |
687 compile_shader(renderdata, GL_FRAGMENT_PROGRAM_ARB, | 691 compile_shader(renderdata, GL_FRAGMENT_PROGRAM_ARB, |
688 fragment_program_UYVY_source_code); | 692 fragment_program_UYVY_source_code); |
689 if (renderdata->fragment_program_UYVY == 0) { | 693 if (renderdata->fragment_program_UYVY == 0) { |
698 } else { | 702 } else { |
699 SDL_SetError("Unsupported texture format"); | 703 SDL_SetError("Unsupported texture format"); |
700 return -1; | 704 return -1; |
701 } | 705 } |
702 break; | 706 break; |
703 #endif | 707 case SDL_PIXELFORMAT_YUY2: |
708 if (renderdata->GL_APPLE_ycbcr_422_supported) { | |
709 internalFormat = GL_RGB; | |
710 format = GL_YCBCR_422_APPLE; | |
711 #if SDL_BYTEORDER == SDL_LIL_ENDIAN | |
712 type = GL_UNSIGNED_SHORT_8_8_REV_APPLE; | |
713 #else | |
714 type = GL_UNSIGNED_SHORT_8_8_APPLE; | |
715 #endif | |
716 } else if (renderdata->GL_MESA_ycbcr_texture_supported) { | |
717 internalFormat = GL_RGB; | |
718 format = GL_YCBCR_MESA; | |
719 #if SDL_BYTEORDER == SDL_LIL_ENDIAN | |
720 type = GL_UNSIGNED_SHORT_8_8_REV_MESA; | |
721 #else | |
722 type = GL_UNSIGNED_SHORT_8_8_MESA; | |
723 #endif | |
724 } else { | |
725 SDL_SetError("Unsupported texture format"); | |
726 return -1; | |
727 } | |
728 break; | |
704 default: | 729 default: |
705 SDL_SetError("Unsupported texture format"); | 730 SDL_SetError("Unsupported texture format"); |
706 return -1; | 731 return -1; |
707 } | 732 } |
708 | 733 |