<?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>Schabby&#039;s Blog</title>
	<atom:link href="http://schabby.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://schabby.de</link>
	<description>OpenGL, Java, Cassandra and other stuff that totally makes the world go round</description>
	<lastBuildDate>Fri, 27 Jan 2012 18:48:20 +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>Display Lists in OpenGL</title>
		<link>http://schabby.de/display-lists/</link>
		<comments>http://schabby.de/display-lists/#comments</comments>
		<pubDate>Sun, 25 Sep 2011 16:18:39 +0000</pubDate>
		<dc:creator>schabby</dc:creator>
				<category><![CDATA[OpenGL]]></category>

		<guid isPermaLink="false">http://schabby.de/?p=1014</guid>
		<description><![CDATA[This is a short OpenGL tutorial covering Display Lists with a code example. This should get you started when you want to enhance the rendering performance in your application.]]></description>
			<content:encoded><![CDATA[<p>This post is a brief tutorial on how to use display lists in OpenGL. An working and self-contained example is given below using LWJGL.<br />
Display lists are an essential feature of OpenGL to improve the rendering performance of your application. You can think of them as kind of a macro for OpenGL commands that you name, record and call at some point in your game. More specifically, you assign an integer handle to a sequence of OpenGL commands and call the commands identified by that handle when you need them.<span id="more-1014"></span></p>
<p><center><iframe width="420" height="315" src="http://www.youtube.com/embed/svkD0ouFHQU" frameborder="0" allowfullscreen></iframe></center></p>
<p>The advantage is mainly rendering speed which is greatly improved as you don&#8217;t pump your geometry into the rendering pipeline through individual <tt>glVertex</tt>, <tt>glNormal</tt> etc. commands in every render pass. Instead, you render your potentially complex geometry into a display list once and call ist every time you want the geometry to be rendered. This becomes enormously beneficial in a Java environment where you want to use as few JNI calls as possible.</p>
<p>The disadvantage is that a display list is fixed once it is uploaded to video memory. That means you cannot modify the order or geometry data after you compiled your list. Even if you only need to change one single <tt>glTranslate</tt> parameter, you would need to delete the entire list and create a new one.</p>
<p>So far for dry theory, let&#8217;s look at the example. Please note that this example makes use of my <a href="http://schabby.de/lwjgl-example-base/" title="LWJGL Example Base">LWJGL example base class</a> which I recommend to copy first so that the example runs out of the box.</p>
<p>We start with setting up the example class as follows. The <tt>setUp</tt> method is responsible for recording the GL commands into the &#8220;macro&#8221;.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> DisplayListExample <span style="color: #000000; font-weight: bold;">extends</span> LwjglExampleBase
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// handle (id) of the display list to be generated</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> displayListHandle <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// angle in degrees required for rotating the cubes</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">float</span> rotationAngle <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Sets up LWJGL and OpenGL and renders the 
	 * display list.
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> 
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// Set up LWJGL and OpenGL using the</span>
		<span style="color: #666666; font-style: italic;">// base class.</span>
		<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">setUp</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Generate one (!) display list.</span>
		<span style="color: #666666; font-style: italic;">// The handle is used to identify the</span>
		<span style="color: #666666; font-style: italic;">// list later.</span>
		displayListHandle <span style="color: #339933;">=</span> glGenLists<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Start recording the new display list.</span>
		glNewList<span style="color: #009900;">&#40;</span>displayListHandle, GL_COMPILE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Render a single cube</span>
		renderCube<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// End the recording of the current display list.</span>
		glEndList<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>Setting up a display list is a simple as that. Note the parameter <tt>GL_COMPILE</tt>. It tells OpenGL to only compile the list and not to draw it at the same time. Alternatively,<br />
one could use GL_COMPILE_AND_EXECUTE which would render the result while recording.</p>
<p>Lets us have a look into the <tt>renderCube()</tt> which basically contains the OpenGL commands to render a simple cube (without normals because we dont have lighting).</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> renderCube<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span> size<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">float</span> HALF <span style="color: #339933;">=</span> size<span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
		glBegin<span style="color: #009900;">&#40;</span>GL_QUADS<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		glColor3f<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		glVertex3f<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		glVertex3f<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		glVertex3f<span style="color: #009900;">&#40;</span>size<span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		glVertex3f<span style="color: #009900;">&#40;</span>size<span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
&nbsp;
		glColor3f<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		glVertex3f<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
		glVertex3f<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
		glVertex3f<span style="color: #009900;">&#40;</span>size<span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		glVertex3f<span style="color: #009900;">&#40;</span>size<span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
&nbsp;
		glColor3f<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		glVertex3f<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
		glVertex3f<span style="color: #009900;">&#40;</span>size<span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		glVertex3f<span style="color: #009900;">&#40;</span>size<span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		glVertex3f<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
		glColor3f<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		glVertex3f<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
		glVertex3f<span style="color: #009900;">&#40;</span>size<span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		glVertex3f<span style="color: #009900;">&#40;</span>size<span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		glVertex3f<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
		glColor3f<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		glVertex3f<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
		glVertex3f<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		glVertex3f<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		glVertex3f<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
&nbsp;
		glColor3f<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		glVertex3f<span style="color: #009900;">&#40;</span>size<span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
		glVertex3f<span style="color: #009900;">&#40;</span>size<span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		glVertex3f<span style="color: #009900;">&#40;</span>size<span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		glVertex3f<span style="color: #009900;">&#40;</span>size<span style="color: #339933;">-</span>HALF, <span style="color: #339933;">-</span>HALF, size<span style="color: #339933;">-</span>HALF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
		glEnd<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>Now comes the interesting part of calling the display list. To illustrate its usefulness, I draw a grid of 5&#215;5 of the same cube and only change its position and rotation.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Render 5x5 cubes centered around the origin. Each
	 * cubes has a slightly different rotation to make this
	 * example look more interesting.
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> render<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> 
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// In each render pass, add one degree to rotation</span>
		<span style="color: #666666; font-style: italic;">// angle.</span>
		rotationAngle <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">1</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> x <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> x <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span> x<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> z <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> z <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span> z<span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">// Save current MODELVIEW matrix to </span>
				<span style="color: #666666; font-style: italic;">// stack.</span>
				glPushMatrix<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #666666; font-style: italic;">// position next cube</span>
				glTranslatef<span style="color: #009900;">&#40;</span>x<span style="color: #339933;">*</span><span style="color: #cc66cc;">2</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">4</span>,<span style="color: #cc66cc;">0</span>, z<span style="color: #339933;">*</span><span style="color: #cc66cc;">2</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #666666; font-style: italic;">// rotate next cube</span>
				glRotatef<span style="color: #009900;">&#40;</span>x<span style="color: #339933;">*</span>z<span style="color: #339933;">*</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">+</span>rotationAngle, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #666666; font-style: italic;">// Call the display list which renders</span>
				<span style="color: #666666; font-style: italic;">// the cube.</span>
				glCallList<span style="color: #009900;">&#40;</span>displayListHandle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #666666; font-style: italic;">// Remove current MODELVIEW Matrix from</span>
				<span style="color: #666666; font-style: italic;">// stack.</span>
				glPopMatrix<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And that&#8217;s it! Pretty easy, huh? To conclude the example I provide the <tt>main()</tt> method necessary to run the example. Also, please bear in mind that you need <a href="http://schabby.de/lwjgl-example-base/">LwjglExampleBase</a> to run the example.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> argv<span style="color: #009900;">&#41;</span> 
	<span style="color: #009900;">&#123;</span>
		DisplayListExample example <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DisplayListExample<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		example.<span style="color: #006633;">setUp</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		example.<span style="color: #006633;">gameLoop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Alright, we are done with the tutorial. If you liked the post, please leave a comment and let me know if you have questions or found a bug.</p>
<p>Cheers, Johannes</p>
]]></content:encoded>
			<wfw:commentRss>http://schabby.de/display-lists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenGL Picking in 3D</title>
		<link>http://schabby.de/picking-opengl-ray-tracing/</link>
		<comments>http://schabby.de/picking-opengl-ray-tracing/#comments</comments>
		<pubDate>Mon, 19 Sep 2011 22:25:54 +0000</pubDate>
		<dc:creator>schabby</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[OpenGL]]></category>

		<guid isPermaLink="false">http://schabby.de/?p=964</guid>
		<description><![CDATA[There are two common ways to accomplish picking: Switching OpenGL to "selection mode" and tracing a line shot from your 2D view screen through the 3D scene. In this opengl picking tutorial I cover the latter and provide a code example.]]></description>
			<content:encoded><![CDATA[<p>This blog post explains a common and versatile approach to OpenGL picking called &#8220;ray picking&#8221;. A code example is given below.</p>
<p>Picking is the process of finding objects in you scene based on user input. Most commonly, you want to determine what object a user has clicked with his mouse. In this case the 2D mouse coordinates serve as a reference on the view port to identify the projected objected that has been clicked. A similar scenario is a first person shooter, where the gun serves as the picking pointer, however in world space coordinates. If you shoot your gun, the trajectory of the bullet is traced through your scene and collisions are detected.<span id="more-964"></span></p>
<div id="attachment_996" class="wp-caption aligncenter" style="width: 473px"><img src="http://schabby.de/wp-content/uploads/2011/09/screenshot-opengl-picking.png" alt="Screenshot OpenGL Picking" title="Screenshot OpenGL Picking" width="463" height="363" class="size-full wp-image-996" /><p class="wp-caption-text">A screenshot showing a hex map in an LWJGL application with a selected tile as an example for 3D picking</p></div>
<h3>OpenGL Selection Mode vs. Ray Picking</h3>
<p>There are two common ways of implementing picking. The first one makes use of a special OpenGL feature in which you render your scene in a so-called &#8220;selection mode&#8221;. In selection mode, OpenGL does not render to the frame buffer but gathers depths information of the objects with is later read at the point where your picking occurs. The second approach is called &#8220;Ray Picking&#8221; and is independent from OpenGL and simulates a line that is shot through the scene until it hits an object. I personally prefer the second approach for the following reasons:</p>
<ul>
<li>You don&#8217;t need an additional render pass. A render pass can take some considerable amount of time and special clipping/culling code is required to only render the small part of the scene which you want to perform the picking on. In addition, you render a less complex scene (omitting textures, lighting, normals, etc) in selection mode if possible which can add a high degree of complexity to your drawing routines (imagine breaking up display lists). Ray picking obviously requires some code to trace the ray through your scene, but this is usually less complex.</li>
<li>Ray picking can be done independently from the rest of the game code as a simultaneous and &#8220;read-only&#8221; operation on the scene graph. In some environments such as AWT/JOGL where the input devices are handled by a separate thread, your picking code can run as part of the handler thread and does not impact the performance of the rest of the game. This comes in handy especially in scenarios where you need to perform picking very often (eg. mouse hovering, target laser on the in-game gun).</li>
<li>In pretty much all Java environments, calling OpenGL takes a considerable amount of time due to JNI. It is therefore beneficial to minimize the number OpenGL calls. Rendering in selection mode would mean additional OpenGL calls that I rather substitute with ray picking.</li>
</ul>
<p>However, there are scenarios where ray picking is simply inferior or impractical. Consider picking in a scene with a lot of small details (eg. tree with little branches and leaves) or if you need to know the individual polygon/triangle that you picked. I will therefore cover both approaches, starting with ray picking.</p>
<p><a href="http://schabby.de/wp-content/uploads/2011/09/ray-packing.png"><img class="alignright" title="Picking by Ray Tracing" src="http://schabby.de/wp-content/uploads/2011/09/ray-packing.png" alt="Picking by Ray Tracing" width="465" height="289" /></a></p>
<h3>Ray Picking</h3>
<p>Ray picking is the process of shooting a line (ie. &#8220;ray&#8221;) from the camera through the 2D viewscreen (where the 3D scene is projected on) into the scene until it hits an object. To do so, we need to know the camera and the point on the viewscreen (eg. mouse cursor position). The first point is trivial, however the second point is a bit more difficult to determine. Let&#8217;s say we have a 2D point on the viewscreen (x, y) and now want to map this point into world coordinates. One way would be to make use of the inverted viewing matrix, but inverting a matrix is usually an expensive undertaking. Instead, we compute the position of the plane of the viewscreen in world space and map the 2D point on this plane and from there into world space.</p>
<p>The algorithm in pseudo code follows below. Note that <tt>cameraLookAt</tt> is the 3D point where the camera looks at (as used on <tt>glLookat</tt>), <tt>cameraPosition</tt> is the current position of the camera in world space and <tt>cameraUp</tt> is the up vector of the camera.</p>
<pre style="border:1px gray solid;padding:5px;background-color:RGB(250, 250, 250);">x = getMouseX() // scalar
y = getMouseY() // scalar

view = cameraLookAt - cameraPosition // 3D float vector
normalize view

h = crossProduct( view, cameraUp ) // 3D float vector
normalize h

v = crossProduct( h, view) // 3D float vector
normalize v</pre>
<p>ok, so far for <tt>h</tt> and <tt>v</tt>. We now need to compute the lengths of <tt>h</tt> and <tt>v</tt> in the view port. In my example I assume that you set up your frustum by a field of view angle in degrees (<tt>fovy</tt>) as commonly the case with <tt>glFrustum</tt>. Let <tt>nearClippingDistance</tt> be the distance to the near clipping plane and <tt>width/height</tt> the ratio of the view port width divided by the viewport heigth.</tt></tt></p>
<pre style="border:1px gray solid;padding:5px;background-color:RGB(250, 250, 250);">// convert fovy to radians
rad = fovy * PI / 180
vLength = tan( rad / 2 ) * nearClippingPlaneDistance
hLength = vLength * (width / height)

scale v by vLength
scale h by hLength</pre>
<p>The two scalars <tt>vLength</tt> and <tt>hLength</tt> in combinaton with <tt>v</tt> and <tt>h</tt> help spanning the view port plane extending from the center point. At this point it is worth mentioning that it may make sense to only compute <tt>h</tt> and <tt>v</tt> when you update the camera orientation because the normalization involves a square root which is a relatively expensive operation (actually <tt>tan</tt> may also be avoided).</p>
<p>Now it is time to map the 2D mouse coordinates onto the view port plane.</p>
<pre style="border:1px gray solid;padding:5px;background-color:RGB(250, 250, 250);">// translate mouse coordinates so that the origin lies in the center
// of the view port
x -= width / 2
y -= height / 2

// scale mouse coordinates so that half the view port width and height
// becomes 1
y /= (height / 2)
x /= (width / 2)

// linear combination to compute intersection of picking ray with
// view port plane
pos = cameraPos + view + h*x + v*y

// compute direction of picking ray by subtracting intersection point
// with camera position
dir = pos - cameraPos</pre>
<p>That's pretty much it. We now got <tt>pos</tt> as the intersection point of the picking ray in the view port plane and the picking ray direction <tt>dir</tt>. This describes a line that can now be used to intersect with the individual objects of the scene.</p>
<pre style="border:1px gray solid;padding:5px;background-color:RGB(250, 250, 250);">// brute force
for all objects in the scene
  test for intersection and keep closest
end for</pre>
<p>So by intersecting the picking ray with all your visible objects in your scene while keeping track of the distance, you determine the object that is hit by your mouse cursor.<br />
Checking all objects in our scene may not be very efficient though. So in a first attempt I recommend to test only objects that lie (partly) within your viewing frustum. Under normal circumstances you got that code already in your scene graph as part of the software culling routine when pumping obects into the render pipeline.</p>
<p>I hope this helped. If you liked the post or if you got questions, ideas hints or found a problem, please leave a comment. I am trying to answer as quickly as possible. Also, if you want me to send you the source code of this example please let me know, I am happy to share the code.</p>
]]></content:encoded>
			<wfw:commentRss>http://schabby.de/picking-opengl-ray-tracing/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>LWJGL Example Base</title>
		<link>http://schabby.de/lwjgl-example-base/</link>
		<comments>http://schabby.de/lwjgl-example-base/#comments</comments>
		<pubDate>Thu, 25 Aug 2011 15:30:57 +0000</pubDate>
		<dc:creator>schabby</dc:creator>
				<category><![CDATA[OpenGL]]></category>

		<guid isPermaLink="false">http://schabby.de/?p=1006</guid>
		<description><![CDATA[LWJGL base class for most of the examples and tutorials in my blog.]]></description>
			<content:encoded><![CDATA[<p>This post contains the LWJGL base class that I use throughout the tutorials and examples. It basically sets up LWJGL and OpenGL which I otherwise would have to do over and over again in the individual examples. In addition, this makes the code in the tutorials and examples more readable by focusing on the important things.<br />
<span id="more-1006"></span><br />
So let&#8217;s dive into the code. I basically provide this class as a copy-paste template so that you have as little hassle as possible to set up the examples.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// import GL11 statically which makes the GL code</span>
<span style="color: #666666; font-style: italic;">// more readable</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">static</span> org.<span style="color: #006633;">lwjgl</span>.<span style="color: #006633;">opengl</span>.<span style="color: #006633;">GL11</span>.<span style="color: #339933;">*;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// some more LWJGL imports that I omitted for brevity.</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">abstract</span> <span style="color: #000000; font-weight: bold;">class</span> LwjglExampleBase 
<span style="color: #009900;">&#123;</span>
	<span style="color: #008000; font-style: italic; font-weight: bold;">/** width of window */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> viewportWidth <span style="color: #339933;">=</span> <span style="color: #cc66cc;">800</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/** height of window */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> viewportHeight <span style="color: #339933;">=</span> <span style="color: #cc66cc;">600</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Rudimentary OpenGL setup with LWJGL. Use perspective
	 * projection with a field of view of 45 degrees. 
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> 
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// set up LWJGL display</span>
		<span style="color: #000000; font-weight: bold;">try</span>
		<span style="color: #009900;">&#123;</span>
			Display.<span style="color: #006633;">setDisplayMode</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> DisplayMode<span style="color: #009900;">&#40;</span>viewportWidth, viewportHeight<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			Display.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>LWJGLException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><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;">// init viewport and projection matrix</span>
		glViewport<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, viewportWidth, viewportHeight<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		glMatrixMode<span style="color: #009900;">&#40;</span>GL11.<span style="color: #006633;">GL_PROJECTION</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		glLoadIdentity<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		GLU.<span style="color: #006633;">gluPerspective</span><span style="color: #009900;">&#40;</span> 45.0f, <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#41;</span>viewportWidth<span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#41;</span>viewportHeight, 1.0f, 200.0f <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		glMatrixMode<span style="color: #009900;">&#40;</span>GL11.<span style="color: #006633;">GL_MODELVIEW</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		glEnable<span style="color: #009900;">&#40;</span>GL_DEPTH_TEST<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		glShadeModel <span style="color: #009900;">&#40;</span>GL_SMOOTH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		glClearColor <span style="color: #009900;">&#40;</span>0f, 0f, 0f, 0f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Game loop is basically an infinite loop that runs
	 * until the window is closed. It calls the abstract
	 * render() method which is to be implemented by the
	 * specific example class. 
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> gameLoop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>Display.<span style="color: #006633;">isCloseRequested</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			glClear<span style="color: #009900;">&#40;</span>GL_COLOR_BUFFER_BIT <span style="color: #339933;">|</span> GL_DEPTH_BUFFER_BIT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			glLoadIdentity<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			GLU.<span style="color: #006633;">gluLookAt</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">15</span>,<span style="color: #cc66cc;">0</span>, 
					<span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, 
					<span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                        <span style="color: #666666; font-style: italic;">// call the abstract render method implemented by the</span>
                        <span style="color: #666666; font-style: italic;">// extending class (eg. example, tutorial, etc.)</span>
			render<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
                        <span style="color: #666666; font-style: italic;">// sync to 60 frames per second</span>
			Display.<span style="color: #006633;">update</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			Display.<span style="color: #006633;">sync</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		Display.<span style="color: #006633;">destroy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #008000; font-style: italic; font-weight: bold;">/**
         * Abstract render method which is supposed to be
         * implemented by the extending tutorial or example
         * class.
         */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">abstract</span> <span style="color: #000066; font-weight: bold;">void</span> render<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> getViewportWidth<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> viewportWidth<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setViewportWidth<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> viewportWidth<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">viewportWidth</span> <span style="color: #339933;">=</span> viewportWidth<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> getViewportHeight<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> viewportHeight<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setViewportHeight<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> viewportHeight<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">viewportHeight</span> <span style="color: #339933;">=</span> viewportHeight<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>That&#8217;s already it! Please make use of it as good as you can and leave a comment if you liked it or have questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://schabby.de/lwjgl-example-base/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Lenovo ThinkPad Keyboard Removal</title>
		<link>http://schabby.de/lenovo-thinkpad-keyboard-removal/</link>
		<comments>http://schabby.de/lenovo-thinkpad-keyboard-removal/#comments</comments>
		<pubDate>Sat, 23 Jul 2011 14:48:09 +0000</pubDate>
		<dc:creator>schabby</dc:creator>
				<category><![CDATA[Dies Und Das]]></category>

		<guid isPermaLink="false">http://schabby.de/?p=917</guid>
		<description><![CDATA[I am posting this little tutorial on how to remove the keyboard from a current Lenovo ThinkPad (in my case it&#8217;s a W510 Thinkpad) because the first time I tried this, I totally failed. Removing the screws on the back of the machine is the easiest part, but right after that I simply could not [...]]]></description>
			<content:encoded><![CDATA[<p>I am posting this little tutorial on how to remove the keyboard from a current Lenovo ThinkPad (in my case it&#8217;s a W510 Thinkpad) because the first time I tried this, I totally failed.<span id="more-917"></span> Removing the screws on the back of the machine is the easiest part, but right after that I simply could not get the keyboard off, even I closely followed Lenovos official guide which says your supposed to &#8220;push&#8221; the keyboard gently with two hands towards the screen. I searched the web for hours checking each tutorial and video I could find. Eventually, I found a side-note in some forum where a guy indirectly hinted to a different way. And here it comes (I took some pictures for illustration):</p>
<div style="height: 250px;"><strong>Step 1: Remove Screws</strong><br />
<a href="http://schabby.de/wp-content/uploads/2011/07/IMAG0330.jpg"><img class="alignright size-medium wp-image-919" title="Lenovo Thinkpad turned over" src="http://schabby.de/wp-content/uploads/2011/07/IMAG0330-300x179.jpg" alt="" width="300" height="179" /></a> Turn your Thinkpad so that it lays on the closed screen and look for the screws that have a little keyboard icon. Remove those screws. Note that you may have to remove the RAM plating first which covers an additional screw for the keyboard.</div>
<div style="height: 450px;"><strong>Step 2: Find Openings in Keyboard Border</strong><br />
<a href="http://schabby.de/wp-content/uploads/2011/07/IMAG0333.jpg"><img class="alignright size-medium wp-image-920" title="Thinpad Keyboard Right Gap" src="http://schabby.de/wp-content/uploads/2011/07/IMAG0333-300x179.jpg" alt="" width="300" height="179" /></a>Now turn over the ThinkPad again and open the screen. On the lower end of the keyboard you will notice tha the frame of the keyboard has little gaps. Find these gaps. There is one right below the arrow keys on the right hand side and one below the left alt-key. The pictures to the right shall help you understand what I mean <img src='http://schabby.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<br />&nbsp;<br />&nbsp;<br />&nbsp;<br />
<a href="http://schabby.de/wp-content/uploads/2011/07/IMAG0334.jpg"><img class="alignright size-medium wp-image-921" title="Thinpad Keyboard Left Gap" src="http://schabby.de/wp-content/uploads/2011/07/IMAG0334-300x179.jpg" alt="" width="300" height="179" /></a></div>
<div style="height: 250px;"><strong>Step 3: Lever off Keyboard</strong><br />
<a href="http://schabby.de/wp-content/uploads/2011/07/IMAG0336.jpg"><img src="http://schabby.de/wp-content/uploads/2011/07/IMAG0336-300x179.jpg" alt="" title="Levering off keyboard" width="300" height="179" class="alignright size-medium wp-image-922" /></a>Now get a screwdriver and gently lever off the Keyboard by gently twisting the screwdriver on the opening. You will notice how easily the keyboars will come off. From there on you can handle the rest.
</div>
]]></content:encoded>
			<wfw:commentRss>http://schabby.de/lenovo-thinkpad-keyboard-removal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>affiliate2go &#8211; iPhone App</title>
		<link>http://schabby.de/affiliate2go/</link>
		<comments>http://schabby.de/affiliate2go/#comments</comments>
		<pubDate>Thu, 31 Mar 2011 10:26:04 +0000</pubDate>
		<dc:creator>schabby</dc:creator>
				<category><![CDATA[Dies Und Das]]></category>

		<guid isPermaLink="false">http://schabby.de/?p=903</guid>
		<description><![CDATA[Vor einigen Monaten entschlossen wir uns, eine iPhone App zu bauen mit der Publisher ihre Sales-Statistiken aus all ihren Partnernetzwerken beziehen können. Das ware die Geburtstunde für affiliate2go. Die Idee &#8220;Publisher Salesdaten aufs iPhone&#8221; ist nicht neu, neu ist aber, dass es nun eine einzelne App gibt, die mehrere Affiliate Netzwerke gleichzeitig anbindet. Bisher brauchte [...]]]></description>
			<content:encoded><![CDATA[<p>Vor einigen Monaten entschlossen wir uns, eine iPhone App zu bauen mit der Publisher ihre Sales-Statistiken aus all ihren Partnernetzwerken beziehen können. Das ware die Geburtstunde für <a href="http://www.ladenzeile.de/apps.html">affiliate2go</a>. <span id="more-903"></span>Die Idee &#8220;Publisher Salesdaten aufs iPhone&#8221; ist nicht neu, neu ist aber, dass es nun eine einzelne App gibt, die mehrere Affiliate Netzwerke gleichzeitig anbindet. Bisher brauchte man für jedes Affiliate Netzwerk jeweils eine App um an die eigenen Daten zu gelanden. Ausserdem benutzen andere Apps einen fremd-gehosteten Webservice um die Daten erst über einen Server und dann aufbereitet aufs iPhone in die App zu laden. Damit könnten die App-Entwickler die Daten ihrer Kunden sehr leicht mitlesen. affiliate2go geht dagegen direkt auf die API der Affiliate Netzwerke um so einen Mittelsmann auszuschliessen.</p>
<p><img style="float:left" src="http://cdn.ladenzeile.de/img/apps/splash_screen.png" alt="affiliate2go iPhone App" />Genau das macht affiliate2go zu einer technisch anspruchsvollen App: Sie muss die Eigenheiten der APIs der Affiliate Netwerke implementieren und dabei insbesondere die (leider nicht trivialen) Authorisationsmechaniken abbilden. Glücklicher Weise haben wir bei ladenzeile sehr viel Erfahrung mit dem Beziehen von Salesdaten aus Affiliate Netzwerken gewonnen, sodass wir das nötige Rüstzeug haben um eine solche App zu basteln.</p>
<p>Das aktuelle Release bindet zwei Große Affiliate Netzwerke an: Zanox und Affili.net. Weitere Netzwerke sind in der Planung. Bisher ist die App kostenlos. Wir wollen in der aktuellen Phase aber insbesondere Userfeedback sammeln, sodass wir uns sehr über alle möglichen Formen der Rückmeldung freuen.</p>
<p>Hier nochmal der Link zur App: <a href="http://www.ladenzeile.de/apps.html">affiliate2go von ladenzeile</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://schabby.de/affiliate2go/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fly Me To The Moon</title>
		<link>http://schabby.de/fly-me-to-the-moon/</link>
		<comments>http://schabby.de/fly-me-to-the-moon/#comments</comments>
		<pubDate>Sat, 12 Mar 2011 17:50:00 +0000</pubDate>
		<dc:creator>schabby</dc:creator>
				<category><![CDATA[Dies Und Das]]></category>

		<guid isPermaLink="false">http://schabby.de/?p=887</guid>
		<description><![CDATA[Es ist nun fast zehn Jahre her, dass ich ein Instrument länger als 15 Minuten in der Hand hielt. Damals spielte ich einer Punk-Rock Band und versuchte mich an einer Reihe von Instrumenten, bis man mich aus Qualifikationsgründen zum Sänger umschulte. Dann zog ich aus Göttingen nach Berlin und von Berlin nach China, was unserer [...]]]></description>
			<content:encoded><![CDATA[<p>Es ist nun fast zehn Jahre her, dass ich ein Instrument länger als 15 Minuten in der Hand hielt. Damals spielte ich einer Punk-Rock Band und versuchte mich an einer Reihe von Instrumenten, bis man mich aus Qualifikationsgründen zum Sänger umschulte. Dann zog ich aus Göttingen nach Berlin und von Berlin nach China, was unserer Band ein Ende setzte. Als ich aus China zurück kam und wieder nach Berlin zog, hatte ich kurzzeitig nochmal eine Band namens &#8220;Die Vier Eukalyptischen Reiter&#8221; in der wir in einer Drum-Piano-Bass Kombination einen eigenwilligen Jazz aufzuspielen wussten. <span id="more-887"></span>Wir mieteten einen Raum im <a href="http://www.orwohaus.de/">Orwo-Haus</a> und hätten Tag und Nacht 24/7 spielen können. Nichtsdestotrotz fanden wir aufgrund von Karriere, Freundin, S-Bahnstreik und fehlender Inspiration insgesamt nur drei Mal Gelegenheit für wenigen Minuten zu proben. Immerhin: die dabei entstanden Aufnahmen sind weltklasse, nicht jungenfre und nicht länger als 15 Minuten.</p>
<p>Vor diesem Hintergrund grenzt es eigentlich an ein Wunder, dass ich im fortgeschrittenen Alter von knapp 30 noch einmal ein Saiteninstrument in die Hand nahm. Aber gestern wars geschenen und ich musizierte wundebare Kammermusik für vier Personen. Als (mitleweile) Jazz und Swing-Fans widmeten wir uns dem alten Superhit &#8220;<a href="http://en.wikipedia.org/wiki/Fly_Me_to_the_Moon">Hit Fly Me To The Moon</a>&#8221; und spielten den Song so wie wir es vor zehn Jahren gelernt haben. Klar also, dass ich auch heute die Gesangslinie wieder singen musste.</p>
<p>Das Ergebnis kann hier heruntergeladen werden:</p>
<div style="font-size:20px;text-align:center"><a href='http://schabby.de/wp-content/uploads/2011/03/Fly-Me-To-The-Moon.mp3'>Fly Me To The Moon.mp3</a></div>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://schabby.de/fly-me-to-the-moon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://schabby.de/wp-content/uploads/2011/03/Fly-Me-To-The-Moon.mp3" length="1657207" type="audio/mpeg" />
		</item>
		<item>
		<title>Wunschzettel Ladenzeile Gewinnspiel</title>
		<link>http://schabby.de/wunschzettel-ladenzeile-gewinnspiel/</link>
		<comments>http://schabby.de/wunschzettel-ladenzeile-gewinnspiel/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 14:37:56 +0000</pubDate>
		<dc:creator>schabby</dc:creator>
				<category><![CDATA[Dies Und Das]]></category>

		<guid isPermaLink="false">http://schabby.de/?p=876</guid>
		<description><![CDATA[Natürlich muss ich hier an dieser Stelle auch unser Gewinnspiel promoten. Es werden 5&#215;500 Euro verlost plus ein Sonderpreis von 1000 Euro. Echt ärgerlich dass ich selbst nicht an meinem Gewinnspiel teilnehmen darf Das Wunschzettel Gewinnspiel: Wunschzettel posten und mit etwas Glück 500 EUR gewinnen. Hier mitmachen: Ladenzeile Wunschzettel Gewinnspiel Pingulina Hochbett mit Rutsche und [...]]]></description>
			<content:encoded><![CDATA[<p>Natürlich muss ich hier an dieser Stelle auch unser Gewinnspiel promoten. Es werden 5&#215;500 Euro verlost plus ein Sonderpreis von 1000 Euro. Echt ärgerlich dass ich selbst nicht an meinem Gewinnspiel teilnehmen darf <img src='http://schabby.de/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  <span id="more-876"></span></p>
<style>*{margin:0;border:none;padding:0;font-family:Arial;}#lz_wishlist{width:100%;height:100%;text-align:center}#lz_wishlist a{color:#1C4C7C;text-decoration:underline;}#lz_wishlist img{-moz-border-shadow:none;background:none;border:none;padding:0;}#lz_wishlist #lz_center{padding:0;text-align:left;margin:0 auto;background-color:white;font-family:Arial;width:398px;border:1px solid #1C4C7C;}#lz_wishlist .lz_item{padding:3px 0;border-bottom:1px solid #CCCCCC;}#lz_wishlist .lz_icon{float:left;width:40px;border:1px solid #CCCCCC;margin-right:5px;}#lz_wishlist .lz_itemContent{overflow:hidden;float:left;width:331px;}#lz_wishlist .lz_itemName{display:block;width:9999em;color:#1C4C7C;line-height:14px;font-size:12px;display:block;}#lz_wishlist .lz_itemCat{line-height:14px;font-size:10px;}#lz_wishlist .lz_itemPrice{line-height:14px;font-size:10px;}#lz_wishlist a#lz_footer{display:block;height:18px;}</style>
<div id="lz_wishlist">
<div id="lz_center"><img src="http://cdn.ladenzeile.de/img/wishlist/header.gif" height="100" width="398"/>
<div style="padding:10px;width:378px;">
<div style="font-size:11px;color:#333333;padding-bottom:10px;border-bottom:1px solid #CCCCCC">Das Wunschzettel Gewinnspiel: Wunschzettel posten und mit etwas Glück 500 EUR gewinnen. Hier mitmachen: <a target="_blank" href="http://www.ladenzeile.de/wunschzettel/" style="color:#1C4C7C">Ladenzeile Wunschzettel Gewinnspiel</a></div>
<div class="lz_item">
<div class="lz_icon"><img src="http://cdn.ladenzeile.de/pingulina-hochbett-mit-rutsche-und-turm-i0002jtnf9.jpg" height="40" width="40"/></div>
<div class="lz_itemContent"><a class="lz_itemName" target="_blank" href="http://moebel.ladenzeile.de/pingulina-hochbett-mit-rutsche-und-turm-14117426.html">Pingulina Hochbett mit Rutsche und Turm</a>
<div class="lz_itemCat">gefunden in <a target="_blank" style="color:#1C4C7C" href="http://moebel.ladenzeile.de/baby-moebel-kindermoebel-kinderbetten-hochbetten/">Hochbetten</a></div>
<div class="lz_itemPrice">339,00 € * <span style="#999999">(Versand: 5,95 €)</span></div>
</div>
<div style="clear:both"></div>
</div>
<div class="lz_item">
<div class="lz_icon"><img src="http://cdn.ladenzeile.de/babybesteck-clown-wmf-i0002jj3co.jpg" height="40" width="40"/></div>
<div class="lz_itemContent"><a class="lz_itemName" target="_blank" href="http://moebel.ladenzeile.de/babybesteck-clown-wmf-2108223.html">Babybesteck CLOWN, WMF</a>
<div class="lz_itemCat">gefunden in <a target="_blank" style="color:#1C4C7C" href="http://moebel.ladenzeile.de/baby-moebel-kindermoebel-kinderbesteck/">Kinderbesteck</a></div>
<div class="lz_itemPrice">22,95 € * <span style="#999999">(Versand: 5,95 €)</span></div>
</div>
<div style="clear:both"></div>
</div>
<div class="lz_item">
<div class="lz_icon"><img src="http://cdn.ladenzeile.de/auerhahn-kinderbesteck-der-kleine-prinz-4tlg-auerhahn-i0002qgomg.jpg" height="40" width="40"/></div>
<div class="lz_itemContent"><a class="lz_itemName" target="_blank" href="http://moebel.ladenzeile.de/auerhahn-kinderbesteck-der-kleine-prinz-4tlg-auerhahn-16389844.html">Auerhahn Kinderbesteck DER KLEINE PRINZ &#8211; 4tlg., Auerhahn</a>
<div class="lz_itemCat">gefunden in <a target="_blank" style="color:#1C4C7C" href="http://moebel.ladenzeile.de/accessoires-besteck-besteckset/">Bestecksets</a></div>
<div class="lz_itemPrice">29,90 € * <span style="#999999">(Versand: 5,95 €)</span></div>
</div>
<div style="clear:both"></div>
</div>
<div class="lz_item">
<div class="lz_icon"><img src="http://cdn.ladenzeile.de/auerhahn-der-kleine-prinz-kinder-set-7-tlg-i0000yv04b.jpg" height="40" width="40"/></div>
<div class="lz_itemContent"><a class="lz_itemName" target="_blank" href="http://moebel.ladenzeile.de/auerhahn-der-kleine-prinz-kinder-set-7-tlg-9600932.html">Auerhahn Der kleine Prinz &#8211; Kinder-Set 7-tlg.</a>
<div class="lz_itemCat">gefunden in <a target="_blank" style="color:#1C4C7C" href="http://www.ladenzeile.de/auerhahn/">Auerhahn</a></div>
<div class="lz_itemPrice">42,90 € * <span style="#999999">(kostenloser Versand)</span></div>
</div>
<div style="clear:both"></div>
</div>
<div class="lz_item">
<div class="lz_icon"><img src="http://cdn.ladenzeile.de/steppjacke-exes-beere-i0001tgkcp.jpg" height="40" width="40"/></div>
<div class="lz_itemContent"><a class="lz_itemName" target="_blank" href="http://kindermode.ladenzeile.de/steppjacke-exes-beere-883142.html">Steppjacke, Exes, beere</a>
<div class="lz_itemCat">gefunden in <a target="_blank" style="color:#1C4C7C" href="http://kindermode.ladenzeile.de/maedchenmode-jacken-jacken/">Jacken für Mädchen</a></div>
<div class="lz_itemPrice">49,95 € * <span style="#999999">(Versand: 5,95 €)</span></div>
</div>
<div style="clear:both"></div>
</div>
<div class="lz_item">
<div class="lz_icon"><img src="http://cdn.ladenzeile.de/vorhaenge-fuer-hochbett-i0002ch8lr.jpg" height="40" width="40"/></div>
<div class="lz_itemContent"><a class="lz_itemName" target="_blank" href="http://moebel.ladenzeile.de/vorhaenge-fuer-hochbett-3211384.html">Vorhänge für Hochbett</a>
<div class="lz_itemCat">gefunden in <a target="_blank" style="color:#1C4C7C" href="http://moebel.ladenzeile.de/baby-moebel-kindermoebel-jugendzimmer/">Jugendzimmer</a></div>
<div class="lz_itemPrice">69,99 € * <span style="#999999">(Versand: 5,95 €)</span></div>
</div>
<div style="clear:both"></div>
</div>
<div class="lz_item">
<div class="lz_icon"><img src="http://cdn.ladenzeile.de/begehbares-anbauregal-silenta-made-in-germany-weiss-i0001uz0rp.jpg" height="40" width="40"/></div>
<div class="lz_itemContent"><a class="lz_itemName" target="_blank" href="http://moebel.ladenzeile.de/begehbares-anbauregal-silenta-made-in-germany-weiss-17282273.html">Begehbares Anbauregal, Silenta, Made in Germany, weiß</a>
<div class="lz_itemCat">gefunden in <a target="_blank" style="color:#1C4C7C" href="http://www.ladenzeile.de/silenta/">Silenta</a></div>
<div class="lz_itemPrice">349,00 € * <span style="#999999">(Versand: 5,95 €)</span></div>
</div>
<div style="clear:both"></div>
</div>
<div class="lz_item">
<div class="lz_icon"><img src="http://cdn.ladenzeile.de/silenta-hochbett-mit-treppe-made-in-germany-weiss-i0002leffr.jpg" height="40" width="40"/></div>
<div class="lz_itemContent"><a class="lz_itemName" target="_blank" href="http://moebel.ladenzeile.de/silenta-hochbett-mit-treppe-made-in-germany-weiss-21945931.html">Silenta, Hochbett mit Treppe, Made in Germany, weiß</a>
<div class="lz_itemCat">gefunden in <a target="_blank" style="color:#1C4C7C" href="http://moebel.ladenzeile.de/baby-moebel-kindermoebel-kinderbetten/">Kinderbetten</a></div>
<div class="lz_itemPrice">699,00 € * <span style="#999999">(Versand: 5,95 €)</span></div>
</div>
<div style="clear:both"></div>
</div>
<div class="lz_item">
<div class="lz_icon"><img src="http://cdn.ladenzeile.de/bsf-02214-210-0-kinderbesteck-4-teilig-eisbaer-i0001ncvxb.jpg" height="40" width="40"/></div>
<div class="lz_itemContent"><a class="lz_itemName" target="_blank" href="http://moebel.ladenzeile.de/bsf-02214-210-0-kinderbesteck-4-teilig-eisbaer-4161391.html">BSF 02214-210-0 Kinderbesteck 4-teilig Eisbär</a>
<div class="lz_itemCat">gefunden in <a target="_blank" style="color:#1C4C7C" href="http://www.ladenzeile.de/bsf/">BSF</a></div>
<div class="lz_itemPrice">20,00 € * <span style="#999999">(zuzüglich Versandkosten)</span></div>
</div>
<div style="clear:both"></div>
</div>
<div class="lz_item">
<div class="lz_icon"><img src="http://cdn.ladenzeile.de/pyjama-dunkelgrau-gestreift-i0001tjjgp.jpg" height="40" width="40"/></div>
<div class="lz_itemContent"><a class="lz_itemName" target="_blank" href="http://kindermode.ladenzeile.de/pyjama-dunkelgrau-gestreift-597883.html">Pyjama, dunkelgrau/gestreift</a>
<div class="lz_itemCat">gefunden in <a target="_blank" style="color:#1C4C7C" href="http://kindermode.ladenzeile.de/maedchenmode-nachtwaesche-schlafanzug/">Mädchen-Schlafanzüge </a></div>
<div class="lz_itemPrice">16,99 € * <span style="#999999">(Versand: 5,95 €)</span></div>
</div>
<div style="clear:both"></div>
</div>
<div style="font-size:10px;margin-top:10px;color:#666666">* Preis kann sich seit der letzten Aktualisierung erhöht haben! <a target="_blank" rel="nofollow" style="color:#666666" href="http://www.ladenzeile.de/impressum.html#pricehint">Weitere Infos</a></div>
</div>
<p><a id="lz_footer" target="_blank" href="http://www.ladenzeile.de/"><img src="http://cdn.ladenzeile.de/img/wishlist/footer.gif" height="18" width="398"/></a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://schabby.de/wunschzettel-ladenzeile-gewinnspiel/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JOGL Example &#8211; Tutorial</title>
		<link>http://schabby.de/jogl-example-hello-world/</link>
		<comments>http://schabby.de/jogl-example-hello-world/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 14:25:38 +0000</pubDate>
		<dc:creator>schabby</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[OpenGL]]></category>

		<guid isPermaLink="false">http://schabby.de/?p=858</guid>
		<description><![CDATA[If you want to get your feed wet with JOGL examples, you may want to check out my simple JOGL tutorial. The JOGL tutorial provides up2date, stand-alone and self-contained example code.]]></description>
			<content:encoded><![CDATA[<p>This getting started tutorial is intended for JOGL users that are mere beginners. It helps to setup a recent JOGL installation in Eclipse on Windows.<br />
<span id="more-858"></span><br />
First you need to download JOGL. This is actually more difficult than it sounds because the precompiled binary packages are a bit hidden in the new project site. Fortunately, I figured out <a href="http://schabby.de/jogl-download/">where you can download recent JOGL binaries</a>.</p>
<p>For this tutorial, I am using</p>
<ul>
<li><tt>jogl-b633-2012-01-23_20-37-13</tt>, and</li>
<li><tt>gluegen-b480-2012-01-23_16-49-04</tt>.</li>
</ul>
<p>This is how your project setup should look like:</p>
<p><a href="http://schabby.de/wp-content/uploads/2010/07/JOGLProjectSetup.png"><img src="http://schabby.de/wp-content/uploads/2010/07/JOGLProjectSetup.png" alt="JOGL Project Setup" title="JOGL Project Setup" width="310" height="346" class="aligncenter size-full wp-image-1033" /></a></p>
<p>So one you got the binaries, unpack the ZIP file somewhere. You will notice the <tt>jar</tt> folder with a number of JAR files. All you need is in that <tt>jar</tt> folder, because the DLL binaries are included in the JARs.</p>
<p>Create a new eclipse project (name doesnt matter) and add the following JARs on the classpath:</p>
<ul>
<li><tt>gluegen-rt-natives-windows-amd64.jar</tt></li>
<li><tt>gluegen-rt.jar</tt></li>
<li><tt>jogl-all-natives-windows-amd64.jar</tt></li>
<li><tt>gluegen-rt.jar</tt></li>
</ul>
<p>These files are the native part of the OpenGL binding and are linked via Java Native Interface (JNI). Since the DLLs are precompiled as part of the JAR files, you are almost ready to go.</p>
<p>Once you got that set up, create a package <tt>de.schabby.jogl.helloworld</tt> and copypaste the following two classes in the newly created package.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">de.schabby.jogl.helloworld</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.event.WindowAdapter</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.event.WindowEvent</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.media.opengl.GLCapabilities</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.media.opengl.GLProfile</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.media.opengl.awt.GLCanvas</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JFrame</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HelloWorld 
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> 
    <span style="color: #009900;">&#123;</span>
    	<span style="color: #666666; font-style: italic;">// setup OpenGL Version 2</span>
    	GLProfile profile <span style="color: #339933;">=</span> GLProfile.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>GLProfile.<span style="color: #006633;">GL2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	GLCapabilities capabilities <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GLCapabilities<span style="color: #009900;">&#40;</span>profile<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	<span style="color: #666666; font-style: italic;">// The canvas is the widget that's drawn in the JFrame</span>
    	GLCanvas glcanvas <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GLCanvas<span style="color: #009900;">&#40;</span>capabilities<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	glcanvas.<span style="color: #006633;">addGLEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Renderer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	glcanvas.<span style="color: #006633;">setSize</span><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">300</span>, <span style="color: #cc66cc;">300</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003399;">JFrame</span> frame <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">JFrame</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;Hello World&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        frame.<span style="color: #006633;">getContentPane</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span> glcanvas<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// shutdown the program on windows close event</span>
        frame.<span style="color: #006633;">addWindowListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">WindowAdapter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> windowClosing<span style="color: #009900;">&#40;</span><span style="color: #003399;">WindowEvent</span> ev<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003399;">System</span>.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        frame.<span style="color: #006633;">setSize</span><span style="color: #009900;">&#40;</span> frame.<span style="color: #006633;">getContentPane</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getPreferredSize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        frame.<span style="color: #006633;">setVisible</span><span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The <rr>Render.java</tt> class looks like follows. It implements <tt>GLEventListener</tt> which is the call-back implementaiton by JOGL to do all OpenGL rendering.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">de.schabby.jogl.helloworld</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.media.opengl.GL2</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.media.opengl.GLAutoDrawable</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.media.opengl.GLEventListener</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.media.opengl.glu.GLU</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> <span style="color: #003399;">Renderer</span> <span style="color: #000000; font-weight: bold;">implements</span> GLEventListener 
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">private</span> GLU glu <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GLU<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> display<span style="color: #009900;">&#40;</span>GLAutoDrawable gLDrawable<span style="color: #009900;">&#41;</span> 
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">final</span> GL2 gl <span style="color: #339933;">=</span> gLDrawable.<span style="color: #006633;">getGL</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getGL2</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        gl.<span style="color: #006633;">glClear</span><span style="color: #009900;">&#40;</span>GL2.<span style="color: #006633;">GL_COLOR_BUFFER_BIT</span> <span style="color: #339933;">|</span> GL2.<span style="color: #006633;">GL_DEPTH_BUFFER_BIT</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        gl.<span style="color: #006633;">glLoadIdentity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        gl.<span style="color: #006633;">glTranslatef</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>1.5f, 0.0f, <span style="color: #339933;">-</span>6.0f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        gl.<span style="color: #006633;">glBegin</span><span style="color: #009900;">&#40;</span>GL2.<span style="color: #006633;">GL_TRIANGLES</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
        gl.<span style="color: #006633;">glVertex3f</span><span style="color: #009900;">&#40;</span>0.0f, 1.0f, 0.0f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
        gl.<span style="color: #006633;">glVertex3f</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>1.0f, <span style="color: #339933;">-</span>1.0f, 0.0f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
        gl.<span style="color: #006633;">glVertex3f</span><span style="color: #009900;">&#40;</span>1.0f, <span style="color: #339933;">-</span>1.0f, 0.0f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
        gl.<span style="color: #006633;">glEnd</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>				
        gl.<span style="color: #006633;">glTranslatef</span><span style="color: #009900;">&#40;</span>3.0f, 0.0f, 0.0f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        gl.<span style="color: #006633;">glBegin</span><span style="color: #009900;">&#40;</span>GL2.<span style="color: #006633;">GL_QUADS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>           	
        gl.<span style="color: #006633;">glVertex3f</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>1.0f, 1.0f, 0.0f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
        gl.<span style="color: #006633;">glVertex3f</span><span style="color: #009900;">&#40;</span>1.0f, 1.0f, 0.0f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
        gl.<span style="color: #006633;">glVertex3f</span><span style="color: #009900;">&#40;</span>1.0f, <span style="color: #339933;">-</span>1.0f, 0.0f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
        gl.<span style="color: #006633;">glVertex3f</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>1.0f, <span style="color: #339933;">-</span>1.0f, 0.0f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
        gl.<span style="color: #006633;">glEnd</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>				
        gl.<span style="color: #006633;">glFlush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> displayChanged<span style="color: #009900;">&#40;</span>GLAutoDrawable gLDrawable, <span style="color: #000066; font-weight: bold;">boolean</span> modeChanged, <span style="color: #000066; font-weight: bold;">boolean</span> deviceChanged<span style="color: #009900;">&#41;</span> 
    <span style="color: #009900;">&#123;</span>
    	<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;displayChanged called&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> init<span style="color: #009900;">&#40;</span>GLAutoDrawable gLDrawable<span style="color: #009900;">&#41;</span> 
    <span style="color: #009900;">&#123;</span>
    	<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;init() called&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        GL2 gl <span style="color: #339933;">=</span> gLDrawable.<span style="color: #006633;">getGL</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getGL2</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        gl.<span style="color: #006633;">glClearColor</span><span style="color: #009900;">&#40;</span>0.0f, 0.0f, 0.0f, 0.0f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        gl.<span style="color: #006633;">glShadeModel</span><span style="color: #009900;">&#40;</span>GL2.<span style="color: #006633;">GL_FLAT</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> reshape<span style="color: #009900;">&#40;</span>GLAutoDrawable gLDrawable, <span style="color: #000066; font-weight: bold;">int</span> x, <span style="color: #000066; font-weight: bold;">int</span> y, <span style="color: #000066; font-weight: bold;">int</span> width, <span style="color: #000066; font-weight: bold;">int</span> height<span style="color: #009900;">&#41;</span> 
    <span style="color: #009900;">&#123;</span>
    	<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;reshape() called: x = &quot;</span><span style="color: #339933;">+</span>x<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;, y = &quot;</span><span style="color: #339933;">+</span>y<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;, width = &quot;</span><span style="color: #339933;">+</span>width<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;, height = &quot;</span><span style="color: #339933;">+</span>height<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">final</span> GL2 gl <span style="color: #339933;">=</span> gLDrawable.<span style="color: #006633;">getGL</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getGL2</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>height <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// avoid a divide by zero error!</span>
        <span style="color: #009900;">&#123;</span>
            height <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">float</span> h <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#41;</span> width <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#41;</span> height<span style="color: #339933;">;</span>
&nbsp;
        gl.<span style="color: #006633;">glViewport</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, width, height<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        gl.<span style="color: #006633;">glMatrixMode</span><span style="color: #009900;">&#40;</span>GL2.<span style="color: #006633;">GL_PROJECTION</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        gl.<span style="color: #006633;">glLoadIdentity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        glu.<span style="color: #006633;">gluPerspective</span><span style="color: #009900;">&#40;</span>45.0f, h, <span style="color: #cc66cc;">1.0</span>, <span style="color: #cc66cc;">20.0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        gl.<span style="color: #006633;">glMatrixMode</span><span style="color: #009900;">&#40;</span>GL2.<span style="color: #006633;">GL_MODELVIEW</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        gl.<span style="color: #006633;">glLoadIdentity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> dispose<span style="color: #009900;">&#40;</span>GLAutoDrawable arg0<span style="color: #009900;">&#41;</span> 
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;dispose() called&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>By right-clicking on the <tt>main()</tt> method and chosing "run as application", Eclipse will execute the program. You should see something like this:</p>
<p><a href="http://schabby.de/wp-content/uploads/2010/07/JoglHelloWorld.png"><img src="http://schabby.de/wp-content/uploads/2010/07/JoglHelloWorld.png" alt="Jogle Hello World" title="Jogle Hello World" width="300" height="300" class="aligncenter size-full wp-image-1034" /></a></p>
<p>That's it so far. Please let me know if you have questions or comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://schabby.de/jogl-example-hello-world/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>JOGL Download</title>
		<link>http://schabby.de/jogl-download/</link>
		<comments>http://schabby.de/jogl-download/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 09:35:40 +0000</pubDate>
		<dc:creator>schabby</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[OpenGL]]></category>

		<guid isPermaLink="false">http://schabby.de/?p=850</guid>
		<description><![CDATA[Just can't find the JOGL downloads (Java OpenGL bindings)? Well, I figured out where to download JOGLs most recent binary distribution such as 2011 releases :)]]></description>
			<content:encoded><![CDATA[<p>You are right in this page if you are on the quest for one of the following:</p>
<ul>
<li>recent JOGL binary distribution download</li>
<li>precompiled Windows Java OpenGL bindings</li>
<li>you just can not find the place where to download JOGL <img src='http://schabby.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ul>
<p><span id="more-850"></span><br />
I had a couple of hours on my own recently and though it would be a good thing to catch up with the latest developments in the Java+OpenGL environment. So I looked for the download of JOGL (Java Bindings for OpenGL) just to realize, that I is actually quite difficult to find a recent binary distribution of JOGL!</p>
<p><strong>Eventually, after a while I found it: <a href="http://jogamp.org/deployment/autobuilds/master/" rel="nofollow">http://jogamp.org/deployment/autobuilds/master/</a>.</strong></p>
<p>There you find an extensive list of directories containing builds, mostly for different binding projects such as <em>gluegen</em>, <em>joal</em>, etc. Search for &#8220;jogl&#8221; to jump to the JOGL builds. </p>
<p>The downloads are basically a list of (probably automated) builds. So I hope that this will be the place for the next months to get update-to-date JOGL binaries. The builds that have the suffix &#8220;-master&#8221; in their directory name appear to contain only documentation. </p>
<p>Please also note that for running JOGL you also need gluegen. I personally use the 2012-01-23 release at the moment. This is</p>
<ul>
<li>gluegen-b480-2012-01-23_16-49-04</li>
<li>jogl-b633-2012-01-23_20-37-13</li>
</ul>
<p>which seem to work.</p>
<p>So the guys at JogAmp.org do actually provide precompiled binaries, they just make it difficult to find them. <img src='http://schabby.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now that you downloaded JOGL, you may be interested in my <a href="http://schabby.de/jogl-example-hello-world/">JOGL Hello World example</a> (includes how to set up the classpath and DLLs right).</p>
<p>Please leave a comment if it helps or my resource gets out of date.</p>
<p>2010-10-20 EDIT: updated download URL.<br />
2010-11-03 EDIT: updated download URL again to point to autobild directory.<br />
2010-11-19 EDIT: added reference to my hello world example with JOGL<br />
2011-07-27 EDIT: updated link to JOGL downloads<br />
2012-01-27 EDIT: updated link to JOGL downloads, added note about gluegen</p>
]]></content:encoded>
			<wfw:commentRss>http://schabby.de/jogl-download/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>crossdomain.xml Demystified</title>
		<link>http://schabby.de/crossdomain-xml-demystified/</link>
		<comments>http://schabby.de/crossdomain-xml-demystified/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 10:24:35 +0000</pubDate>
		<dc:creator>schabby</dc:creator>
				<category><![CDATA[Dies Und Das]]></category>

		<guid isPermaLink="false">http://schabby.de/?p=841</guid>
		<description><![CDATA[Recently, I noticed an increasing number of requests to a file crossdomain.xml on all our subdomains. A vaguely remembered that this is about Flash trying to access resources on our site, but I didnt really know exactly what it is for until I did some research. In a nutshell: crossdomain.xml is a bascially a whitelist [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I noticed an increasing number of requests to a file <tt>crossdomain.xml</tt> on all our subdomains. A vaguely remembered that this is about Flash trying to access resources on our site, but I didnt really know exactly what it is for until I did some research. <span id="more-841"></span>In a nutshell:</p>
<p>crossdomain.xml is a bascially a whitelist of domains that you grant access to your site.</p>
<p>In more detail, browser plugins like Flash or hosted apps are always loaded from some URL, let&#8217;s say <tt>somedomain.com</tt>. Under normal circumstances, these programs are not allowed to access resources on hosts <i>different</i> from the host they where originally loaded, such as <tt>otherdomain.com</tt> for example. So if the client is loaded from <tt>somedomain.com</tt> and wants to load an image from <tt>otherdomain.com</tt>, it first checks <tt>otherdomain.com/crossdomain.xml</tt> if it actually allows <tt>somedomain.com</tt> to access the image.</p>
<p>A simple way to grant access to all resources on your site is to have a crossdomain.xml file that has the following content.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cross-domain-policy<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;allow-access-from</span> <span style="color: #000066;">domain</span>=<span style="color: #ff0000;">&quot;*&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cross-domain-policy<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>I hope that helps. Feel free to leave a comment!</p>
]]></content:encoded>
			<wfw:commentRss>http://schabby.de/crossdomain-xml-demystified/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

