ui.*: move some of the gl initing to set-up-window, should fix #1510
it's also more efficent to run the check-extensions "1.0" require-gl-version code only once when the window is created, rather than once for each drawdb4
parent
7bc0718d34
commit
763b892a1d
|
@ -3,8 +3,8 @@
|
||||||
USING: accessors assocs cache colors combinators
|
USING: accessors assocs cache colors combinators
|
||||||
combinators.short-circuit concurrency.promises continuations
|
combinators.short-circuit concurrency.promises continuations
|
||||||
destructors fry kernel literals math models namespaces opengl
|
destructors fry kernel literals math models namespaces opengl
|
||||||
opengl.capabilities opengl.textures sequences strings ui.backend
|
opengl.capabilities opengl.gl opengl.textures sequences strings
|
||||||
ui.gadgets ui.gadgets.tracks ui.gestures ui.pixel-formats
|
ui.backend ui.gadgets ui.gadgets.tracks ui.gestures ui.pixel-formats
|
||||||
ui.render ;
|
ui.render ;
|
||||||
IN: ui.gadgets.worlds
|
IN: ui.gadgets.worlds
|
||||||
|
|
||||||
|
@ -187,10 +187,8 @@ M: world dim<<
|
||||||
GENERIC: draw-world* ( world -- )
|
GENERIC: draw-world* ( world -- )
|
||||||
|
|
||||||
M: world draw-world*
|
M: world draw-world*
|
||||||
check-extensions
|
|
||||||
"1.0" require-gl-version
|
|
||||||
{
|
{
|
||||||
[ init-gl ]
|
[ gl-draw-init ]
|
||||||
[ draw-gadget ]
|
[ draw-gadget ]
|
||||||
[ text-handle>> [ purge-cache ] when* ]
|
[ text-handle>> [ purge-cache ] when* ]
|
||||||
[ images>> [ purge-cache ] when* ]
|
[ images>> [ purge-cache ] when* ]
|
||||||
|
|
|
@ -1,14 +1,22 @@
|
||||||
USING: ui.gadgets ui.pens ui.gestures help.markup help.syntax
|
USING: help.markup help.syntax math.rectangles models opengl.gl
|
||||||
kernel classes strings opengl opengl.gl models
|
ui.gadgets ui.gadgets.worlds ui.gestures ui.pens ;
|
||||||
math.rectangles math colors ;
|
|
||||||
IN: ui.render
|
IN: ui.render
|
||||||
|
|
||||||
|
HELP: clip
|
||||||
|
{ $var-description "The current clipping rectangle." } ;
|
||||||
|
|
||||||
|
HELP: draw-gadget*
|
||||||
|
{ $values { "gadget" gadget } }
|
||||||
|
{ $contract "Draws the gadget by making OpenGL calls. The top-left corner of the gadget should be drawn at the location stored in the " { $link origin } " variable." }
|
||||||
|
{ $notes "This word should not be called directly. To force a gadget to redraw, call " { $link relayout-1 } "." } ;
|
||||||
|
|
||||||
HELP: gadget
|
HELP: gadget
|
||||||
{ $class-description "An object which displays itself on the screen and acts on user input gestures. Gadgets have the following slots:"
|
{ $class-description "An object which displays itself on the screen and acts on user input gestures. Gadgets have the following slots:"
|
||||||
{ $list
|
{ $list
|
||||||
{ { $snippet "pref-dim" } " - a cached value for " { $link pref-dim } "; do not read or write this slot directly." }
|
{ { $snippet "pref-dim" } " - a cached value for " { $link pref-dim } "; do not read or write this slot directly." }
|
||||||
{ { $snippet "parent" } " - the gadget containing this one, or " { $link f } " if this gadget is not part of the visible gadget hierarchy." }
|
{ { $snippet "parent" } " - the gadget containing this one, or " { $link f } " if this gadget is not part of the visible gadget hierarchy." }
|
||||||
{ { $snippet "children" } " - a vector of child gadgets. Do not modify this vector directly, instead use " { $link add-gadget } ", " { $link add-gadgets } ", " { $link unparent } " or " { $link clear-gadget } "." }
|
{ { $snippet "children" } " - a vector of child gadgets. Do not modify this vector directly, instead use " { $link add-gadget } ", " { $link add-gadgets } ", " { $link unparent } " or " { $link clear-gadget } "." }
|
||||||
|
{ { $snippet "graft-state" } { "This two tuple represents the current graft state of the gadget and what its next state will become." } }
|
||||||
{ { $snippet "orientation" } " - an orientation specifier. This slot is used by layout gadgets." }
|
{ { $snippet "orientation" } " - an orientation specifier. This slot is used by layout gadgets." }
|
||||||
{ { $snippet "layout-state" } " - stores the layout state of the gadget. Do not read or write this slot directly, instead call " { $link relayout } " and " { $link relayout-1 } " if the gadget needs to be re-laid out." }
|
{ { $snippet "layout-state" } " - stores the layout state of the gadget. Do not read or write this slot directly, instead call " { $link relayout } " and " { $link relayout-1 } " if the gadget needs to be re-laid out." }
|
||||||
{ { $snippet "visible?" } " - a boolean indicating if the gadget should display and receive user input." }
|
{ { $snippet "visible?" } " - a boolean indicating if the gadget should display and receive user input." }
|
||||||
|
@ -22,13 +30,9 @@ HELP: gadget
|
||||||
{ $notes
|
{ $notes
|
||||||
"Other classes may inherit from " { $link gadget } " in order to re-implement generic words such as " { $link draw-gadget* } " and " { $link user-input* } ", or to define gestures with " { $link set-gestures } "." } ;
|
"Other classes may inherit from " { $link gadget } " in order to re-implement generic words such as " { $link draw-gadget* } " and " { $link user-input* } ", or to define gestures with " { $link set-gestures } "." } ;
|
||||||
|
|
||||||
HELP: clip
|
HELP: gl-draw-init
|
||||||
{ $var-description "The current clipping rectangle." } ;
|
{ $values { "world" world } }
|
||||||
|
{ $description "Does some OpenGL setup that is required each time the world is to be redrawn." } ;
|
||||||
HELP: draw-gadget*
|
|
||||||
{ $values { "gadget" gadget } }
|
|
||||||
{ $contract "Draws the gadget by making OpenGL calls. The top-left corner of the gadget should be drawn at the location stored in the " { $link origin } " variable." }
|
|
||||||
{ $notes "This word should not be called directly. To force a gadget to redraw, call " { $link relayout-1 } "." } ;
|
|
||||||
|
|
||||||
ARTICLE: "ui-paint" "Customizing gadget appearance"
|
ARTICLE: "ui-paint" "Customizing gadget appearance"
|
||||||
"The UI carries out the following steps when drawing a gadget:"
|
"The UI carries out the following steps when drawing a gadget:"
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
! Copyright (C) 2005, 2009 Slava Pestov.
|
! Copyright (C) 2005, 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: math.rectangles math.vectors namespaces kernel accessors
|
USING: accessors colors colors.constants combinators kernel
|
||||||
assocs combinators sequences sets opengl opengl.gl colors
|
math.rectangles math.vectors namespaces opengl opengl.capabilities
|
||||||
colors.constants ui.gadgets ui.pens ;
|
opengl.gl opengl.textures sequences sets ui.gadgets ui.pens ;
|
||||||
IN: ui.render
|
IN: ui.render
|
||||||
|
|
||||||
SYMBOL: clip
|
SYMBOL: clip
|
||||||
|
@ -17,7 +17,7 @@ SYMBOL: viewport-translation
|
||||||
|
|
||||||
: do-clip ( -- ) clip get flip-rect gl-set-clip ;
|
: do-clip ( -- ) clip get flip-rect gl-set-clip ;
|
||||||
|
|
||||||
: init-clip ( clip-rect -- )
|
: init-clip ( gadget -- )
|
||||||
[
|
[
|
||||||
dim>>
|
dim>>
|
||||||
[ { 0 1 } v* viewport-translation set ]
|
[ { 0 1 } v* viewport-translation set ]
|
||||||
|
@ -29,14 +29,17 @@ SYMBOL: viewport-translation
|
||||||
|
|
||||||
SLOT: background-color
|
SLOT: background-color
|
||||||
|
|
||||||
: init-gl ( world -- )
|
: gl-init ( -- )
|
||||||
|
check-extensions "1.0" require-gl-version
|
||||||
GL_SMOOTH glShadeModel
|
GL_SMOOTH glShadeModel
|
||||||
GL_SCISSOR_TEST glEnable
|
|
||||||
GL_BLEND glEnable
|
GL_BLEND glEnable
|
||||||
GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA glBlendFunc
|
GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA glBlendFunc
|
||||||
GL_VERTEX_ARRAY glEnableClientState
|
GL_VERTEX_ARRAY glEnableClientState
|
||||||
GL_PACK_ALIGNMENT 1 glPixelStorei
|
GL_PACK_ALIGNMENT 1 glPixelStorei
|
||||||
GL_UNPACK_ALIGNMENT 1 glPixelStorei
|
GL_UNPACK_ALIGNMENT 1 glPixelStorei ;
|
||||||
|
|
||||||
|
: gl-draw-init ( world -- )
|
||||||
|
GL_SCISSOR_TEST glEnable
|
||||||
init-matrices
|
init-matrices
|
||||||
[ init-clip ]
|
[ init-clip ]
|
||||||
[
|
[
|
||||||
|
|
|
@ -35,6 +35,10 @@ HELP: set-fullscreen
|
||||||
{ $values { "gadget" gadget } { "?" boolean } }
|
{ $values { "gadget" gadget } { "?" boolean } }
|
||||||
{ $description "Sets and unsets fullscreen mode for the gadget's world." } ;
|
{ $description "Sets and unsets fullscreen mode for the gadget's world." } ;
|
||||||
|
|
||||||
|
HELP: set-up-window
|
||||||
|
{ $values { "world" world } }
|
||||||
|
{ $description "Initializes the window that shows the world." } ;
|
||||||
|
|
||||||
HELP: fullscreen?
|
HELP: fullscreen?
|
||||||
{ $values { "gadget" gadget } { "?" boolean } }
|
{ $values { "gadget" gadget } { "?" boolean } }
|
||||||
{ $description "Queries the gadget's world to see if it is running in fullscreen mode." } ;
|
{ $description "Queries the gadget's world to see if it is running in fullscreen mode." } ;
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
USING: accessors arrays assocs boxes classes.tuple
|
USING: accessors arrays assocs boxes classes.tuple
|
||||||
classes.tuple.parser combinators combinators.short-circuit
|
classes.tuple.parser combinators combinators.short-circuit
|
||||||
concurrency.flags concurrency.promises continuations deques
|
concurrency.flags concurrency.promises continuations deques
|
||||||
destructors dlists fry init kernel lexer make math namespaces parser
|
destructors dlists fry init io.streams.c kernel lexer make math
|
||||||
sequences sets strings threads ui.backend ui.gadgets
|
namespaces parser sequences sets strings threads ui.backend ui.gadgets
|
||||||
ui.gadgets.private ui.gadgets.worlds ui.gestures vectors vocabs.parser
|
ui.gadgets.private ui.gadgets.worlds ui.gestures ui.render vectors
|
||||||
words ;
|
vocabs.parser words ;
|
||||||
IN: ui
|
IN: ui
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
@ -65,7 +65,7 @@ SYMBOL: ui-windows
|
||||||
[ begin-world ]
|
[ begin-world ]
|
||||||
[ resize-world ]
|
[ resize-world ]
|
||||||
[ request-focus ]
|
[ request-focus ]
|
||||||
} cleave ;
|
} cleave gl-init ;
|
||||||
|
|
||||||
: clean-up-broken-window ( world -- )
|
: clean-up-broken-window ( world -- )
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in New Issue