Clean up basis.opengl and fix tests

db4
Slava Pestov 2009-02-19 05:01:21 -06:00
parent 2400e6bc51
commit f843877d35
2 changed files with 17 additions and 13 deletions

View File

@ -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
}
}
}

View File

@ -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 ;