<?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>V // Pixelnerve &#187; Source Code</title>
	<atom:link href="http://www.pixelnerve.com/v/category/source-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pixelnerve.com/v</link>
	<description></description>
	<lastBuildDate>Sun, 30 Oct 2011 23:43:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>1d to 2d</title>
		<link>http://www.pixelnerve.com/v/2011/10/26/1d-to-2d/</link>
		<comments>http://www.pixelnerve.com/v/2011/10/26/1d-to-2d/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 16:14:36 +0000</pubDate>
		<dc:creator>victormartins</dc:creator>
				<category><![CDATA[Graphics programming]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[1d]]></category>
		<category><![CDATA[2d]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[gpu]]></category>

		<guid isPermaLink="false">http://www.pixelnerve.com/v/?p=1542</guid>
		<description><![CDATA[At some point you might end up needing to convert a 1d index value to access a 2d array. Here&#8217;s how you can do it. int x = index % xres; int y = index / xres; As noted by Diogo Teixeira, one way to get rid of the mod/div operations for POT buffers would [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">At some point you might end up needing to convert a 1d index value to access a 2d array. Here&#8217;s how you can do it.</p>
<p style="text-align: justify;">
<code><br />
int x = index % xres;<br />
int y = index / xres;<br />
</code>
</p>
<p style="text-align: justify;">As noted by <a href="http://diogo.codingcorner.net/" title="Diogo Teixeira" target="_blank">Diogo Teixeira</a>, one way to get rid of the mod/div operations for POT buffers would be:</p>
<p style="text-align: justify;">
<code><br />
int precalc_a = ( xresPOT - 1 );<br />
int precalc_b = (int)log2( xresPOT );<br />
int x = index  &#038; precalc_a;<br />
int y = index >> precalc_b;<br />
</code>
</p>
<p style="text-align: justify;">.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelnerve.com/v/2011/10/26/1d-to-2d/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>OpenNI Block of Code</title>
		<link>http://www.pixelnerve.com/v/2011/02/17/openni-block-of-code/</link>
		<comments>http://www.pixelnerve.com/v/2011/02/17/openni-block-of-code/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 11:41:17 +0000</pubDate>
		<dc:creator>victormartins</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Interactive]]></category>
		<category><![CDATA[Libraries]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[kinect]]></category>
		<category><![CDATA[openni]]></category>

		<guid isPermaLink="false">http://www.pixelnerve.com/v/?p=1392</guid>
		<description><![CDATA[OpenNI, a library created by PrimeSense. It&#8217;s quite famous for its ability to use the Kinect to track users and feed us with a usable skeleton per user. Since i wanted to give this a try and play around with the skeleton tracking i had to have this. So i did. In the end i [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">OpenNI, a library created by PrimeSense. It&#8217;s quite famous for its ability to use the Kinect to track users and feed us with a usable skeleton per user. Since i wanted to give this a try and play around with the skeleton tracking i had to have this. So i did. In the end i ended up with a wrapper around this API. It&#8217;s open-source and available to everyone. Its not perfect and needs work and more features, but it&#8217;s just a start. Use it at your own risk and with your favourite creative framework. It&#8217;s possible.</p>
<p style="text-align: justify;"><a title="BlockOpenNI" href="https://github.com/pixelnerve/BlockOpenNI" target="_blank">You can find it at github</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelnerve.com/v/2011/02/17/openni-block-of-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CgFX Block of Code</title>
		<link>http://www.pixelnerve.com/v/2011/02/17/cgfx-block-of-code/</link>
		<comments>http://www.pixelnerve.com/v/2011/02/17/cgfx-block-of-code/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 11:36:14 +0000</pubDate>
		<dc:creator>victormartins</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[GPU]]></category>
		<category><![CDATA[Graphics programming]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[cg]]></category>
		<category><![CDATA[cgfx]]></category>
		<category><![CDATA[nvidia]]></category>
		<category><![CDATA[shader]]></category>

		<guid isPermaLink="false">http://www.pixelnerve.com/v/?p=1388</guid>
		<description><![CDATA[I have been doing more and more work away from java/processing so i had to bring some tools with me to help and improve development time. One of my favourite shader languages is CgFX, a brother of HLSL. I spend alot of time using this for my shader programming, so i wrapped it up in [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I have been doing more and more work away from java/processing so i had to bring some tools with me to help and improve development time. One of my favourite shader languages is CgFX, a brother of HLSL. I spend alot of time using this for my shader programming, so i wrapped it up in a simple to use block of code that should be easy to use with your favourite framework.</p>
<p style="text-align: justify;"><a title="https://github.com/pixelnerve/BlockCgFX" href="http://" target="_blank">You can find it at github</a>.</p>
<p style="text-align: justify;">
]]></content:encoded>
			<wfw:commentRss>http://www.pixelnerve.com/v/2011/02/17/cgfx-block-of-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CLNUI 4 Java (Kinect)</title>
		<link>http://www.pixelnerve.com/v/2010/11/19/clnui-4-java-kinect/</link>
		<comments>http://www.pixelnerve.com/v/2010/11/19/clnui-4-java-kinect/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 02:14:44 +0000</pubDate>
		<dc:creator>victormartins</dc:creator>
				<category><![CDATA[Interaction]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Libraries]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[CLNUI]]></category>
		<category><![CDATA[JNA]]></category>
		<category><![CDATA[kinect]]></category>

		<guid isPermaLink="false">http://www.pixelnerve.com/v/?p=1343</guid>
		<description><![CDATA[Kinect is a new product from Microsoft for XBox360. With an RGB camera, a 3D depth sensor (structured IR light) and  a multi-array microphone , it is able to compute a depth map, something very interesting for the interactive world of creativity and gaming. Nothing new as technology, but still, interesting and cheap. Since its [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a title="Kinect" href="http://en.wikipedia.org/wiki/File:KinectTechnologiesE3.jpg" rel="shadowbox[sbpost-1343];player=img;" target="_blank">Kinect</a> is a new product from Microsoft for XBox360. With an RGB camera, a 3D depth sensor (structured IR light) and  a multi-array microphone , it is able to compute a depth map, something very interesting for the interactive world of creativity and gaming. Nothing new as technology, but still, interesting and cheap. Since its release people have been trying to work in order to hack it and get it to work with windows and mac OS. Quite a few people have been working on drivers and a way to hack the gadget to get access to the color/depth data. One of these people is called Alex from <a title="CL" href="http://codelaboratories.com/forums/viewthread/416/" target="_blank">Code Laboratories</a>, the man behind the PS3eye camera drivers for PC&#8217;s. Recently, he released a new package (C and C#) that includes drivers and SDK for Kinect. I took the SDK and with  <a title="JNA" href="https://jna.dev.java.net/" target="_blank">JNA</a> i wrote a library for java that wraps the original one and also tries to make its use easy for starters.</p>
<p style="text-align: justify;"><a href="../wp-content/uploads/2010/11/Frame_0471.png" rel="shadowbox[sbpost-1343];player=img;"></a><a href="http://www.pixelnerve.com/v/wp-content/uploads/2010/11/Frame_0471.jpg" rel="shadowbox[sbpost-1343];player=img;"><img class="alignnone size-medium wp-image-1348" title="Frame_0471" src="http://www.pixelnerve.com/v/wp-content/uploads/2010/11/Frame_0471-638x358.jpg" alt="" width="638" height="358" /></a></p>
<p style="text-align: justify;">A very early release is available <a title="CLNUI4J" href="http://victamin.googlecode.com/files/CLNUI4J_01.zip" target="_blank">http://victamin.googlecode.com/files/CLNUI4J_01.zip</a>. This might or might not work out-of-the-box and it sure needs improvement and more work, but as they say, release early, release often. This package includes the library and basic examples running on Eclipse IDE <span style="text-decoration: line-through;">and processing IDE (untested)</span>. It is known that this library does not work directly with Processing.</p>
<p>EDIT! Version 0.2 is now available at: <a title="CLNUI4J" href="http://victamin.googlecode.com/files/CLNUI4J_02.zip" target="_blank">http://victamin.googlecode.com/files/CLNUI4J_02.zip</a>.<br />
You can now find a friendly wrapper and a couple of examples to get you started.</p>
<p style="text-align: justify;">I would love to get some feedback, so if you&#8217;re a Kinect owner and you&#8217;re into java<span style="text-decoration: line-through;">/processing</span>, give it a  spin and let me know how it works out for you.</p>
<p style="text-align: justify;">Have fun.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelnerve.com/v/2010/11/19/clnui-4-java-kinect/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>GML Viscosity</title>
		<link>http://www.pixelnerve.com/v/2010/09/07/gml-viscosity/</link>
		<comments>http://www.pixelnerve.com/v/2010/09/07/gml-viscosity/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 07:32:25 +0000</pubDate>
		<dc:creator>victormartins</dc:creator>
				<category><![CDATA[GPU]]></category>
		<category><![CDATA[Graphics programming]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[Works]]></category>
		<category><![CDATA[cgfx]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[gml]]></category>
		<category><![CDATA[gpu]]></category>
		<category><![CDATA[graffiti]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[realtime]]></category>
		<category><![CDATA[shaders]]></category>
		<category><![CDATA[vitamin]]></category>

		<guid isPermaLink="false">http://www.pixelnerve.com/v/?p=1259</guid>
		<description><![CDATA[So here it is, the application and source code for GML Viscosity. I finally took the time to clean up this project and make a public release. In the packages you will find binaries and source code for the application, so if you&#8217;re thinking of using it and come up with something nice, let me [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">So here it is, the application and source code for <strong>GML Viscosity</strong>.</p>
<p style="text-align: justify;"><a href="http://www.pixelnerve.com/v/wp-content/uploads/2010/09/Frame_0233.jpg" rel="shadowbox[sbpost-1259];player=img;"><img class="alignnone size-medium wp-image-1280" title="Frame_0233" src="http://www.pixelnerve.com/v/wp-content/uploads/2010/09/Frame_0233-638x357.jpg" alt="" width="638" height="357" /></a></p>
<p style="text-align: justify;">I finally took the time to clean up this project and make a public release. In the packages you will find binaries and source code for the application, so if you&#8217;re thinking of using it and come up with something nice, let me know. After the first release i have fixed some problems with memory access and crashes. I have also added a simple UI for easy pick of tags from the &#8220;data/tags&#8221; folder on your hard-drive.</p>
<p><iframe src="http://player.vimeo.com/video/13550099?title=0&amp;byline=0&amp;portrait=0&amp;color=ffffff" width="640" height="360" frameborder="0"></iframe></p>
<p style="text-align: justify;"><i>What is it?</i><strong><br />
- GML Viscosity</strong> is an experiment. It is application used to draw GML tags on a viscous liquid rendered purely on the GPU side.</p>
<p style="text-align: justify;"><i>What does it do?</i><br />
- It liquifies your tags, in a way you can hardly read them but still looks cool (thats graffiti).<br />
- It is possible to load gml files from the disk or directly from the <a title="http://000000book.com/" href="http://000000book.com/">&#8220;lots of zeros&#8221;book</a> database.</p>
<p style="text-align: justify;"><a href="http://www.pixelnerve.com/v/wp-content/uploads/2010/09/Frame_0228.jpg" rel="shadowbox[sbpost-1259];player=img;"><img class="alignnone size-medium wp-image-1277" title="Frame_0228" src="http://www.pixelnerve.com/v/wp-content/uploads/2010/09/Frame_0228-638x357.jpg" alt="" width="638" height="357" /></a></p>
<p style="text-align: justify;"><i>How can I interact?</i><br />
- Not implemented on this version. This version selects and draw gml files randomly from the web or from a tags folder. For a smart person it should be easy to add mouse support. The code is also prepared to support multitouch so, it should be easy to implement TUIO and create your multitouch version.<br />
- Use &#8216;r&#8217; key to randomly fetch a new tag from the website and if available it will draw it on the screen.<br />
- Use the GUI window to pick any tag from the folder &#8220;tags&#8221; inside data folder.</p>
<p style="text-align: justify;">
<p style="text-align: justify;"><i>Where can i get it?</i><br />
<a title="GML Viscosity" href="http://www.pixelnerve.com/downloads/processing/GMLViscosity_win.zip" target="_blank">Windows Version</a> | <a title="GML Viscosity" href="http://www.pixelnerve.com/downloads/processing/GMLViscosity_osx.zip" target="_blank">MacOSX Version</a></p>
<p style="text-align: justify;">Have fun.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelnerve.com/v/2010/09/07/gml-viscosity/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MSAOpenCL for Java and Processing</title>
		<link>http://www.pixelnerve.com/v/2010/07/29/msaopencl-for-java-and-processing/</link>
		<comments>http://www.pixelnerve.com/v/2010/07/29/msaopencl-for-java-and-processing/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 01:57:33 +0000</pubDate>
		<dc:creator>victormartins</dc:creator>
				<category><![CDATA[GPU]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Libraries]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[JavaCL]]></category>
		<category><![CDATA[msaopencl]]></category>
		<category><![CDATA[OpenCL]]></category>

		<guid isPermaLink="false">http://www.pixelnerve.com/v/?p=1248</guid>
		<description><![CDATA[Recently I have been doing some work with OpenCL and i found myself messing up with old code and re-writing most of it .  At first it was interesting and quite funny but no more, so,  I thought it was time to make things easier for myself and just make things reusable by creating a [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Recently I have been doing some work with <a title="OpenCL" href="http://www.nvidia.com/object/cuda_opencl_new.html" target="_blank">OpenCL</a> and i found myself messing up with old code and re-writing most of it .  At first it was interesting and quite funny but no more, so,  I thought it was time to make things easier for myself and just make things reusable by creating a wrapper which would wrap most of the boring and time-consuming parts. This would be a wrapper on OpenCL for Java and/or Processing. Well, a well known guy named <a title="Memo" href="http://www.memo.tv" target="_blank">Mehmet &#8220;Memo&#8221; Akten</a> has done such a wrapper in C++ for the <a title="OF" href="http://www.openframeworks.cc" target="_blank">OpenFrameworks</a> and <a title="Cinder" href="http://www.libcinder.org" target="_blank">Cinder</a> libraries. I have ported it  to Java.</p>
<p style="text-align: justify;">There are some problems with reading/writing from/to GL textures. For some reason it crashes on me. I have been working with <a title="JavaCL" href="http://code.google.com/p/javacl/" target="_blank">JavaCL</a>&#8216;s author, so hopefully it will be working soon.</p>
<p style="text-align: justify;">
<p style="text-align: justify;">:: <a title="MSAOpenCL for Java/Processing" href="http://code.google.com/p/victamin/downloads/detail?name=msaopencl.zip" target="_blank">Download</a></p>
<p style="text-align: justify;">Download it, install it and try it.<br />
If you find any problems or if you have suggestions, let me know.</p>
<p style="text-align: justify;">Have fun.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelnerve.com/v/2010/07/29/msaopencl-for-java-and-processing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ping-pong technique on GPU</title>
		<link>http://www.pixelnerve.com/v/2010/07/20/pingpong-technique/</link>
		<comments>http://www.pixelnerve.com/v/2010/07/20/pingpong-technique/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 06:06:26 +0000</pubDate>
		<dc:creator>victormartins</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[GPU]]></category>
		<category><![CDATA[Graphics programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[gpu]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[ping pong]]></category>
		<category><![CDATA[shader]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.pixelnerve.com/v/?p=1205</guid>
		<description><![CDATA[Hello there. Here is a new tutorial, this time about ping-pong on the gpu. I&#8217;ve been wanting to write about it for sometime, finally it&#8217;s off my todo list. Let&#8217;s get down to business. Ping-pong technique is normally used with a shader that needs it&#8217;s result as a source parameter for it&#8217;s next iteration. This [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Hello there. Here is a new tutorial, this time about ping-pong on the gpu. I&#8217;ve been wanting to write about it for sometime, finally it&#8217;s off my todo list. Let&#8217;s get down to business. Ping-pong technique is normally used with a shader that needs it&#8217;s result as a source parameter for it&#8217;s next iteration. This is usually used in the gpu as for now it is not possible to write a program&#8217;s result to itself, so, we&#8217;ll need another equal buffer to save the current result for how next step/iteration. That was too hard?</p>
<p style="text-align: justify;">So imagine we have 2 image buffers Image1, Image2. Usually to change data from Image1, you would simply access it and write directly back to the same positioion. Now, when we&#8217;re talking about a shader fragment program we can&#8217;t simply do that.  You may ask now, what&#8217;s the solution? Ping-pong it!</p>
<p style="text-align: justify;">Here is what i&#8217;m talking about:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// Initialization</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #000066; font-weight: bold;">int</span> W <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> H <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
ImageArray <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>W<span style="color: #339933;">*</span>H<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> CurrActiveBuffer <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Current active buffer index</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// Mainloop</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">int</span> j<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> j<span style="color: #339933;">&lt;</span>H<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>W<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// ERROR! Write to same buffer. Not possible in gpu shader</span>
		<span style="color: #666666; font-style: italic;">//Image1[i+j*W] = Image1[i+j*W] * 2;  // Mul by 2</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Ping-pong version</span>
		<span style="color: #000066; font-weight: bold;">int</span> src <span style="color: #339933;">=</span> CurrActiveBuffer<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Current active buffer (Input)</span>
		<span style="color: #000066; font-weight: bold;">int</span> dest <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span>CurrActiveBuffer<span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// Back buffer (Output)</span>
		ImageArray<span style="color: #009900;">&#91;</span>dest<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>i<span style="color: #339933;">+</span>j<span style="color: #339933;">*</span>W<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> ImageArray<span style="color: #009900;">&#91;</span>src<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>i<span style="color: #339933;">+</span>j<span style="color: #339933;">*</span>W<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// Mul by 2</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Swap back and front buffers (read becomes write and vice-versa)</span>
CurrActiveBuffer <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span>CurrActiveBuffer<span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// CurrActiveBuffer ? 0 : 1;</span></pre></div></div>

<p style="text-align: justify;">As you can see we start with buffer 0. That&#8217;s where we get out data from (read) and write it to Buffer 1. Once the operation is done, we swap buffers every frame. This way we&#8217;ll be able to use last iteration&#8217;s data as input for the next iteration.</p>
<p style="text-align: justify;">Now let&#8217;s put this in OpenGL language. I will be using a FrameBufferObject (FBO) and 2 textures here. The framebuffer will be holding to both textures as 2 Color Attachments. So let&#8217;s get coding:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// Initialization</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #000066; font-weight: bold;">int</span> W <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> H <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> FboID<span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> TexID<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> CurrActiveBuffer <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// Current active buffer index</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Create the frambuffer</span>
glGenFramebuffersEXT<span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">1</span>, <span style="color: #339933;">&amp;</span>FboID <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
glBindFramebufferEXT<span style="color: #009900;">&#40;</span> GL_FRAMEBUFFER_EXT, FboID <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Create 2 textures for input/output.</span>
glGenTextures<span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">2</span>, TexID <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	glBindTexture<span style="color: #009900;">&#40;</span> GL_TEXTURE_2D, TexID<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	glTexParameteri<span style="color: #009900;">&#40;</span> GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	glTexParameteri<span style="color: #009900;">&#40;</span> GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	glTexParameteri<span style="color: #009900;">&#40;</span> GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	glTexParameteri<span style="color: #009900;">&#40;</span> GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">// RGBA8 buffer</span>
	glTexImage2D<span style="color: #009900;">&#40;</span> GL_TEXTURE_2D, <span style="color: #cc66cc;">0</span>, GL_RGBA, W, H, <span style="color: #cc66cc;">0</span>, GL_RGBA, GL_UNSIGNED_BYTE, <span style="color: #000066; font-weight: bold;">NULL</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> _hasMipmapping <span style="color: #009900;">&#41;</span>  glGenerateMipmapEXT<span style="color: #009900;">&#40;</span> GL_TEXTURE_2D <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Now attach textures to FBO</span>
<span style="color: #000066; font-weight: bold;">int</span> src <span style="color: #339933;">=</span> CurrActiveBuffer<span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> dest <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span>CurrActiveBuffer<span style="color: #339933;">;</span>
glFramebufferTexture2DEXT<span style="color: #009900;">&#40;</span> GL_FRAMEBUFFER_EXT, 
                           GL_COLOR_ATTACHMENT0_EXT, 
                           GL_TEXTURE_2D, TexID<span style="color: #009900;">&#91;</span>src<span style="color: #009900;">&#93;</span>, <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
glFramebufferTexture2DEXT<span style="color: #009900;">&#40;</span> GL_FRAMEBUFFER_EXT, 
                           GL_COLOR_ATTACHMENT1_EXT, 
                           GL_TEXTURE_2D, TexID<span style="color: #009900;">&#91;</span>dest<span style="color: #009900;">&#93;</span>, <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// Mainloop</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #000066; font-weight: bold;">int</span> src <span style="color: #339933;">=</span> CurrActiveBuffer<span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> dest <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span>CurrActiveBuffer<span style="color: #339933;">;</span>
&nbsp;
FBO.<span style="color: #006633;">Bind</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
glDrawBuffer<span style="color: #009900;">&#40;</span> dest <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
glBindTexture<span style="color: #009900;">&#40;</span> GL_TEXTURE_2D, TexID<span style="color: #009900;">&#91;</span>src<span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
ShaderProgram.<span style="color: #006633;">SetTextureUniform</span><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
RenderScene<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
FBO.<span style="color: #006633;">Unbind</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">// Swap back and front buffers (read becomes write and vice-versa)</span>
CurrActiveBuffer <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span>CurrActiveBuffer<span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// CurrActiveBuffer ? 0 : 1;</span></pre></div></div>

<p style="text-align: justify;">Why would you want to ping-pong? Well for instance imagine you are doing a water effect in the gpu. You&#8217;ll need to access data from your previous buffer right? Using the CPU that would be trivial as you have the last frame&#8217;s memory buffer allocated somewhere which you can read/write access directly. That doesn&#8217;t really work on the gpu side that way (but we&#8217;re getting closer with CL, CUDA, DC) </p>
<p>Have fun.</p>
<p><a href="http://flattr.com/thing/40440/Ping-pong-technique-explained" target="_blank"><br />
<img src="http://api.flattr.com/button/button-compact-static-100x17.png" alt="Flattr this" title="Flattr this" border="0" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelnerve.com/v/2010/07/20/pingpong-technique/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Evaluate a Cubic Bézier on GPU</title>
		<link>http://www.pixelnerve.com/v/2010/05/11/evaluate-a-cubic-bezier-on-gpu/</link>
		<comments>http://www.pixelnerve.com/v/2010/05/11/evaluate-a-cubic-bezier-on-gpu/#comments</comments>
		<pubDate>Tue, 11 May 2010 02:48:41 +0000</pubDate>
		<dc:creator>victormartins</dc:creator>
				<category><![CDATA[Graphics programming]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[bezier]]></category>
		<category><![CDATA[geometry shader]]></category>
		<category><![CDATA[gpu]]></category>
		<category><![CDATA[shader]]></category>
		<category><![CDATA[tesselation]]></category>

		<guid isPermaLink="false">http://www.pixelnerve.com/v/?p=1108</guid>
		<description><![CDATA[I&#8217;ve made an application as an example for this thread on how to compute/evaluate a Cubic Bézier Curve using a Geometry Shader. The formula is pretty straightforward as described by this wikipedia article (look for Cubic Bézier Curve). I will not go over the bézier math or theory. I assume you have some knowledge in [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I&#8217;ve made an application as an example for this <a href="http://processing.org/discourse/yabb2/YaBB.pl?num=1273399193/5#5" target="_blank">thread</a> on how to compute/evaluate a Cubic Bézier Curve using a Geometry Shader. The formula is pretty straightforward as described by this <a href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve" target="_blank">wikipedia article</a> (look for Cubic Bézier Curve). I will not go over the bézier math or theory. I assume you have some knowledge in shader programming (GLSL is the case) and some math background would help, while not really a need. All that said, let&#8217;s get to work.</p>
<p style="text-align: justify;">On this case we will need 4 points: 2 anchor points (the line end points) and 2 control points. The control points won&#8217;t really touch the curve, they work more as directional information on the curve itself.</p>
<p style="text-align: justify;">As we need to send this data to the shader i have decided to use  LINES as input primitive, 2 points define a line so it&#8217;s perfect, we&#8217;ll use that for the 2 anchor points. As for the control points 2 different texture units (glMultiTexCoord3f) attached to the line&#8217;s vertex data will do. Using geometry shaders besides setting the input primitive type we also need to set the output type. LINE_STRIP is fine, as it works perfectly for what we&#8217;re doing. That&#8217;s all on the application side.</p>
<p style="text-align: justify;">On the vertex shader side it&#8217;s pretty simple:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #009900;">&#91;</span>VERTEX SHADER<span style="color: #009900;">&#93;</span>
<span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">void</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    gl_FrontColor <span style="color: #339933;">=</span> gl_Color<span style="color: #339933;">;</span>
    ControlPoint1 <span style="color: #339933;">=</span> gl_MultiTexCoord0.<span style="color: #006633;">xyz</span><span style="color: #339933;">;</span>
    ControlPoint2 <span style="color: #339933;">=</span> gl_MultiTexCoord1.<span style="color: #006633;">xyz</span><span style="color: #339933;">;</span>
&nbsp;
    gl_Position <span style="color: #339933;">=</span> gl_Vertex<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p style="text-align: justify;">What the code is doing is sending the data further down the pipeline to the geometry shader, where all the magic happens. At this stage, having both Anchor and Control points we can now define the curve by a given detail. Think of detail as a number of step-points along the curve which makes it look smoother or flatten (tesselation, subdivision, smoothing, etc).</p>
<p style="text-align: justify;">Both control points are sent by the application for the geometry shader, still, as in the the vertex shader comes before the geometry shader, we will need to send them down on the vertex-shader, otherwise the GS won&#8217;t be able to &#8220;see&#8221; them (i know, hurray for Cg). We&#8217;re now almost done. By using the function from the above link(s) and as shown below we compute the curve with a given detail on the geometry shader, by generating new vertices along the curve purely on the gpu side. I think it to be pretty straightforward and the code should be self-explanatory.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #009900;">&#91;</span>GEOMETRY SHADER<span style="color: #009900;">&#93;</span>
uniform <span style="color: #000066; font-weight: bold;">int</span> g_Detail<span style="color: #339933;">;</span>
varying in vec3 ControlPoint1<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
varying in vec3 ControlPoint2<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Found in nvidia sdk</span>
vec3 evaluateBezierPosition<span style="color: #009900;">&#40;</span> vec3 v<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span>, <span style="color: #000066; font-weight: bold;">float</span> t <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    vec3 p<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">float</span> OneMinusT <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1.0</span> <span style="color: #339933;">-</span> t<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">float</span> b0 <span style="color: #339933;">=</span> OneMinusT<span style="color: #339933;">*</span>OneMinusT<span style="color: #339933;">*</span>OneMinusT<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">float</span> b1 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3.0</span><span style="color: #339933;">*</span>t<span style="color: #339933;">*</span>OneMinusT<span style="color: #339933;">*</span>OneMinusT<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">float</span> b2 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3.0</span><span style="color: #339933;">*</span>t<span style="color: #339933;">*</span>t<span style="color: #339933;">*</span>OneMinusT<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">float</span> b3 <span style="color: #339933;">=</span> t<span style="color: #339933;">*</span>t<span style="color: #339933;">*</span>t<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> b0<span style="color: #339933;">*</span>v<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> b1<span style="color: #339933;">*</span>v<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> b2<span style="color: #339933;">*</span>v<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> b3<span style="color: #339933;">*</span>v<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    vec3 pos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    pos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> gl_PositionIn<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">xyz</span><span style="color: #339933;">;</span>
    pos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> ControlPoint1<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    pos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> ControlPoint2<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    pos<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> gl_PositionIn<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">xyz</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">float</span> OneOverDetail <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1.0</span> <span style="color: #339933;">/</span> <span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#40;</span>g_Detail<span style="color: #339933;">-</span><span style="color: #cc66cc;">1.0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>g_Detail<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">float</span> t <span style="color: #339933;">=</span> i <span style="color: #339933;">*</span> OneOverDetail<span style="color: #339933;">;</span>
        vec3 p <span style="color: #339933;">=</span> evaluateBezierPosition<span style="color: #009900;">&#40;</span> pos, t <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        gl_FrontColor <span style="color: #339933;">=</span> gl_FrontColorIn<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
        gl_Position <span style="color: #339933;">=</span> gl_ModelViewProjectionMatrix <span style="color: #339933;">*</span> vec4<span style="color: #009900;">&#40;</span> p.<span style="color: #006633;">xyz</span>, <span style="color: #cc66cc;">1.0</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        EmitVertex<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    EndPrimitive<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p style="text-align: justify;">What&#8217;s next? That is up to you. You&#8217;re not going to leave me with all the work, are you ?</p>
<p style="text-align: justify;">Download the <a title="GPUBézier" href="http://victamin.googlecode.com/files/GPUBezier.zip" target="_blank">example + source</a>.<br />
You will also need to install <a title="Vitamin" href="http://victamin.googlecode.com/files/vitamin_0_5_6.zip" target="_blank">Vitamin 0.5.6</a> as the project is built with it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelnerve.com/v/2010/05/11/evaluate-a-cubic-bezier-on-gpu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JavaCL, the new OpenCL4Java</title>
		<link>http://www.pixelnerve.com/v/2010/02/17/javacl-the-new-opencl4java/</link>
		<comments>http://www.pixelnerve.com/v/2010/02/17/javacl-the-new-opencl4java/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 07:11:21 +0000</pubDate>
		<dc:creator>victormartins</dc:creator>
				<category><![CDATA[Graphics programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Libraries]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[gpu]]></category>
		<category><![CDATA[JavaCL]]></category>
		<category><![CDATA[OpenCL]]></category>
		<category><![CDATA[opencl4java]]></category>
		<category><![CDATA[realtime]]></category>

		<guid isPermaLink="false">http://www.pixelnerve.com/v/?p=940</guid>
		<description><![CDATA[I have noticed that OpenCL4Java is on version 1.4beta by now and that my examples were crashing when running on a GPU device. Today i took the time to do something about it. I have downloaded the new version and have updated the examples to run with 1.4beta. Everything seems to work just fine now, [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I have noticed that OpenCL4Java is on version 1.4beta by now and that my examples were crashing when running on a GPU device. Today i took the time to do something about it. I have downloaded the new version and have updated the examples to run with 1.4beta. Everything seems to work just fine now, if you have a different opinion, please do let me know.</p>
<p style="text-align: justify;"><a rel="attachment wp-att-926" href="http://www.pixelnerve.com/v/2010/02/17/javacl-the-new-opencl4java/frame_2225/"><img title="GreeblesCL" src="http://www.pixelnerve.com/v/wp-content/uploads/2010/02/frame_2225-634x356.png" alt="" width="634" height="356" /></a></p>
<p style="text-align: justify;">Download: <a title="JavaCL" href="http://victamin.googlecode.com/files/JavaCL_1_4b.zip" target="_blank">http://victamin.googlecode.com/files/JavaCL_1_4b.zip</a></p>
<p style="text-align: justify;">Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelnerve.com/v/2010/02/17/javacl-the-new-opencl4java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>OpenCL 4 Java &amp; Processing</title>
		<link>http://www.pixelnerve.com/v/2009/10/30/opencl-4-java/</link>
		<comments>http://www.pixelnerve.com/v/2009/10/30/opencl-4-java/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 18:09:42 +0000</pubDate>
		<dc:creator>victormartins</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Libraries]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[cpu]]></category>
		<category><![CDATA[gpu]]></category>
		<category><![CDATA[OpenCL]]></category>
		<category><![CDATA[opencl4java]]></category>
		<category><![CDATA[particles]]></category>

		<guid isPermaLink="false">http://www.pixelnerve.com/v/?p=834</guid>
		<description><![CDATA[I finally took  the time to play with OpenCL. I was motivated by the particle example from Rui Madeira. After speaking with him, he gave me a few other links on more examples like Memo Akten&#8216;s 1.000.000 particles running with mouse interaction on the GPU, the very NVidia&#8217;s first OpenCL application example, etc. I was [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I finally took  the time to play with <a href="http://pt.wikipedia.org/wiki/OpenCL" target="_blank">OpenCL</a>. I was motivated by the particle example from <a href="http://vimeo.com/7298380" target="_blank">Rui Madeira</a>. After speaking with him, he gave me a few other links on more examples like <a href="http://www.memo.tv/" target="_blank">Memo Akten</a>&#8216;s 1.000.000 particles running with mouse interaction on the GPU, the very NVidia&#8217;s first OpenCL application example, etc. I was intriged!  So i took the day to play with <a href="http://code.google.com/p/nativelibs4java/wiki/OpenCL" target="_blank">OpenCL4Java</a> and ported Rui&#8217;s example to Java running on Processing&#8217;s IDE.  I&#8217;ve tested it with a Intel Quad core and i found the Rui&#8217;s sample to crash with GTX280 videocard. I didn&#8217;t gave it much thought but it might be for that for-loop in the program on the particle-particle iteration. In the other hand, Memo&#8217;s example ran easily on the gpu side. I should have made an example of mine, but it was easier to just port their examples and get things running. That was the main goal.</p>
<p style="text-align: justify;">I have only tested this under Windows XP 64bit with ATI Stream SDK and Nvidia drivers. If you find any problem, please report.<br />
One other thing: Memo&#8217;s example isn&#8217;t the real thing. It&#8217;s simply the CL program. So you won&#8217;t be able to get all the fuzzy million particles around. Not yet.</p>
<p style="text-align: left;">Library/Examples available here:<strong> </strong><a title="OpenCL4Java" href="http://victamin.googlecode.com/files/OpenCL4Java_1b.zip" target="_blank">http://victamin.googlecode.com/files/OpenCL4Java_1b.zip</a></p>
<p style="text-align: justify;">
<p style="text-align: justify;"><span style="text-decoration: underline;"><span style="color: #000000;">Installation steps:</span></span><br />
1. Copy the library to processing&#8217;s libraries folder<br />
2. Install ATI Stream SDK (i have packed the OpenCL.dll file, still you might have to install the whole pack). If you&#8217;re using Nvidia, install the OpenCL drivers and toolkit<br />
3. Open the example and run it.</p>
<p style="text-align: justify;">Enjoy and have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pixelnerve.com/v/2009/10/30/opencl-4-java/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

