given a chunked bitmap, renders it.scaled
| 1811 | } |
| 1812 | // given a chunked bitmap, renders it.scaled |
| 1813 | void rend_DrawScaledChunkedBitmap(chunked_bitmap *chunk, int x, int y, int neww, int newh, uint8_t alpha) { |
| 1814 | int *bm_array = chunk->bm_array; |
| 1815 | int w = chunk->w; |
| 1816 | int h = chunk->h; |
| 1817 | int piece_w; |
| 1818 | int piece_h; |
| 1819 | int screen_w, screen_h; |
| 1820 | int i, t; |
| 1821 | |
| 1822 | float scalew, scaleh; |
| 1823 | |
| 1824 | scalew = ((float)neww) / ((float)chunk->pw); |
| 1825 | scaleh = ((float)newh) / ((float)chunk->ph); |
| 1826 | piece_w = scalew * ((float)bm_w(bm_array[0], 0)); |
| 1827 | piece_h = scaleh * ((float)bm_h(bm_array[0], 0)); |
| 1828 | rend_GetProjectionParameters(&screen_w, &screen_h); |
| 1829 | rend_SetOverlayType(OT_NONE); |
| 1830 | rend_SetLighting(LS_NONE); |
| 1831 | rend_SetColorModel(CM_MONO); |
| 1832 | rend_SetZBufferState(0); |
| 1833 | rend_SetAlphaType(AT_CONSTANT_TEXTURE); |
| 1834 | rend_SetAlphaValue(alpha); |
| 1835 | rend_SetWrapType(WT_WRAP); |
| 1836 | for (i = 0; i < h; i++) { |
| 1837 | for (t = 0; t < w; t++) { |
| 1838 | int dx = x + (piece_w * t); |
| 1839 | int dy = y + (piece_h * i); |
| 1840 | int dw, dh; |
| 1841 | if ((dx + piece_w) > screen_w) |
| 1842 | dw = piece_w - ((dx + piece_w) - screen_w); |
| 1843 | else |
| 1844 | dw = piece_w; |
| 1845 | if ((dy + piece_h) > screen_h) |
| 1846 | dh = piece_h - ((dy + piece_h) - screen_h); |
| 1847 | else |
| 1848 | dh = piece_h; |
| 1849 | |
| 1850 | float u2 = (float)dw / (float)piece_w; |
| 1851 | float v2 = (float)dh / (float)piece_h; |
| 1852 | rend_DrawScaledBitmap(dx, dy, dx + dw, dy + dh, bm_array[i * w + t], 0, 0, u2, v2); |
| 1853 | } |
| 1854 | } |
| 1855 | rend_SetZBufferState(1); |
| 1856 | } |
| 1857 | // Sets some global preferences for the renderer |
| 1858 | int rend_SetPreferredState(renderer_preferred_state *pref_state) { |
| 1859 | int retval = 1; |
nothing calls this directly
no test coverage detected