Mercurial > sdl-ios-xcode
comparison src/video/SDL_video.c @ 1907:06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 15 Jul 2006 09:46:36 +0000 |
parents | 36d52b1f0504 |
children | 8f1ab2f7c722 |
comparison
equal
deleted
inserted
replaced
1906:0c49855a7a3e | 1907:06c27a737b7a |
---|---|
1275 } | 1275 } |
1276 | 1276 |
1277 int | 1277 int |
1278 SDL_GetRendererInfo(int index, SDL_RendererInfo * info) | 1278 SDL_GetRendererInfo(int index, SDL_RendererInfo * info) |
1279 { | 1279 { |
1280 if (index < 0 || index >= SDL_GetNumRenderers()) { | 1280 if (!_this) { |
1281 return -1; | |
1282 } | |
1283 | |
1284 if (index >= SDL_GetNumRenderers()) { | |
1281 SDL_SetError("index must be in the range of 0 - %d", | 1285 SDL_SetError("index must be in the range of 0 - %d", |
1282 SDL_GetNumRenderers() - 1); | 1286 SDL_GetNumRenderers() - 1); |
1283 return -1; | 1287 return -1; |
1284 } | 1288 } |
1285 *info = SDL_CurrentDisplay.render_drivers[index].info; | 1289 if (index < 0) { |
1290 if (!SDL_CurrentDisplay.current_renderer) { | |
1291 SDL_SetError("There is no current renderer"); | |
1292 return -1; | |
1293 } | |
1294 *info = SDL_CurrentDisplay.current_renderer->info; | |
1295 } else { | |
1296 *info = SDL_CurrentDisplay.render_drivers[index].info; | |
1297 } | |
1286 return 0; | 1298 return 0; |
1287 } | 1299 } |
1288 | 1300 |
1289 int | 1301 int |
1290 SDL_CreateRenderer(SDL_WindowID windowID, int index, Uint32 flags) | 1302 SDL_CreateRenderer(SDL_WindowID windowID, int index, Uint32 flags) |
1305 if (override) { | 1317 if (override) { |
1306 if (SDL_strcasecmp(override, driver->info.name) == 0) { | 1318 if (SDL_strcasecmp(override, driver->info.name) == 0) { |
1307 break; | 1319 break; |
1308 } | 1320 } |
1309 } else { | 1321 } else { |
1310 /* Skip minimal drivers in automatic scans */ | |
1311 if (!(flags & SDL_Renderer_Minimal) | |
1312 && (driver->info.flags & SDL_Renderer_Minimal)) { | |
1313 continue; | |
1314 } | |
1315 if ((driver->info.flags & flags) == flags) { | 1322 if ((driver->info.flags & flags) == flags) { |
1316 break; | 1323 break; |
1317 } | 1324 } |
1318 } | 1325 } |
1319 } | 1326 } |
1732 return; | 1739 return; |
1733 } | 1740 } |
1734 renderer->DirtyTexture(renderer, texture, numrects, rects); | 1741 renderer->DirtyTexture(renderer, texture, numrects, rects); |
1735 } | 1742 } |
1736 | 1743 |
1737 void | |
1738 SDL_SelectRenderTexture(SDL_TextureID textureID) | |
1739 { | |
1740 SDL_Texture *texture = SDL_GetTextureFromID(textureID); | |
1741 SDL_Renderer *renderer; | |
1742 | |
1743 if (!texture || texture->access != SDL_TextureAccess_Render) { | |
1744 return; | |
1745 } | |
1746 renderer = texture->renderer; | |
1747 if (!renderer->SelectRenderTexture) { | |
1748 return; | |
1749 } | |
1750 renderer->SelectRenderTexture(renderer, texture); | |
1751 } | |
1752 | |
1753 int | 1744 int |
1754 SDL_RenderFill(const SDL_Rect * rect, Uint32 color) | 1745 SDL_RenderFill(const SDL_Rect * rect, Uint32 color) |
1755 { | 1746 { |
1756 SDL_Renderer *renderer; | 1747 SDL_Renderer *renderer; |
1757 SDL_Window *window; | 1748 SDL_Window *window; |
1819 | 1810 |
1820 return renderer->RenderCopy(renderer, texture, &real_srcrect, | 1811 return renderer->RenderCopy(renderer, texture, &real_srcrect, |
1821 &real_dstrect, blendMode, scaleMode); | 1812 &real_dstrect, blendMode, scaleMode); |
1822 } | 1813 } |
1823 | 1814 |
1824 int | |
1825 SDL_RenderReadPixels(const SDL_Rect * rect, void *pixels, int pitch) | |
1826 { | |
1827 SDL_Renderer *renderer; | |
1828 SDL_Rect full_rect; | |
1829 | |
1830 if (!_this) { | |
1831 return -1; | |
1832 } | |
1833 | |
1834 renderer = SDL_CurrentDisplay.current_renderer; | |
1835 if (!renderer || !renderer->RenderReadPixels) { | |
1836 return -1; | |
1837 } | |
1838 | |
1839 if (!rect) { | |
1840 SDL_Window *window = SDL_GetWindowFromID(renderer->window); | |
1841 full_rect.x = 0; | |
1842 full_rect.y = 0; | |
1843 full_rect.w = window->w; | |
1844 full_rect.h = window->h; | |
1845 rect = &full_rect; | |
1846 } | |
1847 | |
1848 return renderer->RenderReadPixels(renderer, rect, pixels, pitch); | |
1849 } | |
1850 | |
1851 int | |
1852 SDL_RenderWritePixels(const SDL_Rect * rect, const void *pixels, int pitch) | |
1853 { | |
1854 SDL_Renderer *renderer; | |
1855 SDL_Rect full_rect; | |
1856 | |
1857 if (!_this) { | |
1858 return -1; | |
1859 } | |
1860 | |
1861 renderer = SDL_CurrentDisplay.current_renderer; | |
1862 if (!renderer || !renderer->RenderWritePixels) { | |
1863 return -1; | |
1864 } | |
1865 | |
1866 if (!rect) { | |
1867 SDL_Window *window = SDL_GetWindowFromID(renderer->window); | |
1868 full_rect.x = 0; | |
1869 full_rect.y = 0; | |
1870 full_rect.w = window->w; | |
1871 full_rect.h = window->h; | |
1872 rect = &full_rect; | |
1873 } | |
1874 | |
1875 return renderer->RenderWritePixels(renderer, rect, pixels, pitch); | |
1876 } | |
1877 | |
1878 void | 1815 void |
1879 SDL_RenderPresent(void) | 1816 SDL_RenderPresent(void) |
1880 { | 1817 { |
1881 SDL_Renderer *renderer; | 1818 SDL_Renderer *renderer; |
1882 | 1819 |
1885 } | 1822 } |
1886 | 1823 |
1887 renderer = SDL_CurrentDisplay.current_renderer; | 1824 renderer = SDL_CurrentDisplay.current_renderer; |
1888 if (!renderer || !renderer->RenderPresent) { | 1825 if (!renderer || !renderer->RenderPresent) { |
1889 return; | 1826 return; |
1890 } | |
1891 | |
1892 if (renderer->SelectRenderTexture) { | |
1893 renderer->SelectRenderTexture(renderer, NULL); | |
1894 } | 1827 } |
1895 renderer->RenderPresent(renderer); | 1828 renderer->RenderPresent(renderer); |
1896 } | 1829 } |
1897 | 1830 |
1898 void | 1831 void |