{"id":227,"date":"2010-11-28T18:09:02","date_gmt":"2010-11-28T22:09:02","guid":{"rendered":"http:\/\/jausoft.com\/blog\/?p=227"},"modified":"2019-05-14T04:52:13","modified_gmt":"2019-05-14T08:52:13","slug":"newt-threading-overview","status":"publish","type":"post","link":"https:\/\/jausoft.com\/blog\/2010\/11\/28\/newt-threading-overview\/","title":{"rendered":"NEWT Threading Overview"},"content":{"rendered":"<p>NEWT&#8217;s event model is pretty simple.<br \/>\nIt spawns one Event Dispatch Thread (EDT) for each unique Display<br \/>\nwhich role is to handle:<\/p>\n<ul>\n<li> input events <\/li>\n<li> window lifecycle actions (window visibility, resize, .. etc) <\/li>\n<li> <b>not<\/b> rendering <\/li>\n<\/ul>\n<p><!--more--><\/p>\n<p>High performance rendering is achieved without being blocked by input events<br \/>\nand the other way around, ie rendering does not disturb \/ lag user input.<br \/>\nThis gives you fluent animation even for complex models.<\/p>\n<p>Lately we had to create NewtCanvasAWT, hooking a NEWT window natively to an AWT Canvas.<br \/>\nThis enables us to use both worlds, AWT\/Swing UI and decoupled high performance rendering.<\/p>\n<p><b>How to pass user input back to the rendering loop ?<\/b><br \/>\n  Shows you how to use a fifo to pipe events from the EDT (listener) to the rendering loop.<\/p>\n<ul>\n<li><a href=\"http:\/\/jogamp.org\/git\/?p=jogl.git;a=blob;f=src\/junit\/com\/jogamp\/test\/junit\/newt\/parenting\/TestParenting02NEWT.java;h=23e3e1c443bbb5551d86236e1fce96d2d4ec15e3;hb=HEAD#l111\">TestParenting02NEWT.java<\/a><\/li>\n<li><a href=\"http:\/\/jogamp.org\/git\/?p=jogl.git;a=blob;f=src\/junit\/com\/jogamp\/test\/junit\/newt\/parenting\/KeyAction.java;h=4948ce9f4f7b0b6f8498b37a19dd63651bb88b5b;hb=HEAD\">KeyAction.java<\/a><\/li>\n<\/ul>\n<p><b>How to inject some GL action to the rendering loop ?<\/b><br \/>\n  Shows you how to inject GL render actions into a GL fifo from another thread.<\/p>\n<ul>\n<li><a href=\"http:\/\/jogamp.org\/git\/?p=jogl.git;a=blob;f=src\/junit\/com\/jogamp\/test\/junit\/newt\/parenting\/TestParenting01cSwingAWT.java;h=fb2c744557c5b83eedfbea1d6e65d746bce5b03d;hb=HEAD#l207\">TestParenting01cSwingAWT.java<\/a><\/li>\n<li><a href=\"http:\/\/jogamp.org\/git\/?p=jogl.git;a=blob;f=src\/junit\/com\/jogamp\/test\/junit\/newt\/parenting\/GLRunnableDummy.java;h=2459c8687afed130d038760a1b94ff07ccc72f70;hb=HEAD#l39\">GLRunnableDummy.java<\/a><\/li>\n<\/ul>\n<p><b>AWT agnostic input event listener<\/b><br \/>\nWe also have a way to write AWT agnostic input event listener:<\/p>\n<ul>\n<li><a href=\"http:\/\/jogamp.org\/git\/?p=jogl.git;a=blob;f=src\/junit\/com\/jogamp\/test\/junit\/jogl\/demos\/gl2\/gears\/newt\/TestGearsNEWT.java;h=d83deea4bccde0121b46ced0cf76dfbb17352a3e;hb=HEAD\">TestGearsNEWT.java<\/a><\/li>\n<li><a href=\"http:\/\/jogamp.org\/git\/?p=jogl.git;a=blob;f=src\/junit\/com\/jogamp\/test\/junit\/jogl\/demos\/gl2\/gears\/TestGearsAWT.java;h=3e7e5988ba3631486e18474ec56fdbcffd23028d;hb=HEAD\">TestGearsAWT.java<\/a><\/li>\n<\/ul>\n<p>We provide some utilities to make life a bit easier.<br \/>\nThese are not really necessary, ie you could write and use your own, sure.<\/p>\n<p>The NEWT threading requirements are easy &#8211; they are just <b>none<\/b> for rendering,<br \/>\nand the input event listener should better not lock the rendering GL context.<br \/>\nWell, they can using <code>GLContext.setSynchronized(true) etc .. <\/code>,<br \/>\nbut that would be a pity performance wise.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>NEWT&#8217;s event model is pretty simple. It spawns one Event Dispatch Thread (EDT) for each unique Display which role is to handle: input events window lifecycle actions (window visibility, resize, .. etc) not rendering<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[7,3,8],"tags":[9,16,44,17],"class_list":["post-227","post","type-post","status-publish","format-standard","hentry","category-3d-opengl","category-computer-stuff","category-jogamp","tag-3d","tag-java","tag-jogamp","tag-opengl"],"_links":{"self":[{"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/posts\/227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/comments?post=227"}],"version-history":[{"count":9,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/posts\/227\/revisions"}],"predecessor-version":[{"id":586,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/posts\/227\/revisions\/586"}],"wp:attachment":[{"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/media?parent=227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/categories?post=227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/tags?post=227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}