comparison src/video/SDL_renderer_gl.c @ 2237:e57a883ffa86

Advertise the most efficient format for the screen. Of course SDL code needs to be fixed to handle framebuffers with alpha...
author Sam Lantinga <slouken@libsdl.org>
date Mon, 13 Aug 2007 02:38:59 +0000
parents 741afd8402cf
children 75daa0792bd1
comparison
equal deleted inserted replaced
2236:741afd8402cf 2237:e57a883ffa86
455 internalFormat = GL_RGB8; 455 internalFormat = GL_RGB8;
456 format = GL_RGB; 456 format = GL_RGB;
457 type = GL_UNSIGNED_BYTE; 457 type = GL_UNSIGNED_BYTE;
458 break; 458 break;
459 case SDL_PIXELFORMAT_RGB888: 459 case SDL_PIXELFORMAT_RGB888:
460 #ifdef __MACOSX__
461 internalFormat = GL_RGBA;
462 format = GL_BGRA;
463 type = GL_UNSIGNED_INT_8_8_8_8_REV;
464 #else
465 internalFormat = GL_RGB8; 460 internalFormat = GL_RGB8;
466 format = GL_BGRA; 461 format = GL_BGRA;
467 type = GL_UNSIGNED_BYTE; 462 type = GL_UNSIGNED_BYTE;
468 #endif
469 break; 463 break;
470 case SDL_PIXELFORMAT_BGR24: 464 case SDL_PIXELFORMAT_BGR24:
471 internalFormat = GL_RGB8; 465 internalFormat = GL_RGB8;
472 format = GL_BGR; 466 format = GL_BGR;
473 type = GL_UNSIGNED_BYTE; 467 type = GL_UNSIGNED_BYTE;
572 GL_STORAGE_SHARED_APPLE); 566 GL_STORAGE_SHARED_APPLE);
573 } else { 567 } else {
574 renderdata->glTexParameteri(data->type, GL_TEXTURE_STORAGE_HINT_APPLE, 568 renderdata->glTexParameteri(data->type, GL_TEXTURE_STORAGE_HINT_APPLE,
575 GL_STORAGE_CACHED_APPLE); 569 GL_STORAGE_CACHED_APPLE);
576 } 570 }
577 if (data->pixels && internalFormat == GL_RGBA && format == GL_BGRA 571 if (texture->access == SDL_TEXTUREACCESS_STREAMING && texture->format == SDL_PIXELFORMAT_ARGB8888 ) {
578 && type == GL_UNSIGNED_INT_8_8_8_8_REV && data->pixels) { 572 /*
579 if (renderdata->glTextureRangeAPPLE) { 573 if (renderdata->glTextureRangeAPPLE) {
580 renderdata->glTextureRangeAPPLE(data->type, 574 renderdata->glTextureRangeAPPLE(data->type,
581 texture->h * data->pitch, 575 texture->h * data->pitch,
582 data->pixels); 576 data->pixels);
583 } 577 }
578 */
584 renderdata->glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE); 579 renderdata->glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
585 renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w, 580 renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w,
586 texture_h, 0, format, type, data->pixels); 581 texture_h, 0, format, type, data->pixels);
587 } else 582 } else
588 #endif 583 #endif
804 SDL_DirtyRect *dirty; 799 SDL_DirtyRect *dirty;
805 void *pixels; 800 void *pixels;
806 int bpp = SDL_BYTESPERPIXEL(texture->format); 801 int bpp = SDL_BYTESPERPIXEL(texture->format);
807 int pitch = texturedata->pitch; 802 int pitch = texturedata->pitch;
808 803
809 #ifdef __MACOSX__
810 if (texture->format == SDL_PIXELFORMAT_RGB888) {
811 int i;
812 Uint8 *p = (Uint8 *) texturedata->pixels;
813 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
814 p += 3;
815 #endif
816 for (i = texture->h * pitch / 4; i--;) {
817 *p = 0xff;
818 p += 4;
819 }
820 }
821 #endif
822 SetupTextureUpdate(data, texture, pitch); 804 SetupTextureUpdate(data, texture, pitch);
823 data->glBindTexture(texturedata->type, texturedata->texture); 805 data->glBindTexture(texturedata->type, texturedata->texture);
824 for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) { 806 for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) {
825 SDL_Rect *rect = &dirty->rect; 807 SDL_Rect *rect = &dirty->rect;
826 pixels = 808 pixels =