<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>20papercups :: Michael Marner&#039;s Website &#187; Programming</title>
	<atom:link href="http://www.20papercups.net/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.20papercups.net</link>
	<description>The (awesome) website of Michael Marner</description>
	<lastBuildDate>Tue, 15 Nov 2011 01:09:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Graphics Applications and Libraries Month at Packt Publishing</title>
		<link>http://www.20papercups.net/random-news/graphics-applications-and-libraries-month-at-packt-publishing/</link>
		<comments>http://www.20papercups.net/random-news/graphics-applications-and-libraries-month-at-packt-publishing/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 23:13:40 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Random News]]></category>
		<category><![CDATA[Augmented Reality]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[openscenegraph]]></category>

		<guid isPermaLink="false">http://www.20papercups.net/?p=371</guid>
		<description><![CDATA[Hey guys So a little while ago I said that I was going to review the new Open Scene Graph 3: Beginners Guide book from Packt Publishing. Unfortunately, I still haven&#8217;t had time to do the review. However, I thought I would mention that all through April Packt Publishing are running discounts on all of [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.20papercups.net/wp-content/uploads/2011/04/packt_logo.png"><img class="alignleft size-full wp-image-372" title="packt_logo" src="http://www.20papercups.net/wp-content/uploads/2011/04/packt_logo.png" alt="" width="104" height="45" /></a>Hey guys</p>
<p>So a little while ago I said that I was going to review the new <a href="http://link.packtpub.com/NwneHs">Open Scene Graph 3: Beginners Guide</a> book from Packt Publishing. Unfortunately, I <em>still</em> haven&#8217;t had time to do the review. However, I thought I would mention that all through April Packt Publishing are running discounts on all of their Graphics books!</p>
<blockquote><p><span style="color: #000000;"><span style="font-family: Calibri;"><span style="font-size: small;">During April, Packt will be running a series of discounts and promotions on a selection of its Open Source Graphic books wherein readers can avail exclusive discounts of 20% and 30% off the cover price of Graphic print books and eBooks.</span></span></span></p></blockquote>
<p><span style="color: #000000;"><span style="font-family: Calibri;"><span style="font-size: small;">So, I suggest you go check out what they have to offer:</span></span></span></p>
<p><a href="http://www.packtpub.com/article/graphic-open-source" target="_blank">http://www.packtpub.com/article/graphic-open-source</a></p>
<p>Cheers<br />
Michael</p>
<p><small><em>Full Disclosure: I have nothing to do with Packt Publishing. However, they did give me a free e-book version of the OSG3 Beginners Guide for me to review. I feel a little bit guilty that I haven&#8217;t done the review yet. Other than that, I have no affiliation with Packt Publishing, and I didn&#8217;t get anything for posting this. So I haven&#8217;t sold out. In my opinion, someone going out of their way to produce documentation and reference books for Open Source Software is a good thing!</em></small></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.20papercups.net/random-news/graphics-applications-and-libraries-month-at-packt-publishing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Videos Now On Youtube</title>
		<link>http://www.20papercups.net/random-news/java-videos-now-on-youtube/</link>
		<comments>http://www.20papercups.net/random-news/java-videos-now-on-youtube/#comments</comments>
		<pubDate>Fri, 25 Mar 2011 06:24:08 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Java Video Tutorials]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Random News]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[vtm]]></category>

		<guid isPermaLink="false">http://www.20papercups.net/?p=366</guid>
		<description><![CDATA[Hi Everyone Just a quick note to say that I&#8217;ve put all the Java video tutorials up on Youtube. Things have changed since I started making the videos &#8211; Youtube has finally allowed videos longer than 15 minutes, which means I can upload them without having to slice them all up. Youtube Playlist Cheers Michael]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.20papercups.net/wp-content/uploads/2008/12/fonzie.jpeg"><img class="alignleft size-full wp-image-12" title="fonzie" src="http://www.20papercups.net/wp-content/uploads/2008/12/fonzie.jpeg" alt="" width="120" height="120" /></a>Hi Everyone</p>
<p>Just a quick note to say that I&#8217;ve put all the Java video tutorials up on Youtube. Things have changed since I started making the videos &#8211; Youtube has finally allowed videos longer than 15 minutes, which means I can upload them without having to slice them all up.</p>
<p><a href="http://www.youtube.com/view_play_list?p=A7C651F65A0C41F7" target="_blank">Youtube Playlist</a></p>
<p>Cheers<br />
Michael</p>
]]></content:encoded>
			<wfw:commentRss>http://www.20papercups.net/random-news/java-videos-now-on-youtube/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Quimo. A deformable material to support freeform modelling in spatial augmented reality environments</title>
		<link>http://www.20papercups.net/random-news/quimo/</link>
		<comments>http://www.20papercups.net/random-news/quimo/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 04:05:26 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Augmented Reality]]></category>
		<category><![CDATA[Random News]]></category>
		<category><![CDATA[UniSA]]></category>
		<category><![CDATA[industrial design]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[publication]]></category>
		<category><![CDATA[sar]]></category>
		<category><![CDATA[sculpting]]></category>

		<guid isPermaLink="false">http://www.20papercups.net/?p=361</guid>
		<description><![CDATA[Hello Everyone 3DUI has wrapped up for the year, so here is our second publication. We introduce a new material for freeform sculpting in spatial augmented reality environments. Please read the paper, and have a look at the video below. &#160;]]></description>
			<content:encoded><![CDATA[<p>Hello Everyone</p>
<p>3DUI has wrapped up for the year, so here is our second publication. We introduce a new material for freeform sculpting in spatial augmented reality environments. Please read the <a href="http://www.20papercups.net/wp-content/uploads/2009/09/quimo.pdf">paper</a>, and have a look at the video below.</p>
<p><iframe title="YouTube video player" width="640" height="390" src="http://www.youtube.com/embed/LqsMzRuDZOs" frameborder="0" allowfullscreen></iframe><br />
&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.20papercups.net/random-news/quimo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Publication: Adaptive Color Marker for SAR Environments</title>
		<link>http://www.20papercups.net/random-news/adaptive-color-marker/</link>
		<comments>http://www.20papercups.net/random-news/adaptive-color-marker/#comments</comments>
		<pubDate>Sun, 20 Mar 2011 03:36:12 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Augmented Reality]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Random News]]></category>
		<category><![CDATA[UniSA]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[publication]]></category>
		<category><![CDATA[sar]]></category>

		<guid isPermaLink="false">http://www.20papercups.net/?p=357</guid>
		<description><![CDATA[Hey Everyone So right now I am at the IEEE Symposium on 3D User Interfaces in Singapore. We have a couple of publications which I&#8217;ll be posting over the next few days. First up is Adaptive Color Marker for SAR Environments. In a previous study we created interactive virtual control panels by projecting onto otherwise [...]]]></description>
			<content:encoded><![CDATA[<p>Hey Everyone</p>
<p>So right now I am at the IEEE Symposium on 3D User Interfaces in Singapore. We have a couple of publications which I&#8217;ll be posting over the next few days. First up is<em> Adaptive Color Marker for SAR Environments</em>. In a <a href="http://www.youtube.com/watch?v=6SAjX8-iBOc" target="_blank">previous study</a> we created interactive virtual control panels by projecting onto otherwise blank designs. We used a simple orange marker to track the position of the user&#8217;s finger. However, in a SAR environment, this approach suffers from several problems:</p>
<ul>
<li>The tracking system can&#8217;t track the marker if we project the same colour as the marker.</li>
<li>Projecting onto the marker changes it&#8217;s appearance, causing tracking to fail.</li>
<li>Users could not tell when they were pressing virtual controls, because their finger occluded the projection.</li>
</ul>
<p>We address these problems with an active colour marker. We use a colour sensor to detect what is being projected onto the marker, and change the colour of the marker to an <em>opposite</em> colour, so that tracking continues to work. In addition, we can use the active marker as a form of visual feedback. For example, we can change the colour to indicate a virtual button press.</p>
<p>I&#8217;ve added the publication to my publications page, and here&#8217;s the video of the marker in action.</p>
<p><iframe title="YouTube video player" width="640" height="390" src="http://www.youtube.com/embed/s8m9JAe9fZ0" frameborder="0" allowfullscreen></iframe></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.20papercups.net/random-news/adaptive-color-marker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Behaviours Demo &#8211; Android Programming</title>
		<link>http://www.20papercups.net/programming/behaviours-demo-android-programming/</link>
		<comments>http://www.20papercups.net/programming/behaviours-demo-android-programming/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 23:37:54 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[3dbuzz]]></category>
		<category><![CDATA[ai]]></category>
		<category><![CDATA[andriod]]></category>
		<category><![CDATA[nexus one]]></category>
		<category><![CDATA[opengl]]></category>

		<guid isPermaLink="false">http://www.20papercups.net/?p=347</guid>
		<description><![CDATA[Hey Everyone So this week I became a member sponsor on www.3dbuzz.com. The first thing I had a look at was their XNA Behaviour Programming videos, which are the first in their set on AI programming. However, not being particularly interested in XNA, I implemented the algorithms presented in the videos for Android. Here&#8217;s a [...]]]></description>
			<content:encoded><![CDATA[<p>Hey Everyone</p>
<p>So this week I became a member sponsor on www.3dbuzz.com. The first thing I had a look at was their XNA Behaviour Programming videos, which are the first in their set on AI programming. However, not being particularly interested in XNA, I implemented the algorithms presented in the videos for Android.</p>
<p>Here&#8217;s a video of the demo running on my Nexus One:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/zFFex-MXm_w?fs=1&amp;hl=en_US" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="640" height="385" src="http://www.youtube.com/v/zFFex-MXm_w?fs=1&amp;hl=en_US" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Since I was on Android and only using the Android and OpenGL ES libraries, I had to write a lot of low level code to replace the XNA functionality that 3DBuzz&#8217;s videos rely on. I also had to implement an on-screen joystick. I might write up a couple of posts on the more interesting parts of the code (what is not in the videos) soon.</p>
<p>Thanks<br />
Michael</p>
]]></content:encoded>
			<wfw:commentRss>http://www.20papercups.net/programming/behaviours-demo-android-programming/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>OpenSceneGraph 3.0 Beginner&#8217;s Guide &#8211; book review coming soon!</title>
		<link>http://www.20papercups.net/random-news/openscenegraph-3-0-beginners-guide-book-review-coming-soon/</link>
		<comments>http://www.20papercups.net/random-news/openscenegraph-3-0-beginners-guide-book-review-coming-soon/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 02:11:34 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Random News]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[openscenegraph]]></category>

		<guid isPermaLink="false">http://www.20papercups.net/?p=344</guid>
		<description><![CDATA[Hi Everyone The guys over at Packt Publishing have kindly asked me to review a new book on programming with OpenSceneGraph. I haven&#8217;t looked at the book yet, but will get the review done sometime this week. In the mean time, checkout the book: http://link.packtpub.com/NwneHs]]></description>
			<content:encoded><![CDATA[<p><a class="moz-txt-link-freetext" href="http://link.packtpub.com/NwneHs"><a href="http://link.packtpub.com/NwneHs"><img class="alignleft size-medium wp-image-345" title="OpenSceneGraph 3.0 Beginner's Guide" src="http://www.20papercups.net/wp-content/uploads/2011/01/OSG-243x300.jpg" alt="" width="243" height="300" /></a></a></p>
<p>Hi Everyone</p>
<p>The guys over at Packt Publishing have kindly asked  me to review a new book on programming with OpenSceneGraph. I haven&#8217;t  looked at the book yet, but will get the review done sometime this week.  In the mean time, checkout the book:</p>
<p><a href="http://link.packtpub.com/NwneHs">http://link.packtpub.com/NwneHs</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.20papercups.net/random-news/openscenegraph-3-0-beginners-guide-book-review-coming-soon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenSceneGraph, Dual Screens &amp; TwinView</title>
		<link>http://www.20papercups.net/programming/openscenegraph-dual-screens-twinview/</link>
		<comments>http://www.20papercups.net/programming/openscenegraph-dual-screens-twinview/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 06:07:24 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[dual screen]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[openscenegraph]]></category>

		<guid isPermaLink="false">http://www.20papercups.net/?p=145</guid>
		<description><![CDATA[So some of my work at uni involves programming using OpenSceneGraph. Now, anybody who has used OSG before will know that as powerful as it may be, it is seriously lacking in the documentation department. So, this article describes how to do dual screen graphics on Linux using OpenSceneGraph. First we&#8217;ll look at the X [...]]]></description>
			<content:encoded><![CDATA[<p>So some of my work at uni involves programming using <a title="OpenSceneGraph Website" href="http://www.openscenegraph.org" target="_blank">OpenSceneGraph</a>. Now, anybody who has used OSG before will know that as powerful as it may be, it is seriously lacking in the documentation department. So, this article describes how to do dual screen graphics on Linux using OpenSceneGraph. First we&#8217;ll look at the X Screens approach, which is easier but probably not the best solution. Then we&#8217;ll look at a method that works with a single X screen.<span id="more-145"></span></p>
<h3>Multiple X Screens</h3>
<p>The easiest way to do dual screen output is if you have your X server configured so each output is its own X screen. The first thing you need to do is make sure you have enough screens. Finding this out is easy enough:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">int</span> getNumScreens<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    osg<span style="color: #008080;">::</span><span style="color: #007788;">GraphicsContext</span><span style="color: #008080;">::</span><span style="color: #007788;">WindowingSystemInterface</span><span style="color: #000040;">*</span> wsi <span style="color: #000080;">=</span> osg<span style="color: #008080;">::</span><span style="color: #007788;">GraphicsContext</span><span style="color: #008080;">::</span><span style="color: #007788;">getWindowingSystemInterface</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    osg<span style="color: #008080;">::</span><span style="color: #007788;">GraphicsContext</span><span style="color: #008080;">::</span><span style="color: #007788;">ScreenIdentifier</span> si<span style="color: #008080;">;</span>
    si.<span style="color: #007788;">readDISPLAY</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">return</span> wsi<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>getNumScreens<span style="color: #008000;">&#40;</span>si<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>You should do this before attempting to create your screens to make sure the X server is configured correctly. Otherwise OSG will throw an error when you try and create a graphics context for a screen that doesn&#8217;t exist. Setting up the viewers is fairly straight forward:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #666666;">//Create main scene viewer</span>
&nbsp;
ref_ptr<span style="color: #000080;">&lt;</span>osgViewer<span style="color: #008080;">::</span><span style="color: #007788;">CompositeViewer</span><span style="color: #000080;">&gt;</span> compositeViewer <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> osgViewer<span style="color: #008080;">::</span><span style="color: #007788;">CompositeViewer</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #666666;">// create first view</span>
osgViewer<span style="color: #008080;">::</span><span style="color: #007788;">View</span><span style="color: #000040;">*</span> v0 <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> osgViewer<span style="color: #008080;">::</span><span style="color: #007788;">View</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
v0<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>setUpViewOnSingleScreen<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #666666;">// add view to the composite viewer</span>
compositeViewer<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>addView<span style="color: #008000;">&#40;</span>v0<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #666666;">// do the same with the second view</span>
osgViewer<span style="color: #008080;">::</span><span style="color: #007788;">View</span><span style="color: #000040;">*</span> v1 <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> osgViewer<span style="color: #008080;">::</span><span style="color: #007788;">View</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
v1<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>setUpViewOnSingleScreen<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
compositeViewer<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>addView<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div>

<p>And thats it. You also need to set the scene data for each of your views and a couple of things I&#8217;ve missed, but that is the basic idea. The problem with this method is it creates 2 graphics contexts, which in most cases will cause a performance hit.</p>
<h3>Single X Screen, Single Context</h3>
<p>I looked into this method because I use TwinView on my Linux desktop boxes. Of course, TwinView means that there is only 1 XScreen that spans both monitors. Therefore, the getNumScreens function above will return 1. I have also set up our projector setup to use TwinView, so I don&#8217;t need to have one lot of code for testing on the desktop and then do something completely different when using the projectors. The other benefit of this approach is you only create one graphics context.</p>
<p>First thing we do is get the dimensions of the screen, which will be the combination of both screens.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #666666;">// get the total resolution of the xscreen</span>
osg<span style="color: #008080;">::</span><span style="color: #007788;">GraphicsContext</span><span style="color: #008080;">::</span><span style="color: #007788;">WindowingSystemInterface</span><span style="color: #000040;">*</span> wsi <span style="color: #000080;">=</span> osg<span style="color: #008080;">::</span><span style="color: #007788;">GraphicsContext</span><span style="color: #008080;">::</span><span style="color: #007788;">getWindowingSystemInterface</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #0000ff;">unsigned</span> width, height<span style="color: #008080;">;</span>
wsi<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>getScreenResolution<span style="color: #008000;">&#40;</span>osg<span style="color: #008080;">::</span><span style="color: #007788;">GraphicsContext</span><span style="color: #008080;">::</span><span style="color: #007788;">ScreenIdentifier</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span>, width, height<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div>

<p>Once that is done we can create our (single) graphics context.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #666666;">// create a context that spans the entire x screen</span>
traits<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>x <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
traits<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>y <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
traits<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>width <span style="color: #000080;">=</span> width<span style="color: #008080;">;</span>
traits<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>height <span style="color: #000080;">=</span> height<span style="color: #008080;">;</span>
traits<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>windowDecoration <span style="color: #000080;">=</span> <span style="color: #0000ff;">false</span><span style="color: #008080;">;</span>
traits<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>doubleBuffer <span style="color: #000080;">=</span> <span style="color: #0000ff;">true</span><span style="color: #008080;">;</span>
traits<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>sharedContext <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
traits<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>overrideRedirect <span style="color: #000080;">=</span> <span style="color: #0000ff;">true</span><span style="color: #008080;">;</span>
osg<span style="color: #008080;">::</span><span style="color: #007788;">ref_ptr</span><span style="color: #000080;">&lt;</span>osg<span style="color: #008080;">::</span><span style="color: #007788;">GraphicsContext</span><span style="color: #000080;">&gt;</span> gc <span style="color: #000080;">=</span> osg<span style="color: #008080;">::</span><span style="color: #007788;">GraphicsContext</span><span style="color: #008080;">::</span><span style="color: #007788;">createGraphicsContext</span><span style="color: #008000;">&#40;</span>traits.<span style="color: #007788;">get</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div>

<p>The important one here is overrideRedirect. Some window managers (I&#8217;m looking at you Gnome) will redirect the position of your graphics context, so it won&#8217;t appear where you want it. The overrideRedirect option is kindof new, it does not exist in the version of OSG shipping with Ubuntu 8.10. Therefore, I am running the latest stable release (2.6) compiled from source.</p>
<p>To get the equivalent of 2 screens to draw on, we create 2 views like before. However, we have to set their viewport manually. Here we just make v0 use the left half of the screen, and v1 use the right half. Easy enough?</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #666666;">//first screen</span>
osgViewer<span style="color: #008080;">::</span><span style="color: #007788;">View</span><span style="color: #000040;">*</span> v0 <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> osgViewer<span style="color: #008080;">::</span><span style="color: #007788;">View</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
osg<span style="color: #008080;">::</span><span style="color: #007788;">ref_ptr</span><span style="color: #000080;">&lt;</span>osg<span style="color: #008080;">::</span><span style="color: #007788;">Camera</span><span style="color: #000080;">&gt;</span> cam <span style="color: #000080;">=</span> v0<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>getCamera<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
cam<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>setGraphicsContext<span style="color: #008000;">&#40;</span>gc.<span style="color: #007788;">get</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
cam<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>setViewport<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span>, <span style="color: #0000dd;">0</span>, width<span style="color: #000040;">/</span><span style="color: #0000dd;">2</span>, height<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
compositeViewer<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>addView<span style="color: #008000;">&#40;</span>v<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #666666;">//second screen</span>
osgViewer<span style="color: #008080;">::</span><span style="color: #007788;">View</span><span style="color: #000040;">*</span> v1 <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> osgViewer<span style="color: #008080;">::</span><span style="color: #007788;">View</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
osg<span style="color: #008080;">::</span><span style="color: #007788;">ref_ptr</span><span style="color: #000080;">&lt;</span>osg<span style="color: #008080;">::</span><span style="color: #007788;">Camera</span><span style="color: #000080;">&gt;</span> cam2 <span style="color: #000080;">=</span> v1<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>getCamera<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
cam2<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>setGraphicsContext<span style="color: #008000;">&#40;</span>gc.<span style="color: #007788;">get</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
cam2<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>setViewport<span style="color: #008000;">&#40;</span>width<span style="color: #000040;">/</span><span style="color: #0000dd;">2</span>, <span style="color: #0000dd;">0</span>, width<span style="color: #000040;">/</span><span style="color: #0000dd;">2</span>, height<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
compositeViewer<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>addView<span style="color: #008000;">&#40;</span>v1<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div>

<p>setViewport sets the viewport of the camera. The first 2 parameters are the position in the context&#8217;s window, the next 2 are the dimensions. So, each view gets width/2 for the width, and the second screen&#8217;s position is offset by half the screen width meaning it starts on the second monitor.</p>
<h2>Conclusion</h2>
<p>And there you have it. Two methods for dual screen using OpenSceneGraph. Looking at the code, it is fairly simple. However, after browsing the doxygen docs for OSG it was not at all obvious to me. Of course, the osg-users mailing list was a big help here. In fact, <a href="http://groups.google.com/group/osg-users/browse_thread/thread/684fb727c4ab6ee2/daaa720956ae17e1" target="_blank">here</a> is the thread from the mailing list</p>
<p>Cheers<br />
Michael</p>
<p><center><script type="text/javascript"><!--
google_ad_client = "pub-9376349336558898";
google_ad_slot = "0815367707";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</center></p>
]]></content:encoded>
			<wfw:commentRss>http://www.20papercups.net/programming/openscenegraph-dual-screens-twinview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Tutorial 09 &#8211; OpenGL and Java</title>
		<link>http://www.20papercups.net/java-vtm-tutorials/java-vtm09-opengl-and-java/</link>
		<comments>http://www.20papercups.net/java-vtm-tutorials/java-vtm09-opengl-and-java/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 10:51:13 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Java Video Tutorials]]></category>
		<category><![CDATA[3dbuzz]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jogl]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.20papercups.net/?p=100</guid>
		<description><![CDATA[This video looks at how we can use the OpenGL graphics library in our Java programs. This video was an entry in a competition on 3dbuzz.com. As such, it doesn&#8217;t flow on from the previous videos, just consider it a bonus. Note that this video is 1024&#215;768, so hit the full screen button to get [...]]]></description>
			<content:encoded><![CDATA[<p>This video looks at how we can use the OpenGL graphics library in our Java programs. This video was an entry in a competition on <a href="http://www.3dbuzz.com" target="_blank">3dbuzz.com</a>. As such, it doesn&#8217;t flow on from the previous videos, just consider it a bonus.<span id="more-100"></span></p>
<p style="text-align: center;"><img src="http://www.20papercups.net/wp-content/plugins/flash-video-player/default_video_player.gif" /></p>
<p style="text-align: left;">Note that this video is 1024&#215;768, so hit the full screen button to get more readable detail.</p>
<p style="text-align: left;"><strong>Notes:</strong></p>
<p style="text-align: left;">This video is the property of 3DBuzz Inc. Jason and Zak have kindly given me permission to host it on this website. Because it is not owned by me, I would appreciate it if you did not distribute this video. Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.20papercups.net/java-vtm-tutorials/java-vtm09-opengl-and-java/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Java Tutorial 08 &#8211; Intro To Eclipse</title>
		<link>http://www.20papercups.net/java-vtm-tutorials/java-vtm08-intro-to-eclipse/</link>
		<comments>http://www.20papercups.net/java-vtm-tutorials/java-vtm08-intro-to-eclipse/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 01:54:54 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Java Video Tutorials]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.20papercups.net/?p=98</guid>
		<description><![CDATA[This video gives an overview of the Eclipse IDE. Eclipse is a feature packed Java development environment that is also free and open source. In this video we see how we create projects in eclipse and run our programs. Note that this video is 1024&#215;768, so hit the full screen button to get more readable [...]]]></description>
			<content:encoded><![CDATA[<p>This video gives an overview of the Eclipse IDE. Eclipse is a feature packed Java development environment that is also free and open source. In this video we see how we create projects in eclipse and run our programs.<span id="more-98"></span></p>
<p style="text-align: center;"><img src="http://www.20papercups.net/wp-content/plugins/flash-video-player/default_video_player.gif" /></p>
<p style="text-align: left;">Note that this video is 1024&#215;768, so hit the full screen button to get more readable detail.</p>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-9376349336558898";
google_ad_slot = "0815367707";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p style="text-align: center;">
<p style="text-align: left;"><strong>Notes:</strong></p>
<p style="text-align: left;">You can get Eclipse from http://www.eclipse.org. It is available for pretty much all platforms. If you&#8217;re on Linux it is probably in your distribution&#8217;s repository.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.20papercups.net/java-vtm-tutorials/java-vtm08-intro-to-eclipse/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>C++ Video &#8211; 3DBuzz Suppliment</title>
		<link>http://www.20papercups.net/tutorials/c-video-3dbuzz-suppliment/</link>
		<comments>http://www.20papercups.net/tutorials/c-video-3dbuzz-suppliment/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 01:25:16 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[3dbuzz]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.20papercups.net/?p=113</guid>
		<description><![CDATA[This is a very short video explaining a problem that comes up time and time again on 3dbuzz.com. Essentially, why the code for their Hello World example doesn&#8217;t compile. If you have done any C++ coding before, you can safely ignore this video. Note that this video is 1024&#215;768, so hit the full screen button [...]]]></description>
			<content:encoded><![CDATA[<p>This is a very short video explaining a problem that comes up time and time again on <a href="http://www.3dbuzz.com" target="_blank">3dbuzz.com</a>. Essentially, why the code for their Hello World example doesn&#8217;t compile. If you have done any C++ coding before, you can safely ignore this video.<span id="more-113"></span></p>
<p style="text-align: center;"><img src="http://www.20papercups.net/wp-content/plugins/flash-video-player/default_video_player.gif" /></p>
<p style="text-align: left;">Note that this video is 1024&#215;768, so hit the full screen button to get more readable detail.</p>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-9376349336558898";
google_ad_slot = "0815367707";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p style="text-align: left;"><strong>Notes:</strong></p>
<p style="text-align: left;">The 3DBuzz C++ videos include the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000066;">cout</span> <span style="color: #339933;">&lt;&lt;</span> <span style="color: #ff0000;">&quot;Hello World&quot;</span> <span style="color: #339933;">&lt;&lt;</span> endl<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This code fails to compile on newer versions of Visual C++ and GCC. All that needs to be done is to specify that main will return an int, and then actually return one:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000066;">cout</span> <span style="color: #339933;">&lt;&lt;</span> <span style="color: #ff0000;">&quot;Hello World&quot;</span> <span style="color: #339933;">&lt;&lt;</span> endl<span style="color: #339933;">;</span>
   <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Of course, whether this actually needed a video is debatable!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.20papercups.net/tutorials/c-video-3dbuzz-suppliment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

