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
|
||||
combinators.short-circuit concurrency.promises continuations
|
||||
destructors fry kernel literals math models namespaces opengl
|
||||
opengl.capabilities opengl.textures sequences strings ui.backend
|
||||
ui.gadgets ui.gadgets.tracks ui.gestures ui.pixel-formats
|
||||
opengl.capabilities opengl.gl opengl.textures sequences strings
|
||||
ui.backend ui.gadgets ui.gadgets.tracks ui.gestures ui.pixel-formats
|
||||
ui.render ;
|
||||
IN: ui.gadgets.worlds
|
||||
|
||||
|
@ -187,10 +187,8 @@ M: world dim<<
|
|||
GENERIC: draw-world* ( world -- )
|
||||
|
||||
M: world draw-world*
|
||||
check-extensions
|
||||
"1.0" require-gl-version
|
||||
{
|
||||
[ init-gl ]
|
||||
[ gl-draw-init ]
|
||||
[ draw-gadget ]
|
||||
[ text-handle>> [ purge-cache ] when* ]
|
||||
[ images>> [ purge-cache ] when* ]
|
||||
|
|
|
@ -1,14 +1,22 @@
|
|||
USING: ui.gadgets ui.pens ui.gestures help.markup help.syntax
|
||||
kernel classes strings opengl opengl.gl models
|
||||
math.rectangles math colors ;
|
||||
USING: help.markup help.syntax math.rectangles models opengl.gl
|
||||
ui.gadgets ui.gadgets.worlds ui.gestures ui.pens ;
|
||||
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
|
||||
{ $class-description "An object which displays itself on the screen and acts on user input gestures. Gadgets have the following slots:"
|
||||
{ $list
|
||||
{ { $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 "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 "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." }
|
||||
|
@ -22,13 +30,9 @@ HELP: gadget
|
|||
{ $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 } "." } ;
|
||||
|
||||
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: gl-draw-init
|
||||
{ $values { "world" world } }
|
||||
{ $description "Does some OpenGL setup that is required each time the world is to be redrawn." } ;
|
||||
|
||||
ARTICLE: "ui-paint" "Customizing gadget appearance"
|
||||
"The UI carries out the following steps when drawing a gadget:"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
! Copyright (C) 2005, 2009 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: math.rectangles math.vectors namespaces kernel accessors
|
||||
assocs combinators sequences sets opengl opengl.gl colors
|
||||
colors.constants ui.gadgets ui.pens ;
|
||||
USING: accessors colors colors.constants combinators kernel
|
||||
math.rectangles math.vectors namespaces opengl opengl.capabilities
|
||||
opengl.gl opengl.textures sequences sets ui.gadgets ui.pens ;
|
||||
IN: ui.render
|
||||
|
||||
SYMBOL: clip
|
||||
|
@ -17,7 +17,7 @@ SYMBOL: viewport-translation
|
|||
|
||||
: do-clip ( -- ) clip get flip-rect gl-set-clip ;
|
||||
|
||||
: init-clip ( clip-rect -- )
|
||||
: init-clip ( gadget -- )
|
||||
[
|
||||
dim>>
|
||||
[ { 0 1 } v* viewport-translation set ]
|
||||
|
@ -29,14 +29,17 @@ SYMBOL: viewport-translation
|
|||
|
||||
SLOT: background-color
|
||||
|
||||
: init-gl ( world -- )
|
||||
: gl-init ( -- )
|
||||
check-extensions "1.0" require-gl-version
|
||||
GL_SMOOTH glShadeModel
|
||||
GL_SCISSOR_TEST glEnable
|
||||
GL_BLEND glEnable
|
||||
GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA glBlendFunc
|
||||
GL_VERTEX_ARRAY glEnableClientState
|
||||
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-clip ]
|
||||
[
|
||||
|
|
|
@ -35,6 +35,10 @@ HELP: set-fullscreen
|
|||
{ $values { "gadget" gadget } { "?" boolean } }
|
||||
{ $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?
|
||||
{ $values { "gadget" gadget } { "?" boolean } }
|
||||
{ $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
|
||||
classes.tuple.parser combinators combinators.short-circuit
|
||||
concurrency.flags concurrency.promises continuations deques
|
||||
destructors dlists fry init kernel lexer make math namespaces parser
|
||||
sequences sets strings threads ui.backend ui.gadgets
|
||||
ui.gadgets.private ui.gadgets.worlds ui.gestures vectors vocabs.parser
|
||||
words ;
|
||||
destructors dlists fry init io.streams.c kernel lexer make math
|
||||
namespaces parser sequences sets strings threads ui.backend ui.gadgets
|
||||
ui.gadgets.private ui.gadgets.worlds ui.gestures ui.render vectors
|
||||
vocabs.parser words ;
|
||||
IN: ui
|
||||
|
||||
<PRIVATE
|
||||
|
@ -65,7 +65,7 @@ SYMBOL: ui-windows
|
|||
[ begin-world ]
|
||||
[ resize-world ]
|
||||
[ request-focus ]
|
||||
} cleave ;
|
||||
} cleave gl-init ;
|
||||
|
||||
: clean-up-broken-window ( world -- )
|
||||
[
|
||||
|
|
Loading…
Reference in New Issue