Mercurial > sdl-ios-xcode
comparison src/video/SDL_video.c @ 2810:27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 30 Nov 2008 21:58:23 +0000 |
parents | 985001797115 |
children | e841aa93e6be |
comparison
equal
deleted
inserted
replaced
2809:7e257c3a3bf0 | 2810:27cb878a278e |
---|---|
1474 if (!_this) { | 1474 if (!_this) { |
1475 SDL_UninitializedVideo(); | 1475 SDL_UninitializedVideo(); |
1476 return 0; | 1476 return 0; |
1477 } | 1477 } |
1478 renderer = SDL_CurrentDisplay.current_renderer; | 1478 renderer = SDL_CurrentDisplay.current_renderer; |
1479 if (!renderer || !renderer->CreateTexture) { | 1479 if (!renderer) { |
1480 return 0; | |
1481 } | |
1482 if (!renderer->CreateTexture) { | |
1483 SDL_Unsupported(); | |
1480 return 0; | 1484 return 0; |
1481 } | 1485 } |
1482 texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture)); | 1486 texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture)); |
1483 if (!texture) { | 1487 if (!texture) { |
1484 SDL_OutOfMemory(); | 1488 SDL_OutOfMemory(); |
1667 if (!texture) { | 1671 if (!texture) { |
1668 return -1; | 1672 return -1; |
1669 } | 1673 } |
1670 renderer = texture->renderer; | 1674 renderer = texture->renderer; |
1671 if (!renderer->QueryTexturePixels) { | 1675 if (!renderer->QueryTexturePixels) { |
1676 SDL_Unsupported(); | |
1672 return -1; | 1677 return -1; |
1673 } | 1678 } |
1674 return renderer->QueryTexturePixels(renderer, texture, pixels, pitch); | 1679 return renderer->QueryTexturePixels(renderer, texture, pixels, pitch); |
1675 } | 1680 } |
1676 | 1681 |
1684 if (!texture) { | 1689 if (!texture) { |
1685 return -1; | 1690 return -1; |
1686 } | 1691 } |
1687 renderer = texture->renderer; | 1692 renderer = texture->renderer; |
1688 if (!renderer->SetTexturePalette) { | 1693 if (!renderer->SetTexturePalette) { |
1694 SDL_Unsupported(); | |
1689 return -1; | 1695 return -1; |
1690 } | 1696 } |
1691 return renderer->SetTexturePalette(renderer, texture, colors, firstcolor, | 1697 return renderer->SetTexturePalette(renderer, texture, colors, firstcolor, |
1692 ncolors); | 1698 ncolors); |
1693 } | 1699 } |
1702 if (!texture) { | 1708 if (!texture) { |
1703 return -1; | 1709 return -1; |
1704 } | 1710 } |
1705 renderer = texture->renderer; | 1711 renderer = texture->renderer; |
1706 if (!renderer->GetTexturePalette) { | 1712 if (!renderer->GetTexturePalette) { |
1713 SDL_Unsupported(); | |
1707 return -1; | 1714 return -1; |
1708 } | 1715 } |
1709 return renderer->GetTexturePalette(renderer, texture, colors, firstcolor, | 1716 return renderer->GetTexturePalette(renderer, texture, colors, firstcolor, |
1710 ncolors); | 1717 ncolors); |
1711 } | 1718 } |
1719 if (!texture) { | 1726 if (!texture) { |
1720 return -1; | 1727 return -1; |
1721 } | 1728 } |
1722 renderer = texture->renderer; | 1729 renderer = texture->renderer; |
1723 if (!renderer->SetTextureColorMod) { | 1730 if (!renderer->SetTextureColorMod) { |
1731 SDL_Unsupported(); | |
1724 return -1; | 1732 return -1; |
1725 } | 1733 } |
1726 if (r < 255 || g < 255 || b < 255) { | 1734 if (r < 255 || g < 255 || b < 255) { |
1727 texture->modMode |= SDL_TEXTUREMODULATE_COLOR; | 1735 texture->modMode |= SDL_TEXTUREMODULATE_COLOR; |
1728 } else { | 1736 } else { |
1766 if (!texture) { | 1774 if (!texture) { |
1767 return -1; | 1775 return -1; |
1768 } | 1776 } |
1769 renderer = texture->renderer; | 1777 renderer = texture->renderer; |
1770 if (!renderer->SetTextureAlphaMod) { | 1778 if (!renderer->SetTextureAlphaMod) { |
1779 SDL_Unsupported(); | |
1771 return -1; | 1780 return -1; |
1772 } | 1781 } |
1773 if (alpha < 255) { | 1782 if (alpha < 255) { |
1774 texture->modMode |= SDL_TEXTUREMODULATE_ALPHA; | 1783 texture->modMode |= SDL_TEXTUREMODULATE_ALPHA; |
1775 } else { | 1784 } else { |
1802 if (!texture) { | 1811 if (!texture) { |
1803 return -1; | 1812 return -1; |
1804 } | 1813 } |
1805 renderer = texture->renderer; | 1814 renderer = texture->renderer; |
1806 if (!renderer->SetTextureBlendMode) { | 1815 if (!renderer->SetTextureBlendMode) { |
1816 SDL_Unsupported(); | |
1807 return -1; | 1817 return -1; |
1808 } | 1818 } |
1809 texture->blendMode = blendMode; | 1819 texture->blendMode = blendMode; |
1810 return renderer->SetTextureBlendMode(renderer, texture); | 1820 return renderer->SetTextureBlendMode(renderer, texture); |
1811 } | 1821 } |
1833 if (!texture) { | 1843 if (!texture) { |
1834 return -1; | 1844 return -1; |
1835 } | 1845 } |
1836 renderer = texture->renderer; | 1846 renderer = texture->renderer; |
1837 if (!renderer->SetTextureScaleMode) { | 1847 if (!renderer->SetTextureScaleMode) { |
1848 SDL_Unsupported(); | |
1838 return -1; | 1849 return -1; |
1839 } | 1850 } |
1840 texture->scaleMode = scaleMode; | 1851 texture->scaleMode = scaleMode; |
1841 return renderer->SetTextureScaleMode(renderer, texture); | 1852 return renderer->SetTextureScaleMode(renderer, texture); |
1842 } | 1853 } |
1866 if (!texture) { | 1877 if (!texture) { |
1867 return -1; | 1878 return -1; |
1868 } | 1879 } |
1869 renderer = texture->renderer; | 1880 renderer = texture->renderer; |
1870 if (!renderer->UpdateTexture) { | 1881 if (!renderer->UpdateTexture) { |
1882 SDL_Unsupported(); | |
1871 return -1; | 1883 return -1; |
1872 } | 1884 } |
1873 if (!rect) { | 1885 if (!rect) { |
1874 full_rect.x = 0; | 1886 full_rect.x = 0; |
1875 full_rect.y = 0; | 1887 full_rect.y = 0; |
1895 SDL_SetError("SDL_LockTexture(): texture must be streaming"); | 1907 SDL_SetError("SDL_LockTexture(): texture must be streaming"); |
1896 return -1; | 1908 return -1; |
1897 } | 1909 } |
1898 renderer = texture->renderer; | 1910 renderer = texture->renderer; |
1899 if (!renderer->LockTexture) { | 1911 if (!renderer->LockTexture) { |
1912 SDL_Unsupported(); | |
1900 return -1; | 1913 return -1; |
1901 } | 1914 } |
1902 if (!rect) { | 1915 if (!rect) { |
1903 full_rect.x = 0; | 1916 full_rect.x = 0; |
1904 full_rect.y = 0; | 1917 full_rect.y = 0; |
1959 if (!_this) { | 1972 if (!_this) { |
1960 SDL_UninitializedVideo(); | 1973 SDL_UninitializedVideo(); |
1961 return -1; | 1974 return -1; |
1962 } | 1975 } |
1963 renderer = SDL_CurrentDisplay.current_renderer; | 1976 renderer = SDL_CurrentDisplay.current_renderer; |
1964 if (!renderer || !renderer->RenderFill) { | 1977 if (!renderer) { |
1978 return -1; | |
1979 } | |
1980 if(!renderer->RenderFill) { | |
1981 SDL_Unsupported(); | |
1965 return -1; | 1982 return -1; |
1966 } | 1983 } |
1967 window = SDL_GetWindowFromID(renderer->window); | 1984 window = SDL_GetWindowFromID(renderer->window); |
1968 real_rect.x = 0; | 1985 real_rect.x = 0; |
1969 real_rect.y = 0; | 1986 real_rect.y = 0; |
1989 | 2006 |
1990 if (!texture || texture->renderer != SDL_CurrentDisplay.current_renderer) { | 2007 if (!texture || texture->renderer != SDL_CurrentDisplay.current_renderer) { |
1991 return -1; | 2008 return -1; |
1992 } | 2009 } |
1993 renderer = SDL_CurrentDisplay.current_renderer; | 2010 renderer = SDL_CurrentDisplay.current_renderer; |
1994 if (!renderer || !renderer->RenderCopy) { | 2011 if (!renderer) { |
2012 return -1; | |
2013 } | |
2014 if (!renderer->RenderCopy) { | |
2015 SDL_Unsupported(); | |
1995 return -1; | 2016 return -1; |
1996 } | 2017 } |
1997 window = SDL_GetWindowFromID(renderer->window); | 2018 window = SDL_GetWindowFromID(renderer->window); |
1998 if (srcrect) { | 2019 if (srcrect) { |
1999 real_srcrect = *srcrect; | 2020 real_srcrect = *srcrect; |