From 9d02d38f182bb60df7aac97159e5bbe53a7d0e19 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 15 Jul 2009 22:44:03 -0500 Subject: [PATCH] gl-break word and interactive debugging aids --- basis/opengl/debug/authors.txt | 1 + basis/opengl/debug/debug-docs.factor | 36 ++++++++++++++++++++++++++++ basis/opengl/debug/debug.factor | 23 ++++++++++++++++++ basis/opengl/debug/summary.txt | 1 + 4 files changed, 61 insertions(+) create mode 100644 basis/opengl/debug/authors.txt create mode 100644 basis/opengl/debug/debug-docs.factor create mode 100644 basis/opengl/debug/debug.factor create mode 100644 basis/opengl/debug/summary.txt diff --git a/basis/opengl/debug/authors.txt b/basis/opengl/debug/authors.txt new file mode 100644 index 0000000000..f13c9c1e77 --- /dev/null +++ b/basis/opengl/debug/authors.txt @@ -0,0 +1 @@ +Joe Groff diff --git a/basis/opengl/debug/debug-docs.factor b/basis/opengl/debug/debug-docs.factor new file mode 100644 index 0000000000..7cb8f9b246 --- /dev/null +++ b/basis/opengl/debug/debug-docs.factor @@ -0,0 +1,36 @@ +! (c)2009 Joe Groff bsd license +USING: help.markup help.syntax multiline tools.continuations ; +IN: opengl.debug + +HELP: G +{ $description "Makes the OpenGL context associated with " { $link G-world } " active for subsequent OpenGL calls. This is intended to be used from the listener, where interactively entered OpenGL calls can be directed to any window. Note that the Factor UI resets the OpenGL context every time a window is updated, so every code snippet entered in the listener must be prefixed with " { $snippet "G" } " in this use case." } +{ $examples { $code <" USING: opengl.debug ui ; + +[ drop t ] find-window G-world set +G 0.0 0.0 1.0 1.0 glClearColor +G GL_COLOR_BUFFER_BIT glClear +"> } } ; + +HELP: F +{ $description "Flushes the OpenGL context associated with " { $link G-world } ", thereby committing any outstanding drawing operations." } ; + +HELP: G-world +{ $var-description "The world whose OpenGL context is made active by " { $link G } "." } ; + +HELP: GB +{ $description "A shorthand for " { $link gl-break } "." } ; + +HELP: gl-break +{ $description "Suspends the current thread and activates the walker like " { $link break } ", but also preserves the current OpenGL context, saves it to " { $link G-world } " for interactive use through " { $link G } ", and restores the current context when the suspended thread is continued. The shorthand word " { $link POSTPONE: GB } " can also be used." } ; + +{ G F G-world POSTPONE: GB gl-break } related-words + +ARTICLE: "opengl.debug" "Interactive debugging of OpenGL applications" +"The " { $vocab-link "opengl.debug" } " vocabulary provides words to assist with interactive debugging of OpenGL applications in the Factor UI." +{ $subsection G-world } +{ $subsection G } +{ $subsection F } +{ $subsection GB } +{ $subsection gl-break } ; + +ABOUT: "opengl.debug" diff --git a/basis/opengl/debug/debug.factor b/basis/opengl/debug/debug.factor new file mode 100644 index 0000000000..7cbdf62346 --- /dev/null +++ b/basis/opengl/debug/debug.factor @@ -0,0 +1,23 @@ +! (c)2009 Joe Groff bsd license +USING: accessors kernel namespaces parser tools.continuations +ui.backend ui.gadgets.worlds words ; +IN: opengl.debug + +SYMBOL: G-world + +: G ( -- ) + G-world get set-gl-context ; + +: F ( -- ) + G-world get handle>> flush-gl-context ; + +: gl-break ( -- ) + world get dup G-world set-global + [ break ] dip + set-gl-context ; + +<< \ gl-break t "break?" set-word-prop >> + +SYNTAX: GB + \ gl-break parsed ; + diff --git a/basis/opengl/debug/summary.txt b/basis/opengl/debug/summary.txt new file mode 100644 index 0000000000..3a85f2f3c8 --- /dev/null +++ b/basis/opengl/debug/summary.txt @@ -0,0 +1 @@ +Helper words for breaking and interactively manipulating OpenGL applications