Load fixes, FreeType memory usage fix

db4
Slava Pestov 2008-02-02 15:00:16 -06:00
parent b381c123dd
commit 70b685fad8
8 changed files with 20 additions and 19 deletions

View File

@ -5,7 +5,7 @@ io.buffers io.files io.nonblocking io.sockets io.binary
io.sockets.impl windows.errors strings io.streams.duplex kernel
math namespaces sequences windows windows.kernel32
windows.shell32 windows.types windows.winsock splitting
continuations ;
continuations math.bitfields ;
IN: io.windows
TUPLE: windows-nt-io ;

View File

@ -1,11 +1,11 @@
! Copyright (C) 2005, 2007 Slava Pestov.
! Copyright (C) 2005, 2008 Slava Pestov.
! Portions copyright (C) 2007 Eduardo Cavazos.
! Portions copyright (C) 2008 Joe Groff.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types continuations kernel libc math macros
namespaces math.vectors math.constants math.functions
math.parser opengl.gl opengl.glu combinators arrays sequences
splitting words byte-arrays ;
splitting words byte-arrays assocs ;
IN: opengl
: coordinates [ first2 ] 2apply ;
@ -233,7 +233,8 @@ TUPLE: sprite loc dim dim2 dlist texture ;
dup sprite-dlist delete-dlist
sprite-texture delete-texture ;
: free-sprites ( sprites -- ) [ [ free-sprite ] when* ] each ;
: free-sprites ( sprites -- )
[ nip [ free-sprite ] when* ] assoc-each ;
: with-translation ( loc quot -- )
GL_MODELVIEW [ >r gl-translate r> call ] do-matrix ; inline

View File

@ -36,13 +36,13 @@ M: font hashcode* drop font hashcode* ;
: close-freetype ( -- )
global [
open-fonts [ values [ close-font ] each f ] change
open-fonts [ [ drop close-font ] assoc-each f ] change
freetype [ FT_Done_FreeType f ] change
] bind ;
M: freetype-renderer free-fonts ( world -- )
dup world-handle select-gl-context
world-fonts values [ second free-sprites ] each ;
world-fonts [ nip second free-sprites ] assoc-each ;
: ttf-name ( font style -- name )
2array H{
@ -100,7 +100,7 @@ SYMBOL: dpi
swap set-font-height ;
: <font> ( handle -- font )
V{ } clone
H{ } clone
{ set-font-handle set-font-widths } font construct
dup init-font ;
@ -119,7 +119,7 @@ M: freetype-renderer open-font ( font -- open-font )
: char-width ( open-font char -- w )
over font-widths [
dupd load-glyph glyph-hori-advance ft-ceil
] cache-nth nip ;
] cache nip ;
M: freetype-renderer string-width ( open-font string -- w )
0 -rot [ char-width + ] with each ;
@ -175,7 +175,7 @@ M: freetype-renderer string-height ( open-font string -- h )
[ bitmap>texture ] keep [ init-sprite ] keep ;
: draw-char ( open-font char sprites -- )
[ dupd <char-sprite> ] cache-nth nip
[ dupd <char-sprite> ] cache nip
sprite-dlist glCallList ;
: (draw-string) ( open-font sprites string loc -- )
@ -186,7 +186,7 @@ M: freetype-renderer string-height ( open-font string -- h )
] do-enabled ;
: font-sprites ( open-font world -- pair )
world-fonts [ open-font V{ } clone 2array ] cache ;
world-fonts [ open-font H{ } clone 2array ] cache ;
M: freetype-renderer draw-string ( font string loc -- )
>r >r world get font-sprites first2 r> r> (draw-string) ;

View File

@ -6,7 +6,8 @@ math math.vectors namespaces prettyprint sequences strings
vectors words windows.kernel32 windows.gdi32 windows.user32
windows.opengl32 windows.messages windows.types
windows.nt windows threads timers libc combinators continuations
command-line shuffle opengl ui.render unicode.case ascii ;
command-line shuffle opengl ui.render unicode.case ascii
math.bitfields ;
IN: ui.windows
TUPLE: windows-ui-backend ;

View File

@ -1,4 +1,4 @@
USING: alien.syntax kernel math windows.types ;
USING: alien.syntax kernel math windows.types math.bitfields ;
IN: windows.advapi32
LIBRARY: advapi32

View File

@ -1,7 +1,8 @@
! Copyright (C) 2005, 2006 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.syntax parser namespaces kernel
math windows.types windows.types init assocs sequences libc ;
math math.bitfields windows.types windows.types init assocs
sequences libc ;
IN: windows.opengl32
! PIXELFORMATDESCRIPTOR flags
@ -70,8 +71,6 @@ IN: windows.opengl32
: WGL_SWAP_UNDERLAY14 HEX: 20000000 ; inline
: WGL_SWAP_UNDERLAY15 HEX: 40000000 ; inline
: pfd-dwFlags
{ PFD_DRAW_TO_WINDOW PFD_SUPPORT_OPENGL PFD_DOUBLEBUFFER } flags ;

View File

@ -1,7 +1,7 @@
! Copyright (C) 2005, 2006 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.syntax parser namespaces kernel math
windows.types shuffle ;
windows.types shuffle math.bitfields ;
IN: windows.user32
! HKL for ActivateKeyboardLayout

View File

@ -1,8 +1,8 @@
! Copyright (C) 2006 Mackenzie Straight, Doug Coleman.
USING: alien alien.c-types alien.syntax arrays byte-arrays kernel
math sequences windows.types windows.kernel32 windows.errors structs
windows ;
USING: alien alien.c-types alien.syntax arrays byte-arrays
kernel math sequences windows.types windows.kernel32
windows.errors structs windows math.bitfields ;
IN: windows.winsock
USE: libc