Re: [Factor-talk] OpenGL gadget question
Thank you very much, Jon! I now have a working gadget, and a link to the OpenGL tutorial which I'm going to study in the background. Next question, if you don't mind. My gadget now displays some colored rectangles, and I need to add numbers to the output. How do I do that? To be very specific, I'd like to output single-digit numbers 0 through 6 to specified window coordinates, preferably using Tahoma font (I'm on Windows here) size 8 (something about 13 pixels high) in black color. What's the simplest way to do it? Where should I look for hints or maybe working example code? 25.04.2016, 19:10, "Jon Harper" : > You can totally forget about do-matrix ! It's here to help when > building hierarchical structures (so for example factor uses it for > the gadget hierarchies, where children are drawn inside the parent). > But you don't have to. The built-in documentation really lacks this information. ---=--- Александр -- Find and fix application performance issues faster with Applications Manager Applications Manager provides deep performance insights into multiple tiers of your business applications. It resolves application problems quickly and reduces your MTTR. Get your free trial! https://ad.doubleclick.net/ddm/clk/302982198;130105516;z ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] OpenGL gadget question
On Mon, Apr 25, 2016 at 1:46 PM, Alexander Ilin wrote: > 24.04.2016, 23:17, "Jon Harper" : >> Also, the opengl matrix stacks were part of the "fixed function >> pipeline". It was totally removed in openGL 4 and replaced by the >> programmable shaders. You can read about it on Joe's blog: >> http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Table-of-Contents.html I'm no openGL expert, so for anyone, feel free to correct me if I'm wrong. Also, those functions were removed from the openGL spec in version 3.1, not 4, my bad. > But what does it mean practically? Practically, it means you need system libraries documented on this page: https://concatenative.org/wiki/view/Factor/Requirements All these are pretty portable, so don't be afraid to depend on them. >When I'm programming in Factor's GUI, am I using OpenGL 4 or an earlier >version? openGL is a standard, which is different from an implementation. I don't think factor uses any functions from openGL 3 or 4 for the default UI tools. The extra/gpu vocab does use openGL3.1 functions so it's available if you need it. > Is it dependent on the host system libraries and/or capabilities support? Factor builds it's UI on several components. For example, on linux it uses gtk to open windows, opengl to draw stuff, pango to render text. All these are system libraries. So for openGL, it will use the libGL.so of your system. It expects that this libGL.so will have the functions it needs (for example glPushMatrix). > Is there a way to find out? On linux, you can check that by running the nm program: $ nm -D "/usr/lib/x86_64-linux-gnu/libGL.so.352.21" | grep glPushMatrix 000cd0a0 T glPushMatrix > Or does it mean I can just forget that do-matrix exists and not use it, > ever? You can totally forget about do-matrix ! It's here to help when building hierarchical structures (so for example factor uses it for the gadget hierarchies, where children are drawn inside the parent). But you don't have to. Cheers, Jon -- Find and fix application performance issues faster with Applications Manager Applications Manager provides deep performance insights into multiple tiers of your business applications. It resolves application problems quickly and reduces your MTTR. Get your free trial! https://ad.doubleclick.net/ddm/clk/302982198;130105516;z ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] OpenGL gadget question
Hello, Jon! >> Also, if you don't use openGL functions that modify the current matrix >> (see >> http://docs.factorcode.org/content/article-opengl-modeling-transformations.html), >> the do-matrix word doesn't do anything for you. OK, that's the main point for me, thank you! 24.04.2016, 23:17, "Jon Harper" : > Also, the opengl matrix stacks were part of the "fixed function > pipeline". It was totally removed in openGL 4 and replaced by the > programmable shaders. You can read about it on Joe's blog: > http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Table-of-Contents.html But what does it mean practically? When I'm programming in Factor's GUI, am I using OpenGL 4 or an earlier version? Is it dependent on the host system libraries and/or capabilities support? Is there a way to find out? Or does it mean I can just forget that do-matrix exists and not use it, ever? ---=--- Александр -- Find and fix application performance issues faster with Applications Manager Applications Manager provides deep performance insights into multiple tiers of your business applications. It resolves application problems quickly and reduces your MTTR. Get your free trial! https://ad.doubleclick.net/ddm/clk/302982198;130105516;z ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] OpenGL gadget question
Also, the opengl matrix stacks were part of the "fixed function pipeline". It was totally removed in openGL 4 and replaced by the programmable shaders. You can read about it on Joe's blog: http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Table-of-Contents.html Jon On Sun, Apr 24, 2016 at 8:45 PM, Jon Harper wrote: > Hi, > do-matrix is a very thin wrapper around glPushMatrix and glPopMatrix > (https://www.opengl.org/sdk/docs/man2/xhtml/glPushMatrix.xml), so for > a theoretical explanation, I suggest you read about linear algebra > (how a matrix can represent a linear transformation such as a > translation, a rotation, a projection, etc) and the openGL matrix > stacks used in the rendering pipeline (how opengl transforms your > coordinates). But to explain everything, you will need more than a few > words... > > From a more practical point of view, the do-matrix call in tetris > means that the effects of the call to "glScalef" (in "scale-board") > end after do-matrix returns. Note that since factor also uses > do-matrix to call the draw-gadget* word, it would have ended after > draw-gadget* returned anyway. > > Also, if you don't use openGL functions that modify the current matrix > (see > http://docs.factorcode.org/content/article-opengl-modeling-transformations.html), > the do-matrix word doesn't do anything for you. > > Hope that helps, > Jon > > Jon > > > On Sun, Apr 24, 2016 at 7:22 PM, Alexander Ilin wrote: >> Thanks fore the reply! >> >> Could someone explain to me in a few words what is do-matrix used for? >> I'm not sure I need it, I just copied the code from the tetris example. >> >> 24.04.2016, 19:51, "John Benediktsson" : >>> You can log to the terminal/console standard output using: >>> >>> [ "foo" . ] with-global >>> >>> The problem with your listener output issue is probably pref-dim is called >>> before the new window opens and draw-gadget is called after and the >>> output-stream (initially set to the listener) is rebound to something other >>> than the listener you expect it to be. >>> >>> You could also save the listener output stream somewhere: >>> >>> SYMBOL: my-output-stream >>> >>> output-stream get my-output-stream set-global >>> >>> Then use it to make sure output goes to the right place: >>> >>> my-output-stream [ "foo" . ] with-output-stream >>> >>> There are other ways maybe to make that cleaner but if you only need debug >>> output that should fix it for you. >>> M: iqlink-gadget draw-gadget* drop [ origin get { 5 5 } gl-fill-rect ] do-matrix "draw-gadget*" . gl-error ; >> >> ---=--- >> Александр >> >> -- >> Find and fix application performance issues faster with Applications Manager >> Applications Manager provides deep performance insights into multiple tiers >> of >> your business applications. It resolves application problems quickly and >> reduces your MTTR. Get your free trial! >> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z >> ___ >> Factor-talk mailing list >> Factor-talk@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/factor-talk -- Find and fix application performance issues faster with Applications Manager Applications Manager provides deep performance insights into multiple tiers of your business applications. It resolves application problems quickly and reduces your MTTR. Get your free trial! https://ad.doubleclick.net/ddm/clk/302982198;130105516;z ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] OpenGL gadget question
Hi, do-matrix is a very thin wrapper around glPushMatrix and glPopMatrix (https://www.opengl.org/sdk/docs/man2/xhtml/glPushMatrix.xml), so for a theoretical explanation, I suggest you read about linear algebra (how a matrix can represent a linear transformation such as a translation, a rotation, a projection, etc) and the openGL matrix stacks used in the rendering pipeline (how opengl transforms your coordinates). But to explain everything, you will need more than a few words... From a more practical point of view, the do-matrix call in tetris means that the effects of the call to "glScalef" (in "scale-board") end after do-matrix returns. Note that since factor also uses do-matrix to call the draw-gadget* word, it would have ended after draw-gadget* returned anyway. Also, if you don't use openGL functions that modify the current matrix (see http://docs.factorcode.org/content/article-opengl-modeling-transformations.html), the do-matrix word doesn't do anything for you. Hope that helps, Jon Jon On Sun, Apr 24, 2016 at 7:22 PM, Alexander Ilin wrote: > Thanks fore the reply! > > Could someone explain to me in a few words what is do-matrix used for? > I'm not sure I need it, I just copied the code from the tetris example. > > 24.04.2016, 19:51, "John Benediktsson" : >> You can log to the terminal/console standard output using: >> >> [ "foo" . ] with-global >> >> The problem with your listener output issue is probably pref-dim is called >> before the new window opens and draw-gadget is called after and the >> output-stream (initially set to the listener) is rebound to something other >> than the listener you expect it to be. >> >> You could also save the listener output stream somewhere: >> >> SYMBOL: my-output-stream >> >> output-stream get my-output-stream set-global >> >> Then use it to make sure output goes to the right place: >> >> my-output-stream [ "foo" . ] with-output-stream >> >> There are other ways maybe to make that cleaner but if you only need debug >> output that should fix it for you. >> >>> M: iqlink-gadget draw-gadget* >>> drop [ origin get { 5 5 } gl-fill-rect ] do-matrix "draw-gadget*" . >>> gl-error ; > > ---=--- > Александр > > -- > Find and fix application performance issues faster with Applications Manager > Applications Manager provides deep performance insights into multiple tiers of > your business applications. It resolves application problems quickly and > reduces your MTTR. Get your free trial! > https://ad.doubleclick.net/ddm/clk/302982198;130105516;z > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk -- Find and fix application performance issues faster with Applications Manager Applications Manager provides deep performance insights into multiple tiers of your business applications. It resolves application problems quickly and reduces your MTTR. Get your free trial! https://ad.doubleclick.net/ddm/clk/302982198;130105516;z ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] OpenGL gadget question
Thanks fore the reply! Could someone explain to me in a few words what is do-matrix used for? I'm not sure I need it, I just copied the code from the tetris example. 24.04.2016, 19:51, "John Benediktsson" : > You can log to the terminal/console standard output using: > > [ "foo" . ] with-global > > The problem with your listener output issue is probably pref-dim is called > before the new window opens and draw-gadget is called after and the > output-stream (initially set to the listener) is rebound to something other > than the listener you expect it to be. > > You could also save the listener output stream somewhere: > > SYMBOL: my-output-stream > > output-stream get my-output-stream set-global > > Then use it to make sure output goes to the right place: > > my-output-stream [ "foo" . ] with-output-stream > > There are other ways maybe to make that cleaner but if you only need debug > output that should fix it for you. > >> M: iqlink-gadget draw-gadget* >> drop [ origin get { 5 5 } gl-fill-rect ] do-matrix "draw-gadget*" . >> gl-error ; ---=--- Александр -- Find and fix application performance issues faster with Applications Manager Applications Manager provides deep performance insights into multiple tiers of your business applications. It resolves application problems quickly and reduces your MTTR. Get your free trial! https://ad.doubleclick.net/ddm/clk/302982198;130105516;z ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] OpenGL gadget question
You can log to the terminal/console standard output using: [ "foo" . ] with-global The problem with your listener output issue is probably pref-dim is called before the new window opens and draw-gadget is called after and the output-stream (initially set to the listener) is rebound to something other than the listener you expect it to be. You could also save the listener output stream somewhere: SYMBOL: my-output-stream output-stream get my-output-stream set-global Then use it to make sure output goes to the right place: my-output-stream [ "foo" . ] with-output-stream There are other ways maybe to make that cleaner but if you only need debug output that should fix it for you. > On Apr 24, 2016, at 9:40 AM, Alexander Ilin wrote: > > Hello! > > I've got the following gadget implementation: > USING: kernel ui.gadgets > ui.render opengl prettyprint namespaces ; > IN: iqlink.gadget > > TUPLE: iqlink-gadget < gadget ; > > : ( -- gadget ) > iqlink-gadget new ; > > M: iqlink-gadget pref-dim* > drop { 900 600 } "pref-dim*" . ; > > M: iqlink-gadget draw-gadget* > drop [ origin get { 5 5 } gl-fill-rect ] do-matrix "draw-gadget*" . gl-error > ; > > I'm displaying it in a window like so: > [ "IQLink" open-window ] with-ui > > In the Listener output I expect to see the line "draw-gadget*" every time > the window is redrawn. However, I only see "pref-dim*" once, and the line > "draw-gadget*" is never added to the Listener output. It appears as if the > method draw-gadget* is never called. > > What do I do wrong? > > > ---=--- > Александр > > -- > Find and fix application performance issues faster with Applications Manager > Applications Manager provides deep performance insights into multiple tiers of > your business applications. It resolves application problems quickly and > reduces your MTTR. Get your free trial! > https://ad.doubleclick.net/ddm/clk/302982198;130105516;z > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk -- Find and fix application performance issues faster with Applications Manager Applications Manager provides deep performance insights into multiple tiers of your business applications. It resolves application problems quickly and reduces your MTTR. Get your free trial! https://ad.doubleclick.net/ddm/clk/302982198;130105516;z ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
[Factor-talk] OpenGL gadget question
Hello! I've got the following gadget implementation: USING: kernel ui.gadgets ui.render opengl prettyprint namespaces ; IN: iqlink.gadget TUPLE: iqlink-gadget < gadget ; : ( -- gadget ) iqlink-gadget new ; M: iqlink-gadget pref-dim* drop { 900 600 } "pref-dim*" . ; M: iqlink-gadget draw-gadget* drop [ origin get { 5 5 } gl-fill-rect ] do-matrix "draw-gadget*" . gl-error ; I'm displaying it in a window like so: [ "IQLink" open-window ] with-ui In the Listener output I expect to see the line "draw-gadget*" every time the window is redrawn. However, I only see "pref-dim*" once, and the line "draw-gadget*" is never added to the Listener output. It appears as if the method draw-gadget* is never called. What do I do wrong? ---=--- Александр -- Find and fix application performance issues faster with Applications Manager Applications Manager provides deep performance insights into multiple tiers of your business applications. It resolves application problems quickly and reduces your MTTR. Get your free trial! https://ad.doubleclick.net/ddm/clk/302982198;130105516;z ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk