diff --git a/basis/opengl/textures/textures-tests.factor b/basis/opengl/textures/textures-tests.factor index 28ae775fc3..45b1d8f706 100644 --- a/basis/opengl/textures/textures-tests.factor +++ b/basis/opengl/textures/textures-tests.factor @@ -22,14 +22,14 @@ IN: opengl.textures.tests { component-order RGB } { bitmap B{ - 1 2 3 4 5 6 7 8 9 0 0 0 - 10 11 12 13 14 15 16 17 18 0 0 0 - 19 20 21 22 23 24 25 26 27 0 0 0 - 28 29 30 31 32 33 34 35 36 0 0 0 - 37 38 39 40 41 42 43 44 45 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 3 4 5 6 7 8 9 7 8 9 + 10 11 12 13 14 15 16 17 18 16 17 18 + 19 20 21 22 23 24 25 26 27 25 26 27 + 28 29 30 31 32 33 34 35 36 34 35 36 + 37 38 39 40 41 42 43 44 45 43 44 45 + 37 38 39 40 41 42 43 44 45 43 44 45 + 37 38 39 40 41 42 43 44 45 43 44 45 + 37 38 39 40 41 42 43 44 45 43 44 45 } } } diff --git a/basis/opengl/textures/textures.factor b/basis/opengl/textures/textures.factor index b5d6dfa805..02e818d501 100644 --- a/basis/opengl/textures/textures.factor +++ b/basis/opengl/textures/textures.factor @@ -19,17 +19,21 @@ M: RGBA component-order>format drop GL_RGBA GL_UNSIGNED_BYTE ; M: ARGB component-order>format drop GL_BGRA_EXT GL_UNSIGNED_INT_8_8_8_8_REV ; M: BGRA component-order>format drop GL_BGRA_EXT GL_UNSIGNED_INT_8_8_8_8 ; +: repeat-last ( seq n -- seq' ) + over peek pad-tail concat ; + : power-of-2-bitmap ( rows dim size -- bitmap dim ) '[ - [ [ [ _ group ] map ] dip first '[ _ over peek pad-tail concat ] map ] - [ second over peek pad-tail ] bi - concat + first2 + [ [ _ ] dip '[ _ group _ repeat-last ] map ] + [ repeat-last ] + bi* ] keep ; : image-rows ( image -- rows ) [ bitmap>> ] [ dim>> first ] - [ component-order>> bytes-per-component ] + [ component-order>> bytes-per-pixel ] tri * group ; inline : power-of-2-image ( image -- image ) @@ -37,7 +41,7 @@ M: BGRA component-order>format drop GL_BGRA_EXT GL_UNSIGNED_INT_8_8_8_8 ; clone dup [ image-rows ] [ dim>> [ next-power-of-2 ] map ] - [ component-order>> bytes-per-component ] tri + [ component-order>> bytes-per-pixel ] tri power-of-2-bitmap [ >>bitmap ] [ >>dim ] bi* ] unless ;