From 6a18dec56625c1d1cb6cab048622aee73e6b0062 Mon Sep 17 00:00:00 2001 From: erikc Date: Fri, 5 Feb 2010 15:32:38 -0800 Subject: [PATCH 01/10] Had the color order for TGA backwards --- basis/images/tga/tga.factor | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/basis/images/tga/tga.factor b/basis/images/tga/tga.factor index c24fd5f5bd..7a3a400197 100644 --- a/basis/images/tga/tga.factor +++ b/basis/images/tga/tga.factor @@ -238,7 +238,7 @@ ERROR: bad-tga-unsupported ; ] unless ] ignore-errors - #! Only 24-bit uncompressed RGB and 32-bit uncompressed ARGB are supported. + #! Only 24-bit uncompressed BGR and 32-bit uncompressed BGRA are supported. #! Other formats would need to be converted to work within the image class. map-type 0 = [ bad-tga-unsupported ] unless image-type 2 = [ bad-tga-unsupported ] unless @@ -247,7 +247,7 @@ ERROR: bad-tga-unsupported ; #! Create image instance image new - alpha-bits 0 = [ RGB ] [ ARGB ] if >>component-order + alpha-bits 0 = [ BGR ] [ BGRA ] if >>component-order { image-width image-height } >>dim pixel-order 0 = >>upside-down? image-data >>bitmap @@ -259,7 +259,7 @@ M: tga-image stream>image M: tga-image image>stream drop [ - component-order>> { RGB ARGB } member? [ bad-tga-unsupported ] unless + component-order>> { BGRA BGRA } member? [ bad-tga-unsupported ] unless ] keep B{ 0 } write #! id-length @@ -272,15 +272,15 @@ M: tga-image image>stream [ dim>> second 2 >le write ] [ component-order>> { - { RGB [ B{ 24 } write ] } - { ARGB [ B{ 32 } write ] } + { BGR [ B{ 24 } write ] } + { BGRA [ B{ 32 } write ] } } case ] [ dup component-order>> { - { RGB [ 0 ] } - { ARGB [ 8 ] } + { BGR [ 0 ] } + { BGRA [ 8 ] } } case swap upside-down?>> [ 0 ] [ 2 ] if 3 shift bitor 1 >le write From d435e5256c799b062a427fa6671af308bb1b6625 Mon Sep 17 00:00:00 2001 From: erikc Date: Fri, 5 Feb 2010 15:51:53 -0800 Subject: [PATCH 02/10] Add material loading for OBJ format, generalize model-viewer and removed hard-coded paths --- extra/game/models/collada/collada-docs.factor | 3 +- extra/game/models/collada/collada.factor | 4 +- extra/game/models/models-docs.factor | 2 +- extra/game/models/models.factor | 2 +- extra/game/models/obj/obj-docs.factor | 70 ++++ extra/game/models/obj/obj.factor | 188 +++++++---- extra/game/models/util/util.factor | 2 - extra/model-viewer/model-viewer.factor | 298 +++++++++--------- 8 files changed, 358 insertions(+), 211 deletions(-) diff --git a/extra/game/models/collada/collada-docs.factor b/extra/game/models/collada/collada-docs.factor index 402f5eddc1..5be2e19790 100644 --- a/extra/game/models/collada/collada-docs.factor +++ b/extra/game/models/collada/collada-docs.factor @@ -2,7 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: help.markup help.crossref help.stylesheet help.topics help.syntax definitions io prettyprint summary arrays math sequences vocabs strings -see xml.data hashtables assocs game.models.collada.private game.models.util ; +see xml.data hashtables assocs game.models.collada.private game.models +game.models.util ; IN: game.models.collada ABOUT: "game.models.collada" diff --git a/extra/game/models/collada/collada.factor b/extra/game/models/collada/collada.factor index 3de255bae8..9d8fad764c 100644 --- a/extra/game/models/collada/collada.factor +++ b/extra/game/models/collada/collada.factor @@ -5,7 +5,7 @@ locals math math.parser sequences sequences.deep specialized-arrays.instances.alien.c-types.float specialized-arrays.instances.alien.c-types.uint splitting xml xml.data xml.traversal math.order -namespaces combinators images gpu.shaders io make +namespaces combinators images gpu.shaders io make game.models game.models.util io.encodings.ascii game.models.loader ; IN: game.models.collada @@ -152,7 +152,7 @@ VERTEX-FORMAT: collada-vertex-format soa>aos [ flatten >float-array ] [ flatten >uint-array ] - bi* collada-vertex-format model boa + bi* collada-vertex-format f model boa ] bi ; : mesh>triangles ( sources vertices mesh-tag -- models ) diff --git a/extra/game/models/models-docs.factor b/extra/game/models/models-docs.factor index 907c32e294..174d64a156 100644 --- a/extra/game/models/models-docs.factor +++ b/extra/game/models/models-docs.factor @@ -6,4 +6,4 @@ see ; IN: game.models HELP: model -{ $class-description "Tuple of a packed attribute buffer, index buffer and vertex format suitable for a single OpenGL draw call." } ; +{ $class-description "Tuple of a packed attribute buffer, index buffer, vertex format and material suitable for a single OpenGL draw call." } ; diff --git a/extra/game/models/models.factor b/extra/game/models/models.factor index 5575f5fb80..2d297f80b9 100644 --- a/extra/game/models/models.factor +++ b/extra/game/models/models.factor @@ -3,5 +3,5 @@ USING: ; IN: game.models -TUPLE: model attribute-buffer index-buffer vertex-format ; +TUPLE: model attribute-buffer index-buffer vertex-format material ; diff --git a/extra/game/models/obj/obj-docs.factor b/extra/game/models/obj/obj-docs.factor index e69de29bb2..adea0ef34b 100644 --- a/extra/game/models/obj/obj-docs.factor +++ b/extra/game/models/obj/obj-docs.factor @@ -0,0 +1,70 @@ +! Copyright (C) 2010 Erik Charlebois +! See http://factorcode.org/license.txt for BSD license. +USING: help.markup help.crossref help.stylesheet help.topics help.syntax +definitions io prettyprint summary arrays math sequences vocabs strings +see xml.data hashtables assocs game.models.obj.private game.models +game.models.util io.pathnames ; +IN: game.models.obj + +ABOUT: "game.models.obj" + +ARTICLE: "game.models.obj" "Conversion of Wavefront OBJ assets" +"The " { $vocab-link "game.models.obj" } " vocabulary implements words for converting Wavefront OBJ assets to data suitable for use with OpenGL." ; + +HELP: material +{ $class-description "Tuple describing the GPU state that needs to be applied prior to rendering geometry tagged with this material." } ; + +HELP: cm +{ $values { "current-material" material } } +{ $description "Convenience word for accessing the current material while parsing primitives." } ; + +HELP: md +{ $values { "material-dictionary" assoc } } +{ $description "Convenience word for accessing the material dictionary while parsing primitives. " } ; + +HELP: strings>floats +{ $values { "strings" sequence } { "floats" sequence } } +{ $description "Convert a sequence of strings to a sequence of floats." } ; + +HELP: strings>faces +{ $values { "strings" sequence } { "faces" sequence } } +{ $description "Convert a sequence of '/'-delimited strings into a sequence of sequences of numbers. Each number is an index into the vertex, texture or normal tables, respectively." } ; + +HELP: split-string +{ $values { "string" string } { "strings" sequence } } +{ $description "Split the given string on whitespace." } ; + +HELP: line>mtl +{ $values { "line" string } } +{ $description "Process a line from a material file within the current parsing context." } ; + +HELP: read-mtl +{ $values { "file" pathname } { "material-dictionary" assoc } } +{ $description "Read the specified material file and generate a material dictionary keyed by material name." } ; + +HELP: obj-vertex-format +{ $class-description "Vertex format used for rendering OBJ geometry." } ; + +HELP: triangle>aos +{ $values { "x" sequence } { "y" sequence } } +{ $description "Convert a sequence of vertex, texture and normal indices into a sequence of vertex, texture and normal values." } ; + +HELP: quad>aos +{ $values { "x" sequence } { "y" sequence } { "z" sequence } } +{ $description "Convert a sequence of vertex, texture and normal indices into two sequences of vertex, texture and normal values. This splits a quad into two triangles." } ; + +HELP: face>aos +{ $values { "x" sequence } { "y" sequence } } +{ $description "Convert a face line to a sequence of vertex attributes." } ; + +HELP: push* +{ $values { "elt" "an object" } { "seq" sequence } { "seq" sequence } } +{ $description "Push the value onto the sequence, keeping the sequence on the stack." } ; + +HELP: push-current-model +{ $description "Push the current model being built onto the models list and initialize a fresh empty model." } ; + +HELP: line>obj +{ $values { "line" string } } +{ $description "Process a line from the object file within the current parsing context." } ; + diff --git a/extra/game/models/obj/obj.factor b/extra/game/models/obj/obj.factor index 94927c9db8..57eddcec6c 100644 --- a/extra/game/models/obj/obj.factor +++ b/extra/game/models/obj/obj.factor @@ -1,98 +1,166 @@ -! Copyright (C) 2010 Your name. +! Copyright (C) 2010 Erik Charlebois ! See http://factorcode.org/license.txt for BSD license. USING: io io.encodings.ascii math.parser sequences splitting kernel assocs io.files combinators math.order math namespaces arrays sequences.deep accessors specialized-arrays.instances.alien.c-types.float specialized-arrays.instances.alien.c-types.uint -game.models.util gpu.shaders images game.models.loader ; +game.models game.models.util gpu.shaders images +game.models.loader prettyprint ; IN: game.models.obj SINGLETON: obj-models "obj" ascii obj-models register-models-class floats ( strings -- floats ) + [ string>float ] map ; + +: strings>faces ( strings -- faces ) + [ "/" split [ string>number ] map ] map ; + +: split-string ( string -- strings ) + " \t\n" split harvest ; + +: line>mtl ( line -- ) + " \t\n" split harvest + [ + [ rest ] [ first ] bi + { + { "newmtl" [ first + [ material new swap >>name current-material set ] + [ cm swap md set-at ] bi + ] } + { "Ka" [ 3 head [ string>float ] map cm (>>ambient-reflectivity) ] } + { "Kd" [ 3 head [ string>float ] map cm (>>diffuse-reflectivity) ] } + { "Ks" [ 3 head [ string>float ] map cm (>>specular-reflectivity) ] } + { "Tf" [ 3 head [ string>float ] map cm (>>transmission-filter) ] } + { "d" [ first string>float cm (>>dissolve) ] } + { "Ns" [ first string>float cm (>>specular-exponent) ] } + { "Ni" [ first string>float cm (>>refraction-index) ] } + { "map_Ka" [ first cm (>>ambient-map) ] } + { "map_Kd" [ first cm (>>diffuse-map) ] } + { "map_Ks" [ first cm (>>specular-map) ] } + { "map_Ns" [ first cm (>>specular-exponent-map) ] } + { "map_d" [ first cm (>>dissolve-map) ] } + { "map_bump" [ first cm (>>bump-map) ] } + { "bump" [ first cm (>>bump-map) ] } + { "disp" [ first cm (>>displacement-map) ] } + { "refl" [ first cm (>>reflection-map) ] } + [ 2drop ] + } case + ] unless-empty ; + +: read-mtl ( file -- material-dictionary ) + [ + f current-material set + H{ } clone material-dictionary set + ] H{ } make-assoc + [ + ascii file-lines [ line>mtl ] each + md + ] bind ; VERTEX-FORMAT: obj-vertex-format { "POSITION" float-components 3 f } { "TEXCOORD" float-components 2 f } { "NORMAL" float-components 3 f } ; -: string>floats ( x -- y ) - [ string>float ] map ; - -: string>faces ( x -- y ) - [ "/" split [ string>number ] map ] map ; - -: 3face>aos ( x -- y ) - dup length { - { 3 - [ - first3 - [ 1 - v get nth ] - [ 1 - vt get nth ] - [ 1 - vn get nth ] tri* 3array flatten - ] } - { 2 - [ - first2 - [ 1 - v get nth ] - [ 1 - vt get nth ] bi* 2array flatten - ] } - } case ; - - -: 4face>aos ( x -- y z ) - [ 3 head [ 3face>aos 1array ] map ] - [ [ 0 swap nth ] [ 2 swap nth ] [ 3 swap nth ] tri 3array [ 3face>aos 1array ] map ] - bi - ; - -: faces>aos ( x -- y ) +: triangle>aos ( x -- y ) dup length { - { 3 [ [ 3face>aos 1array ] map 1array ] } - { 4 [ 4face>aos 2array ] } + { 3 [ + first3 + [ 1 - vp get nth ] + [ 1 - vt get nth ] + [ 1 - vn get nth ] tri* 3array flatten + ] } + { 2 [ + first2 + [ 1 - vp get nth ] + [ 1 - vt get nth ] bi* 2array flatten + ] } + } case ; + +: quad>aos ( x -- y z ) + [ 3 head [ triangle>aos 1array ] map ] + [ [ 2 swap nth ] + [ 3 swap nth ] + [ 0 swap nth ] tri 3array + [ triangle>aos 1array ] map ] + bi ; + +: face>aos ( x -- y ) + dup length + { + { 3 [ [ triangle>aos 1array ] map 1array ] } + { 4 [ quad>aos 2array ] } } case ; -: push* ( x z -- y ) +: push* ( elt seq -- seq ) [ push ] keep ; +: push-current-model ( -- ) + current-model get [ + [ dseq>> flatten >float-array ] + [ iseq>> flatten >uint-array ] + bi obj-vertex-format current-material get model boa models get push + V{ } V{ } H{ } current-model set + ] unless-empty ; + : line>obj ( line -- ) - " \t\n" split harvest dup - length 1 > + split-string [ [ rest ] [ first ] bi { - { "#" [ drop ] } - { "v" [ string>floats 3 head v [ push* ] change ] } - { "vt" [ string>floats 2 head vt [ push* ] change ] } - { "vn" [ string>floats 3 head vn [ push* ] change ] } - { "f" [ string>faces faces>aos [ [ i [ push* ] change ] each ] each ] } - { "o" [ drop ] } - { "g" [ drop ] } - { "s" [ drop ] } - { "mtllib" [ drop ] } - { "usemtl" [ drop ] } + { "mtllib" [ first read-mtl material-dictionary set ] } + { "v" [ strings>floats 3 head vp [ push* ] change ] } + { "vt" [ strings>floats 2 head vt [ push* ] change ] } + { "vn" [ strings>floats 3 head vn [ push* ] change ] } + { "usemtl" [ push-current-model first md at current-material set ] } + { "f" [ strings>faces face>aos [ [ current-model [ push* ] change ] each ] each ] } + [ 2drop ] } case - ] - [ drop ] if ; + ] unless-empty ; PRIVATE> M: obj-models stream>models drop [ - V{ } - [ clone v set ] - [ clone vt set ] - [ clone vn set ] tri - V{ } V{ } H{ } i set + V{ } clone vp set + V{ } clone vt set + V{ } clone vn set + V{ } clone models set + V{ } V{ } H{ } current-model set + f current-material set + f material-dictionary set ] H{ } make-assoc [ - [ line>obj ] each-stream-line i get - ] bind - [ dseq>> flatten >float-array ] - [ iseq>> flatten >uint-array ] bi obj-vertex-format model boa 1array ; + [ line>obj ] each-stream-line push-current-model + models get + ] bind ; diff --git a/extra/game/models/util/util.factor b/extra/game/models/util/util.factor index 76f93f8365..438ab82356 100644 --- a/extra/game/models/util/util.factor +++ b/extra/game/models/util/util.factor @@ -3,8 +3,6 @@ USING: sequences accessors kernel locals assocs ; IN: game.models.util -TUPLE: model attribute-buffer index-buffer vertex-format ; - TUPLE: indexed-seq dseq iseq rassoc ; INSTANCE: indexed-seq sequence diff --git a/extra/model-viewer/model-viewer.factor b/extra/model-viewer/model-viewer.factor index 641e4fe763..22a80a136e 100644 --- a/extra/model-viewer/model-viewer.factor +++ b/extra/model-viewer/model-viewer.factor @@ -8,93 +8,109 @@ io io.encodings.ascii io.files io.files.temp kernel locals math math.matrices math.vectors.simd math.parser math.vectors method-chains namespaces sequences splitting threads ui ui.gadgets ui.gadgets.worlds ui.pixel-formats specialized-arrays -specialized-vectors literals fry xml -xml.traversal sequences.deep destructors math.bitwise opengl.gl -game.models.obj game.models.loader game.models.collada ; +specialized-vectors literals fry +sequences.deep destructors math.bitwise opengl.gl +game.models game.models.obj game.models.loader game.models.collada +prettyprint images.tga ; FROM: alien.c-types => float ; SPECIALIZED-ARRAY: float SPECIALIZED-VECTOR: uint IN: model-viewer -GLSL-SHADER: model-vertex-shader vertex-shader -uniform mat4 mv_matrix, p_matrix; -uniform vec3 light_position; +GLSL-SHADER: obj-vertex-shader vertex-shader +uniform mat4 mv_matrix; +uniform mat4 p_matrix; attribute vec3 POSITION; +attribute vec3 TEXCOORD; attribute vec3 NORMAL; -attribute vec2 TEXCOORD; -varying vec2 texit; -varying vec3 norm; +varying vec2 texcoord_fs; +varying vec3 normal_fs; +varying vec3 world_pos_fs; void main() { vec4 position = mv_matrix * vec4(POSITION, 1.0); - gl_Position = p_matrix * position; - texit = TEXCOORD; - norm = NORMAL; + gl_Position = p_matrix * position; + world_pos_fs = POSITION; + texcoord_fs = TEXCOORD; + normal_fs = NORMAL; } ; -GLSL-SHADER: model-fragment-shader fragment-shader -varying vec2 texit; -varying vec3 norm; -void main() -{ - gl_FragColor = vec4(texit, 0, 1) + vec4(norm, 1); -} -; - -GLSL-PROGRAM: model-program - model-vertex-shader model-fragment-shader ; - -GLSL-SHADER: debug-vertex-shader vertex-shader +GLSL-SHADER: obj-fragment-shader fragment-shader uniform mat4 mv_matrix, p_matrix; -uniform vec3 light_position; - -attribute vec3 POSITION; -attribute vec3 COLOR; -varying vec4 color; - +uniform sampler2D map_Ka; +uniform sampler2D map_bump; +uniform vec3 Ka; +uniform vec3 view_pos; +uniform vec3 light; +varying vec2 texcoord_fs; +varying vec3 normal_fs; +varying vec3 world_pos_fs; void main() { - gl_Position = p_matrix * mv_matrix * vec4(POSITION, 1.0); - color = vec4(COLOR, 1); + vec4 d = texture2D(map_Ka, texcoord_fs.xy); + vec3 b = texture2D(map_bump, texcoord_fs.xy).xyz; + vec3 n = normal_fs; + vec3 v = normalize(view_pos - world_pos_fs); + vec3 l = normalize(light); + vec3 h = normalize(v + l); + float cosTh = saturate(dot(n, l)); + gl_FragColor = d * cosTh + + d * 0.5 * cosTh * pow(saturate(dot(n, h)), 10.0) ; } ; -GLSL-SHADER: debug-fragment-shader fragment-shader -varying vec4 color; -void main() -{ - gl_FragColor = color; -} -; - -GLSL-PROGRAM: debug-program debug-vertex-shader debug-fragment-shader ; +GLSL-PROGRAM: obj-program + obj-vertex-shader obj-fragment-shader ; UNIFORM-TUPLE: model-uniforms < mvp-uniforms - { "light-position" vec3-uniform f } ; + { "map_Ka" texture-uniform f } + { "map_bump" texture-uniform f } + { "Ka" vec3-uniform f } + { "light" vec3-uniform f } + { "view_pos" vec3-uniform f } + ; TUPLE: model-state models vertex-arrays - index-vectors ; + index-vectors + textures + bumps + kas ; -TUPLE: model-world < wasd-world - { model-state model-state } ; +TUPLE: model-world < wasd-world model-path model-state ; -VERTEX-FORMAT: model-vertex - { "POSITION" float-components 3 f } - { "NORMAL" float-components 3 f } - { "TEXCOORD" float-components 2 f } ; +TUPLE: vbo + vertex-buffer + index-buffer index-count vertex-format texture bump ka ; -VERTEX-FORMAT: debug-vertex - { "POSITION" float-components 3 f } - { "COLOR" float-components 3 f } ; - -TUPLE: vbo vertex-buffer index-buffer index-count vertex-format ; +: white-image ( -- image ) + { 1 1 } BGR ubyte-components f + B{ 255 255 255 } image boa ; +: up-image ( -- image ) + { 1 1 } BGR ubyte-components f + B{ 0 0 0 } image boa ; + +: make-texture ( pathname alt -- texture ) + swap [ nip load-image ] [ ] if* + [ + [ component-order>> ] + [ component-type>> ] bi + T{ texture-parameters + { wrap repeat-texcoord } + { min-filter filter-linear } + { min-mipmap-filter f } } + + ] + [ + 0 swap [ allocate-texture-image ] 3keep 2drop + ] bi ; + : ( models -- buffers ) [ { @@ -102,110 +118,104 @@ TUPLE: vbo vertex-buffer index-buffer index-count vertex-format ; [ index-buffer>> underlying>> static-upload draw-usage index-buffer byte-array>buffer ] [ index-buffer>> length ] [ vertex-format>> ] + [ material>> ambient-map>> white-image make-texture ] + [ material>> bump-map>> up-image make-texture ] + [ material>> ambient-reflectivity>> ] } cleave vbo boa ] map ; : fill-model-state ( model-state -- ) dup models>> - [ - [ - [ vertex-buffer>> model-program ] - [ vertex-format>> ] bi buffer>vertex-array - ] map >>vertex-arrays drop - ] - [ - [ - [ index-buffer>> ] [ index-count>> ] bi - '[ _ 0 _ uint-indexes ] call - ] map >>index-vectors drop - ] 2bi ; - -: model-files ( -- files ) - { "C:/Users/erikc/Downloads/test2.dae" - "C:/Users/erikc/Downloads/Sponza.obj" } ; - -: ( -- model-state ) - model-state new - model-files [ load-models ] [ append ] map-reduce >>models ; - -M: model-world begin-game-world - init-gpu - { 0.0 0.0 2.0 } 0 0 set-wasd-view - [ fill-model-state drop ] [ >>model-state drop ] 2bi ; - -: ( world -- uniforms ) - [ wasd-mv-matrix ] [ wasd-p-matrix ] bi - { -10000.0 10000.0 10000.0 } ! light position - model-uniforms boa ; - -: draw-line ( world from to color -- ) - [ 3 head ] tri@ dup -rot append -rot append swap append >float-array - underlying>> stream-upload draw-usage vertex-buffer byte-array>buffer - debug-program debug-vertex buffer>vertex-array - - { 0 1 } >uint-array stream-upload draw-usage index-buffer byte-array>buffer - 2 '[ _ 0 _ uint-indexes ] call - - rot - { - { "primitive-mode" [ 3drop lines-mode ] } - { "uniforms" [ nip nip ] } - { "vertex-array" [ drop drop ] } - { "indexes" [ drop nip ] } - } 3 render ; + [ + [ + [ vertex-buffer>> obj-program ] + [ vertex-format>> ] bi buffer>vertex-array + ] map >>vertex-arrays drop + ] + [ + [ + [ index-buffer>> ] [ index-count>> ] bi + '[ _ 0 _ uint-indexes ] call + ] map >>index-vectors drop + ] + [ [ texture>> ] map >>textures drop ] + [ [ bump>> ] map >>bumps drop ] + [ [ ka>> ] map >>kas drop ] + } 2cleave ; -: draw-lines ( world lines -- ) - 3 [ first3 draw-line ] with each ; inline +: ( model-world -- model-state ) + model-path>> 1array model-state new swap + [ load-models ] [ append ] map-reduce >>models ; -: draw-axes ( world -- ) - { { 0 0 0 } { 1 0 0 } { 1 0 0 } - { 0 0 0 } { 0 1 0 } { 0 1 0 } - { 0 0 0 } { 0 0 1 } { 0 0 1 } } draw-lines ; - -: draw-model ( world -- ) +:: ( world -- uniforms ) + world model-state>> + [ textures>> ] [ bumps>> ] [ kas>> ] tri + [| texture bump ka | + world wasd-mv-matrix + world wasd-p-matrix + texture bump ka + { 0.5 0.5 0.5 } + world location>> + model-uniforms boa + ] 3map ; + +: clear-screen ( -- ) 0 0 0 0 glClearColor 1 glClearDepth HEX: ffffffff glClearStencil - { GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT GL_STENCIL_BUFFER_BIT } flags glClear - + { GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT + GL_STENCIL_BUFFER_BIT } flags glClear ; + +: draw-model ( world -- ) + clear-screen + face-ccw cull-back set-gpu-state + cmp-less set-gpu-state + [ model-state>> vertex-arrays>> ] + [ model-state>> index-vectors>> ] + [ ] + tri [ - triangle-fill dup t set-gpu-state - face-ccw cull-back set-gpu-state - - cmp-less set-gpu-state - [ model-state>> vertex-arrays>> ] - [ model-state>> index-vectors>> ] - [ ] - tri - [ - { - { "primitive-mode" [ 3drop triangles-mode ] } - { "uniforms" [ nip nip ] } - { "vertex-array" [ drop drop ] } - { "indexes" [ drop nip ] } - } 3 render - ] curry 2each - ] - [ - cmp-always set-gpu-state - draw-axes - ] - bi ; + { + { "primitive-mode" [ 3drop triangles-mode ] } + { "uniforms" [ nip nip ] } + { "vertex-array" [ drop drop ] } + { "indexes" [ drop nip ] } + } 3 render + ] 3each ; -M: model-world draw-world* - draw-model ; +TUPLE: model-attributes < game-attributes model-path ; +M: model-world draw-world* draw-model ; M: model-world wasd-movement-speed drop 1/4. ; M: model-world wasd-near-plane drop 1/32. ; M: model-world wasd-far-plane drop 1024.0 ; +M: model-world begin-game-world + init-gpu + { 0.0 0.0 2.0 } 0 0 set-wasd-view + [ [ fill-model-state ] keep ] [ (>>model-state) ] bi ; +M: model-world apply-world-attributes + { + [ model-path>> >>model-path ] + [ call-next-method ] + } cleave ; -GAME: model-viewer { - { world-class model-world } - { title "Model Viewer" } - { pixel-format-attributes { windowed double-buffered } } - { grab-input? t } - { use-game-input? t } - { pref-dim { 1024 768 } } - { tick-interval-micros $[ 60 fps ] } - } ; +:: open-model-viewer ( model-path -- ) + [ + f + T{ model-attributes + { world-class model-world } + { grab-input? t } + { title "Model Viewer" } + { pixel-format-attributes + { windowed double-buffered } + } + { pref-dim { 1024 768 } } + { tick-interval-micros 16666 } + { use-game-input? t } + { model-path model-path } + } + clone + open-window + ] with-ui ; From e3c3739624a04cc2767901be3b6f312343cacd02 Mon Sep 17 00:00:00 2001 From: erikc Date: Fri, 5 Feb 2010 15:52:55 -0800 Subject: [PATCH 03/10] Add brace matching for parse time quotes $\[ --- misc/fuel/fuel-syntax.el | 1 + 1 file changed, 1 insertion(+) diff --git a/misc/fuel/fuel-syntax.el b/misc/fuel/fuel-syntax.el index 851e13f13d..635bf0ea82 100644 --- a/misc/fuel/fuel-syntax.el +++ b/misc/fuel/fuel-syntax.el @@ -287,6 +287,7 @@ ("\\_<\\()\\))\\_>" (1 ")(")) ;; Quotations: ("\\_<'\\(\\[\\)\\_>" (1 "(]")) ; fried + ("\\_<$\\(\\[\\)\\_>" (1 "(]")) ; parse-time ("\\_<\\(\\[\\)\\_>" (1 "(]")) ("\\_<\\(\\]\\)\\_>" (1 ")[")))) From daefa86b6dcfdc5106a5f6a4be025a761ea06fb1 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 6 Feb 2010 18:04:28 +1300 Subject: [PATCH 04/10] cpu.ppc: needs same fix for jit-profiling as on x86-64 --- basis/cpu/ppc/bootstrap.factor | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/basis/cpu/ppc/bootstrap.factor b/basis/cpu/ppc/bootstrap.factor index 698fc6257a..b2ae9c4e73 100644 --- a/basis/cpu/ppc/bootstrap.factor +++ b/basis/cpu/ppc/bootstrap.factor @@ -97,11 +97,11 @@ CONSTANT: ctx-reg 16 rs-reg ctx-reg context-retainstack-offset LWZ ; [ - 0 3 LOAD32 rc-absolute-ppc-2/2 rt-literal jit-rel - 11 3 profile-count-offset LWZ + 0 12 LOAD32 rc-absolute-ppc-2/2 rt-literal jit-rel + 11 12 profile-count-offset LWZ 11 11 1 tag-fixnum ADDI - 11 3 profile-count-offset STW - 11 3 word-code-offset LWZ + 11 12 profile-count-offset STW + 11 12 word-code-offset LWZ 11 11 compiled-header-size ADDI 11 MTCTR BCTR From d5a25f99bf41702274a5cfea40a77b248f589ff1 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 6 Feb 2010 18:41:58 +1300 Subject: [PATCH 05/10] cpu.x86.64: inline cache miss blocks have a prolog generated in the middle of a procedure; undo a recent change to non-optimizing backend to fix random crashes --- basis/cpu/x86/64/bootstrap.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/cpu/x86/64/bootstrap.factor b/basis/cpu/x86/64/bootstrap.factor index 48b5dfd65d..bc560580fa 100644 --- a/basis/cpu/x86/64/bootstrap.factor +++ b/basis/cpu/x86/64/bootstrap.factor @@ -28,7 +28,7 @@ IN: bootstrap.x86 [ ! load entry point - safe-reg -7 [] LEA + safe-reg 0 MOV rc-absolute-cell rt-this jit-rel ! save stack frame size stack-frame-size PUSH ! push entry point From c08fa9cb6e4eb19739a6a3674c819553f6b78527 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 6 Feb 2010 00:45:06 -0600 Subject: [PATCH 06/10] vm: disable silly nano-count workaround on Win64, fix some indentation issues --- vm/io.cpp | 37 +++++++++++++++---------------------- vm/os-windows-nt.cpp | 14 +++++++++----- vm/os-windows.cpp | 4 ++-- 3 files changed, 26 insertions(+), 29 deletions(-) diff --git a/vm/io.cpp b/vm/io.cpp index ae27b5a3d8..8eaaa453b5 100755 --- a/vm/io.cpp +++ b/vm/io.cpp @@ -154,7 +154,7 @@ void factor_vm::primitive_fopen() FILE *file; file = safe_fopen((char *)(path.untagged() + 1), - (char *)(mode.untagged() + 1)); + (char *)(mode.untagged() + 1)); ctx->push(allot_alien(file)); } @@ -187,31 +187,24 @@ void factor_vm::primitive_fread() data_root buf(allot_uninitialized_array(size),this); - for(;;) + int c = safe_fread(buf.untagged() + 1,1,size,file); + if(c == 0) { - int c = safe_fread(buf.untagged() + 1,1,size,file); - if(c == 0) - { - if(feof(file)) - { - ctx->push(false_object); - break; - } - else - io_error(); - } + if(feof(file)) + ctx->push(false_object); else + io_error(); + } + else + { + if(feof(file)) { - if(feof(file)) - { - byte_array *new_buf = allot_byte_array(c); - memcpy(new_buf + 1, buf.untagged() + 1,c); - buf = new_buf; - } - - ctx->push(buf.value()); - break; + byte_array *new_buf = allot_byte_array(c); + memcpy(new_buf + 1, buf.untagged() + 1,c); + buf = new_buf; } + + ctx->push(buf.value()); } } diff --git a/vm/os-windows-nt.cpp b/vm/os-windows-nt.cpp index cf5878e5bf..644ff83b44 100755 --- a/vm/os-windows-nt.cpp +++ b/vm/os-windows-nt.cpp @@ -37,8 +37,6 @@ u64 system_micros() - EPOCH_OFFSET) / 10; } -/* On VirtualBox, QueryPerformanceCounter does not increment -the high part every time the low part overflows. Workaround. */ u64 nano_count() { LARGE_INTEGER count; @@ -53,8 +51,14 @@ u64 nano_count() if(ret == 0) fatal_error("QueryPerformanceFrequency", 0); - if(count.LowPart < lo) - hi += 1; +#ifdef FACTOR_64 + hi = count.HighPart; +#else + /* On VirtualBox, QueryPerformanceCounter does not increment + the high part every time the low part overflows. Workaround. */ + if(lo > count.LowPart) + hi++; +#endif lo = count.LowPart; return (u64)((((u64)hi << 32) | (u64)lo)*(1000000000.0/frequency.QuadPart)); @@ -91,7 +95,7 @@ LONG factor_vm::exception_handler(PEXCEPTION_POINTERS pe) case STATUS_FLOAT_UNDERFLOW: case STATUS_FLOAT_MULTIPLE_FAULTS: case STATUS_FLOAT_MULTIPLE_TRAPS: -#ifdef FACTOR_AMD64 +#ifdef FACTOR_64 signal_fpu_status = fpu_status(MXCSR(c)); #else signal_fpu_status = fpu_status(X87SW(c) | MXCSR(c)); diff --git a/vm/os-windows.cpp b/vm/os-windows.cpp index a6914a9f70..08f5932172 100755 --- a/vm/os-windows.cpp +++ b/vm/os-windows.cpp @@ -128,7 +128,7 @@ segment::~segment() long getpagesize() { static long g_pagesize = 0; - if (! g_pagesize) + if(!g_pagesize) { SYSTEM_INFO system_info; GetSystemInfo (&system_info); @@ -139,7 +139,7 @@ long getpagesize() void factor_vm::move_file(const vm_char *path1, const vm_char *path2) { - if(MoveFileEx((path1),(path2),MOVEFILE_REPLACE_EXISTING) == false) + if(MoveFileEx((path1),(path2),MOVEFILE_REPLACE_EXISTING) == false) general_error(ERROR_IO,tag_fixnum(GetLastError()),false_object,NULL); } From d22eb403605bf38c6379571ca237b02defaf8725 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 6 Feb 2010 01:06:26 -0600 Subject: [PATCH 07/10] Fix spaces that crept into vm/ cpp files --- vm/Config.macosx | 2 +- vm/bignumint.hpp | 2 +- vm/cpu-ppc.hpp | 14 +++++++------- vm/cpu-x86.hpp | 14 +++++++------- vm/data_heap.cpp | 2 +- vm/full_collector.cpp | 2 +- vm/gc.hpp | 2 +- vm/jit.hpp | 2 +- vm/math.cpp | 2 +- vm/os-freebsd-x86.32.hpp | 16 ++++++++-------- vm/os-freebsd-x86.64.hpp | 12 ++++++------ vm/os-linux-x86.64.hpp | 12 ++++++------ vm/os-windows-nt.cpp | 8 ++++---- vm/vm.hpp | 14 +++++++------- 14 files changed, 52 insertions(+), 52 deletions(-) diff --git a/vm/Config.macosx b/vm/Config.macosx index 07629f72bb..89fe239668 100644 --- a/vm/Config.macosx +++ b/vm/Config.macosx @@ -11,7 +11,7 @@ SHARED_FLAG = -dynamiclib ifdef X11 LIBS = -lm -framework Cocoa -L/opt/local/lib $(X11_UI_LIBS) -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib else - LIBS = -lm -framework Cocoa -framework AppKit + LIBS = -lm -framework Cocoa -framework AppKit endif LINKER = $(CPP) $(CFLAGS) -dynamiclib -single_module -std=gnu99 \ diff --git a/vm/bignumint.hpp b/vm/bignumint.hpp index 57c71959c3..ff0d86a681 100644 --- a/vm/bignumint.hpp +++ b/vm/bignumint.hpp @@ -96,7 +96,7 @@ typedef fixnum bignum_length_type; #define BIGNUM_ASSERT(expression) \ { \ if (! (expression)) \ - BIGNUM_EXCEPTION (); \ + BIGNUM_EXCEPTION (); \ } #endif /* not BIGNUM_DISABLE_ASSERTION_CHECKS */ diff --git a/vm/cpu-ppc.hpp b/vm/cpu-ppc.hpp index d284cbce78..d09fc173ea 100644 --- a/vm/cpu-ppc.hpp +++ b/vm/cpu-ppc.hpp @@ -58,20 +58,20 @@ inline static bool tail_call_site_p(cell return_address) inline static unsigned int fpu_status(unsigned int status) { - unsigned int r = 0; + unsigned int r = 0; - if (status & 0x20000000) + if (status & 0x20000000) r |= FP_TRAP_INVALID_OPERATION; - if (status & 0x10000000) + if (status & 0x10000000) r |= FP_TRAP_OVERFLOW; - if (status & 0x08000000) + if (status & 0x08000000) r |= FP_TRAP_UNDERFLOW; - if (status & 0x04000000) + if (status & 0x04000000) r |= FP_TRAP_ZERO_DIVIDE; - if (status & 0x02000000) + if (status & 0x02000000) r |= FP_TRAP_INEXACT; - return r; + return r; } /* Defined in assembly */ diff --git a/vm/cpu-x86.hpp b/vm/cpu-x86.hpp index 5f9fa15740..ac8ac51ade 100644 --- a/vm/cpu-x86.hpp +++ b/vm/cpu-x86.hpp @@ -55,20 +55,20 @@ inline static bool tail_call_site_p(cell return_address) inline static unsigned int fpu_status(unsigned int status) { - unsigned int r = 0; + unsigned int r = 0; - if (status & 0x01) + if (status & 0x01) r |= FP_TRAP_INVALID_OPERATION; - if (status & 0x04) + if (status & 0x04) r |= FP_TRAP_ZERO_DIVIDE; - if (status & 0x08) + if (status & 0x08) r |= FP_TRAP_OVERFLOW; - if (status & 0x10) + if (status & 0x10) r |= FP_TRAP_UNDERFLOW; - if (status & 0x20) + if (status & 0x20) r |= FP_TRAP_INEXACT; - return r; + return r; } } diff --git a/vm/data_heap.cpp b/vm/data_heap.cpp index d1809f09ce..22ef39e868 100755 --- a/vm/data_heap.cpp +++ b/vm/data_heap.cpp @@ -201,7 +201,7 @@ cell object::binary_payload_start() const return sizeof(wrapper); default: critical_error("Invalid header",(cell)this); - return 0; /* can't happen */ + return 0; /* can't happen */ } } diff --git a/vm/full_collector.cpp b/vm/full_collector.cpp index ec0972e952..849ef07084 100644 --- a/vm/full_collector.cpp +++ b/vm/full_collector.cpp @@ -67,7 +67,7 @@ void factor_vm::collect_mark_impl(bool trace_contexts_p) data->tenured->clear_mark_bits(); collector.trace_roots(); - if(trace_contexts_p) + if(trace_contexts_p) { collector.trace_contexts(); collector.trace_context_code_blocks(); diff --git a/vm/gc.hpp b/vm/gc.hpp index d80d57dafe..5224dec3e2 100755 --- a/vm/gc.hpp +++ b/vm/gc.hpp @@ -45,7 +45,7 @@ struct gc_event { struct gc_state { gc_op op; u64 start_time; - jmp_buf gc_unwind; + jmp_buf gc_unwind; gc_event *event; explicit gc_state(gc_op op_, factor_vm *parent); diff --git a/vm/jit.hpp b/vm/jit.hpp index 3889d92fc5..a9716cab79 100644 --- a/vm/jit.hpp +++ b/vm/jit.hpp @@ -61,7 +61,7 @@ struct jit { return position; } - void set_position(fixnum position_) + void set_position(fixnum position_) { if(computing_offset_p) position = position_; diff --git a/vm/math.cpp b/vm/math.cpp index ef4a599331..2ff6f28d2a 100755 --- a/vm/math.cpp +++ b/vm/math.cpp @@ -168,7 +168,7 @@ void factor_vm::primitive_bignum_xor() void factor_vm::primitive_bignum_shift() { fixnum y = untag_fixnum(ctx->pop()); - bignum* x = untag(ctx->pop()); + bignum* x = untag(ctx->pop()); ctx->push(tag(bignum_arithmetic_shift(x,y))); } diff --git a/vm/os-freebsd-x86.32.hpp b/vm/os-freebsd-x86.32.hpp index 5ed5cf0e81..664da1e997 100644 --- a/vm/os-freebsd-x86.32.hpp +++ b/vm/os-freebsd-x86.32.hpp @@ -6,35 +6,35 @@ namespace factor inline static unsigned int uap_fpu_status(void *uap) { - ucontext_t *ucontext = (ucontext_t *)uap; - if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_387) + ucontext_t *ucontext = (ucontext_t *)uap; + if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_387) { struct save87 *x87 = (struct save87 *)(&ucontext->uc_mcontext.mc_fpstate); return x87->sv_env.en_sw; - } + } else if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM) { struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate); return xmm->sv_env.en_sw | xmm->sv_env.en_mxcsr; - } + } else return 0; } inline static void uap_clear_fpu_status(void *uap) { - ucontext_t *ucontext = (ucontext_t *)uap; - if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_387) + ucontext_t *ucontext = (ucontext_t *)uap; + if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_387) { struct save87 *x87 = (struct save87 *)(&ucontext->uc_mcontext.mc_fpstate); x87->sv_env.en_sw = 0; - } + } else if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM) { struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate); xmm->sv_env.en_sw = 0; xmm->sv_env.en_mxcsr &= 0xffffffc0; - } + } } diff --git a/vm/os-freebsd-x86.64.hpp b/vm/os-freebsd-x86.64.hpp index 02f7fb3ad2..c691409dd1 100644 --- a/vm/os-freebsd-x86.64.hpp +++ b/vm/os-freebsd-x86.64.hpp @@ -6,25 +6,25 @@ namespace factor inline static unsigned int uap_fpu_status(void *uap) { - ucontext_t *ucontext = (ucontext_t *)uap; - if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM) + ucontext_t *ucontext = (ucontext_t *)uap; + if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM) { struct savefpu *xmm = (struct savefpu *)(&ucontext->uc_mcontext.mc_fpstate); return xmm->sv_env.en_sw | xmm->sv_env.en_mxcsr; - } + } else return 0; } inline static void uap_clear_fpu_status(void *uap) { - ucontext_t *ucontext = (ucontext_t *)uap; - if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM) + ucontext_t *ucontext = (ucontext_t *)uap; + if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM) { struct savefpu *xmm = (struct savefpu *)(&ucontext->uc_mcontext.mc_fpstate); xmm->sv_env.en_sw = 0; xmm->sv_env.en_mxcsr &= 0xffffffc0; - } + } } diff --git a/vm/os-linux-x86.64.hpp b/vm/os-linux-x86.64.hpp index 14ba9fb002..7d764d61e3 100644 --- a/vm/os-linux-x86.64.hpp +++ b/vm/os-linux-x86.64.hpp @@ -5,16 +5,16 @@ namespace factor inline static unsigned int uap_fpu_status(void *uap) { - ucontext_t *ucontext = (ucontext_t *)uap; - return ucontext->uc_mcontext.fpregs->swd - | ucontext->uc_mcontext.fpregs->mxcsr; + ucontext_t *ucontext = (ucontext_t *)uap; + return ucontext->uc_mcontext.fpregs->swd + | ucontext->uc_mcontext.fpregs->mxcsr; } inline static void uap_clear_fpu_status(void *uap) { - ucontext_t *ucontext = (ucontext_t *)uap; - ucontext->uc_mcontext.fpregs->swd = 0; - ucontext->uc_mcontext.fpregs->mxcsr &= 0xffffffc0; + ucontext_t *ucontext = (ucontext_t *)uap; + ucontext->uc_mcontext.fpregs->swd = 0; + ucontext->uc_mcontext.fpregs->mxcsr &= 0xffffffc0; } #define UAP_STACK_POINTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.gregs[15]) diff --git a/vm/os-windows-nt.cpp b/vm/os-windows-nt.cpp index 644ff83b44..07d428fb49 100755 --- a/vm/os-windows-nt.cpp +++ b/vm/os-windows-nt.cpp @@ -79,12 +79,12 @@ LONG factor_vm::exception_handler(PEXCEPTION_POINTERS pe) else signal_callstack_top = NULL; - switch (e->ExceptionCode) - { - case EXCEPTION_ACCESS_VIOLATION: + switch (e->ExceptionCode) + { + case EXCEPTION_ACCESS_VIOLATION: signal_fault_addr = e->ExceptionInformation[1]; c->EIP = (cell)factor::memory_signal_handler_impl; - break; + break; case STATUS_FLOAT_DENORMAL_OPERAND: case STATUS_FLOAT_DIVIDE_BY_ZERO: diff --git a/vm/vm.hpp b/vm/vm.hpp index 5d9b3204d3..20a837a58a 100755 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -184,20 +184,20 @@ struct factor_vm void bignum_destructive_add(bignum * bignum, bignum_digit_type n); void bignum_destructive_scale_up(bignum * bignum, bignum_digit_type factor); void bignum_divide_unsigned_large_denominator(bignum * numerator, bignum * denominator, - bignum * * quotient, bignum * * remainder, int q_negative_p, int r_negative_p); + bignum * * quotient, bignum * * remainder, int q_negative_p, int r_negative_p); void bignum_divide_unsigned_normalized(bignum * u, bignum * v, bignum * q); bignum_digit_type bignum_divide_subtract(bignum_digit_type * v_start, bignum_digit_type * v_end, - bignum_digit_type guess, bignum_digit_type * u_start); + bignum_digit_type guess, bignum_digit_type * u_start); void bignum_divide_unsigned_medium_denominator(bignum * numerator,bignum_digit_type denominator, - bignum * * quotient, bignum * * remainder,int q_negative_p, int r_negative_p); + bignum * * quotient, bignum * * remainder,int q_negative_p, int r_negative_p); void bignum_destructive_normalization(bignum * source, bignum * target, int shift_left); void bignum_destructive_unnormalization(bignum * bignum, int shift_right); bignum_digit_type bignum_digit_divide(bignum_digit_type uh, bignum_digit_type ul, - bignum_digit_type v, bignum_digit_type * q) /* return value */; + bignum_digit_type v, bignum_digit_type * q) /* return value */; bignum_digit_type bignum_digit_divide_subtract(bignum_digit_type v1, bignum_digit_type v2, - bignum_digit_type guess, bignum_digit_type * u); + bignum_digit_type guess, bignum_digit_type * u); void bignum_divide_unsigned_small_denominator(bignum * numerator, bignum_digit_type denominator, - bignum * * quotient, bignum * * remainder,int q_negative_p, int r_negative_p); + bignum * * quotient, bignum * * remainder,int q_negative_p, int r_negative_p); bignum_digit_type bignum_destructive_scale_down(bignum * bignum, bignum_digit_type denominator); bignum * bignum_remainder_unsigned_small_denominator(bignum * n, bignum_digit_type d, int negative_p); bignum *bignum_digit_to_bignum(bignum_digit_type digit, int negative_p); @@ -314,7 +314,7 @@ struct factor_vm if(!(current_gc && current_gc->op == collect_growing_heap_op)) { assert((cell)pointer >= data->seg->start - && (cell)pointer < data->seg->end); + && (cell)pointer < data->seg->end); } #endif } From 1af9b684958cba39a2261f0a863402e85736f366 Mon Sep 17 00:00:00 2001 From: erikc Date: Fri, 5 Feb 2010 23:50:58 -0800 Subject: [PATCH 08/10] Don't FEP on unhandled case for WM_APPCOMMAND --- basis/ui/backend/windows/windows.factor | 1 + 1 file changed, 1 insertion(+) diff --git a/basis/ui/backend/windows/windows.factor b/basis/ui/backend/windows/windows.factor index fdd3c06c29..69b09dcba0 100644 --- a/basis/ui/backend/windows/windows.factor +++ b/basis/ui/backend/windows/windows.factor @@ -502,6 +502,7 @@ SYMBOL: nc-buttons { { APPCOMMAND_BROWSER_BACKWARD [ pick window left-action send-action ] } { APPCOMMAND_BROWSER_FORWARD [ pick window right-action send-action ] } + [ drop ] } case 3drop ; : handle-wm-buttondown ( hWnd uMsg wParam lParam -- ) From e2500c14d266a9d19bf89d0fcb296de64c2e2f5c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 7 Feb 2010 18:17:53 +1300 Subject: [PATCH 09/10] io.launcher.unix: sometimes both WIFEXITED and WIFSIGNALED would return true, and the wrong status would be reported --- basis/io/launcher/unix/unix-tests.factor | 4 ++-- basis/io/launcher/unix/unix.factor | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/basis/io/launcher/unix/unix-tests.factor b/basis/io/launcher/unix/unix-tests.factor index 4304f5f62a..bb7569516a 100644 --- a/basis/io/launcher/unix/unix-tests.factor +++ b/basis/io/launcher/unix/unix-tests.factor @@ -3,7 +3,7 @@ USING: io.files io.files.temp io.directories io.pathnames tools.test io.launcher arrays io namespaces continuations math io.encodings.binary io.encodings.ascii accessors kernel sequences io.encodings.utf8 destructors io.streams.duplex locals -concurrency.promises threads unix.process calendar ; +concurrency.promises threads unix.process calendar unix ; [ ] [ [ "launcher-test-1" temp-file delete-file ] ignore-errors @@ -134,7 +134,7 @@ concurrency.promises threads unix.process calendar ; [ p fulfill ] [ wait-for-process s fulfill ] bi ] in-thread - p 1 seconds ?promise-timeout handle>> 9 kill drop + p 1 seconds ?promise-timeout handle>> kill-process* s ?promise 0 = ] ] unit-test diff --git a/basis/io/launcher/unix/unix.factor b/basis/io/launcher/unix/unix.factor index 28c805a528..d8b55d3d17 100644 --- a/basis/io/launcher/unix/unix.factor +++ b/basis/io/launcher/unix/unix.factor @@ -91,7 +91,7 @@ M: unix kill-process* ( pid -- ) TUPLE: signal n ; : code>status ( code -- obj ) - dup WIFEXITED [ WEXITSTATUS ] [ WTERMSIG signal boa ] if ; + dup WIFSIGNALED [ WTERMSIG signal boa ] [ WEXITSTATUS ] if ; M: unix wait-for-processes ( -- ? ) 0 -1 over WNOHANG waitpid From 83674821a102b4530f60d00cf14d685f698382b2 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 7 Feb 2010 18:20:54 +1300 Subject: [PATCH 10/10] ui.text: fix outdated material --- basis/ui/text/text-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/ui/text/text-docs.factor b/basis/ui/text/text-docs.factor index 492ab76a13..8b3b5ad24f 100644 --- a/basis/ui/text/text-docs.factor +++ b/basis/ui/text/text-docs.factor @@ -49,7 +49,7 @@ HELP: line-metrics { $contract "Outputs a " { $link metrics } " object with text measurements." } ; ARTICLE: "text-rendering" "Rendering text" -"The " { $vocab-link "ui.text" } " vocabulary provides a cross-platform interface to the operating system's native font rendering engine. Currently, it uses Core Text on Mac OS X and FreeType on Windows and X11." +"The " { $vocab-link "ui.text" } " vocabulary provides a cross-platform interface to the operating system's native font rendering engine. Currently, it uses Core Text on Mac OS X, Uniscribe on Windows and Pango on X11." { $subsections "fonts" } "Measuring text:" { $subsections