<?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>Wesley&#039;s Techblog &#187; OpenGL</title>
	<atom:link href="http://wesley.vidiqatch.org/category/opengl/feed/" rel="self" type="application/rss+xml" />
	<link>http://wesley.vidiqatch.org</link>
	<description>This blog does not need a smart-ass tagline</description>
	<lastBuildDate>Wed, 09 Sep 2009 21:36:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Overriding dynamic library calls (function interposition)</title>
		<link>http://wesley.vidiqatch.org/18-08-2009/overriding-dynamic-library-calls-function-interposition/</link>
		<comments>http://wesley.vidiqatch.org/18-08-2009/overriding-dynamic-library-calls-function-interposition/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 07:32:57 +0000</pubDate>
		<dc:creator>Wesley</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://wesley.vidiqatch.org/?p=497</guid>
		<description><![CDATA[About function interposition
I was wondering how I could override dynamic library calls in Linux, and I came across this technique known as function interposition. It is a powerful technique that allows you to override dynamic library calls. It might sound dull, but it can be very, very useful. There are some memory trace tools that [...]]]></description>
			<content:encoded><![CDATA[<h4>About function interposition</h4>
<p>I was wondering how I could <em>override dynamic library calls</em> in Linux, and I came across this technique known as <strong>function interposition</strong>. It is a powerful technique that allows you to override dynamic library calls. It might sound dull, but it can be very, very useful. There are some memory trace tools that make use of this technique to work, but perhaps a cooler example is the <a href="http://nullkey.ath.cx/projects/glc/">OpenGL capture system</a> which was created by <a href="nullkey.ath.cx">nullkey</a>: it can capture OpenGL frames by overriding certain OpenGL functions. Another example are cheat tools (wallhacks, aimbots) which also make use of this technique a lot.</p>
<h4>Some background</h4>
<p>While Googling <em>(did I spell that right?)</em> I came across <a href="http://www.jayconrod.com/cgi/view_post.py?23">this</a> recent blog article which explains the background very well. I will quote it here:</p>
<blockquote><p>First, some background. When a program that uses dynamic libraries is compiled, a list of undefined symbols is included in the binary, along with a list of libraries the program is linked with. There is no correspondence between the symbols and the libraries; the two lists just tell the loader which libraries to load and which symbols need to be resolved. At runtime, each symbol is resolved using the first library that provides it. This means that if we can get a library containing our wrapper functions to load before other libraries, the undefined symbols in the program will be resolved to our wrappers instead of the real functions.</p></blockquote>
<p>So if we create a custom shared library which overrides some of the functions of the original library, our functions will be called instead of those of the original library.</p>
<h4>How to do it</h4>
<ul>
<li>Write new functions which override existing functions</li>
<li>Compile the written code to a dynamic library that is linked to the dynamic linking interface library</li>
<li>Use the <em>LD_PRELOAD</em> environment variable when running an application to preload your custom library before all other dynamic libraries</li>
</ul>
<p><a href="http://www.jayconrod.com/cgi/view_post.py?23">The article by Jay Conrod</a> has an example which shows you the basic implementation of a simple memory allocation tracer.</p>
<p>I have also cooked up an example myself. Because I&#8217;ve been busy learning more about OpenGL, I thought that it shouldn&#8217;t be too hard to create a wallhack for one of my favourite games: <a href="http://en.wikipedia.org/wiki/Soldier_of_Fortune_II:_Double_Helix">Soldier of Fortune 2</a> running in Wine. Just for testing purposes of course! I am no cheater <img src='http://wesley.vidiqatch.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  It turned out to be relatively simple, although my first tries weren&#8217;t so very successful:</p>
<ul>
<li><a href="http://wesley.vidiqatch.org/images/hack_v1.png">Epic fail</a> &#8211; At least I know my library is used now.</li>
<li><a href="http://wesley.vidiqatch.org/images/hack_v2.png">Partial success</a> &#8211; Disabling depth testing completely was only a partial success.</li>
<li><a href="http://wesley.vidiqatch.org/images/hack_v3.png">Success</a> &#8211; A debugger can tell that players are drawn using glDrawElements(). By knowing the number of elements for each character, we can disable depth testing selectively.</li>
</ul>
<div class="wp-caption aligncenter" style="width: 568px"><a href="/images/hack_v3.png"><img title="SoF2 wallhack" src="/images/hack_v3.png" alt="Soldier of Fortune 2 wallhack example" width="558" height="430" /></a><p class="wp-caption-text">Soldier of Fortune 2 wallhack example</p></div>
<p>For those of you who are interested in the code:</p>
<div class="codecolorer-container cpp-qt default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br /></div></td><td><div class="cpp-qt codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #888888; font-style: italic;">/*<br />
&nbsp; &nbsp; Simple wallhack example for Soldier of Fortune 2 (Wine) in Linux using function interposition<br />
<br />
&nbsp; &nbsp; This code snippet was written by Wesley Stessens (wesley@ubuntu.com)<br />
&nbsp; &nbsp; It is released in the Public Domain.<br />
<br />
&nbsp; &nbsp; Compilation: gcc -Wall -ansi -pedantic -shared -ldl -fPIC glhack.c -o glhack.so<br />
&nbsp; &nbsp; Usage: LD_PRELOAD=glhack.so wine game.exe<br />
*/</span><br />
<br />
<span style="color: #006E28;">#define _GNU_SOURCE</span><br />
<span style="color: #006E28;">#include &lt;dlfcn.h&gt;</span><br />
<span style="color: #006E28;">#include &lt;stdio.h&gt;</span><br />
<span style="color: #006E28;">#include &lt;stdint.h&gt;</span><br />
<span style="color: #006E28;">#include &lt;GL/gl.h&gt;</span><br />
<br />
<span style="color: #888888; font-style: italic;">/* Override the glDrawElements function */</span><br />
GLAPI <span style="color: #0057AE;">void</span> GLAPIENTRY glDrawElements<span style="color: #006E28;">&#40;</span>GLenum mode<span style="color: #006E28;">,</span> GLsizei count<span style="color: #006E28;">,</span> GLenum type<span style="color: #006E28;">,</span> <span style="color: #0057AE;">const</span> GLvoid <span style="color: #006E28;">*</span>indices<span style="color: #006E28;">&#41;</span> <span style="color: #006E28;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #888888; font-style: italic;">/* Store the actual function in a static function pointer */</span><br />
&nbsp; &nbsp; <span style="color: #0057AE;">static</span> <span style="color: #0057AE;">void</span> <span style="color: #006E28;">&#40;</span><span style="color: #006E28;">*</span>glDrawElements_<span style="color: #006E28;">&#41;</span><span style="color: #006E28;">&#40;</span>GLenum mode<span style="color: #006E28;">,</span> GLsizei count<span style="color: #006E28;">,</span> GLenum type<span style="color: #006E28;">,</span> <span style="color: #0057AE;">const</span> GLvoid <span style="color: #006E28;">*</span>indices<span style="color: #006E28;">&#41;</span> <span style="color: #006E28;">=</span> NULL<span style="color: #006E28;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight:bold;">if</span> <span style="color: #006E28;">&#40;</span><span style="color: #006E28;">!</span>glDrawElements_<span style="color: #006E28;">&#41;</span> <span style="color: #006E28;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; glDrawElements_ <span style="color: #006E28;">=</span> <span style="color: #006E28;">&#40;</span><span style="color: #0057AE;">void</span><span style="color: #006E28;">&#40;</span><span style="color: #006E28;">*</span><span style="color: #006E28;">&#41;</span><span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span><span style="color: #006E28;">&#41;</span><span style="color: #006E28;">&#40;</span>intptr_t<span style="color: #006E28;">&#41;</span>dlsym<span style="color: #006E28;">&#40;</span>RTLD_NEXT<span style="color: #006E28;">,</span> <span style="color: #BF0303;">&quot;glDrawElements&quot;</span><span style="color: #006E28;">&#41;</span><span style="color: #006E28;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #2B74C7;">puts</span><span style="color: #006E28;">&#40;</span><span style="color: #BF0303;">&quot;GLHack: glDrawElements call has been overridden&quot;</span><span style="color: #006E28;">&#41;</span><span style="color: #006E28;">;</span><br />
&nbsp; &nbsp; <span style="color: #006E28;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #888888; font-style: italic;">/* Disable depth testing if the number of elements to draw is one of the following, which means a player is being drawn */</span><br />
&nbsp; &nbsp; <span style="color: #888888; font-style: italic;">/* To avoid abuse of this code by cheaters, I have changed all count constants below to VALUEX */</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight:bold;">if</span> <span style="color: #006E28;">&#40;</span>count <span style="color: #006E28;">==</span> VALUE1 <span style="color: #006E28;">||</span> count <span style="color: #006E28;">==</span> VALUE2 <span style="color: #006E28;">||</span> count <span style="color: #006E28;">==</span> VALUE3 <span style="color: #006E28;">||</span> count <span style="color: #006E28;">==</span> VALUE4<span style="color: #006E28;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; glDisable<span style="color: #006E28;">&#40;</span>GL_DEPTH_TEST<span style="color: #006E28;">&#41;</span><span style="color: #006E28;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight:bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; glEnable<span style="color: #006E28;">&#40;</span>GL_DEPTH_TEST<span style="color: #006E28;">&#41;</span><span style="color: #006E28;">;</span><br />
&nbsp; &nbsp; glDrawElements_<span style="color: #006E28;">&#40;</span>mode<span style="color: #006E28;">,</span> count<span style="color: #006E28;">,</span> type<span style="color: #006E28;">,</span> indices<span style="color: #006E28;">&#41;</span><span style="color: #006E28;">;</span><br />
<span style="color: #006E28;">&#125;</span></div></td></tr></tbody></table></div>
<h4>Interesting thought about multiplayer cheats and Wine</h4>
<p>If anti-cheat tools would perform a sanity check of the OpenGL or DirectX DLL, they would only find the virtual DLL&#8217;s when a game is run in Wine, right? I&#8217;m wondering whether this sort of cheats can be made undetectable then. In a way I hope not, because cheaters are very annoying when you&#8217;re playing a game, but on the other hand, it would be an amazing technological achievement. Anyway, anti-cheat tools like <em>PunkBuster</em> don&#8217;t even work with Wine at the moment, so it might be a non-issue. What are your thoughts?</p>
]]></content:encoded>
			<wfw:commentRss>http://wesley.vidiqatch.org/18-08-2009/overriding-dynamic-library-calls-function-interposition/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>NeHe OpenGL lessons in Qt &#8211; Chapter 4</title>
		<link>http://wesley.vidiqatch.org/08-08-2009/nehe-opengl-lessons-in-qt-chapter-4/</link>
		<comments>http://wesley.vidiqatch.org/08-08-2009/nehe-opengl-lessons-in-qt-chapter-4/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 23:43:25 +0000</pubDate>
		<dc:creator>Wesley</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://wesley.vidiqatch.org/?p=414</guid>
		<description><![CDATA[As promised, the fourth chapter of the NeHe OpenGL lessons ported to make use of the Qt toolkit.
 
Fourth chapter: fog, fonts revisited, quadrics, particle engine, triangle strips, masking
In the fourth chapter you will learn a few cooler tricks. You will learn how to create good-looking fog effects and how certain objects can easily be [...]]]></description>
			<content:encoded><![CDATA[<p>As promised, the fourth chapter of the <a href="http://nehe.gamedev.net/">NeHe OpenGL lessons</a> ported to make use of the <a href="http://www.qtsoftware.com/">Qt toolkit</a>.</p>
<p style="text-align: center;"><img title="OpenGL" src="http://www.fabioruini.eu/blog/wp-content/uploads/2008/07/opengl_logo.png" alt="" width="137" height="72" /> <img title="Qt 4" src="http://www.qtsoftware.com/logo.png" alt="" width="174" height="71" /></p>
<h4>Fourth chapter: fog, fonts revisited, quadrics, particle engine, triangle strips, masking</h4>
<p>In the <a href="http://nehe.gamedev.net/lesson.asp?index=04">fourth chapter</a> you will learn a few cooler tricks. You will learn how to create good-looking fog effects and how certain objects can easily be constructed using quadrics. But the coolest thing that you will learn is how to create a simple <strong>particle engine</strong> (during lesson 19). To end off the chapter, you will learn how you can use masking to create partial transparency using bitmap textures.</p>
<p><em>Some minor modifications were made to improve the visual appearance of some of the lessons.</em></p>
<p><img class="aligncenter" title="Particle engine" src="http://wesley.vidiqatch.org/images/particles_snapshot.png" alt="" width="386" height="269" /></p>
<h4>Videos and source code</h4>
<p><a href="http://www.youtube.com/watch?v=SksYPqFCj4M&amp;fmt=18">This video</a> shows the fog effect (lesson 16)<br />
<a href="http://www.youtube.com/watch?v=5TxEGk6W-YU&amp;fmt=18">This video</a> shows what you can achieve using quadrics (lesson 18)<br />
<a href="http://www.youtube.com/watch?v=0FfH9fx_hJo&amp;fmt=18">This video</a> shows the very cool particle engine that you will create! (lesson 19)<br />
<a href="http://www.youtube.com/watch?v=gfBfRVgi5FU&amp;fmt=18">This video</a> shows which effect masking has (lesson 20)<br />
You can download the Qt 4 source code for this chapter <a href="http://wesley.vidiqatch.org/files/chapter4.zip"><strong>here</strong></a>.</p>
<p><em>PS: The port of chapter 5 will take a while&#8230; I will be a bit busy the coming weeks, and the first lesson of chapter 5 is HUGE, so will require a lot of time to port.<br />
Oh, and apparently I forgot to upload the source code for the third chapter. I have uploaded it now <img src='http://wesley.vidiqatch.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </em></p>
]]></content:encoded>
			<wfw:commentRss>http://wesley.vidiqatch.org/08-08-2009/nehe-opengl-lessons-in-qt-chapter-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NeHe OpenGL lessons in Qt – Chapter 3</title>
		<link>http://wesley.vidiqatch.org/04-08-2009/nehe-opengl-lessons-in-qt-chapter-3/</link>
		<comments>http://wesley.vidiqatch.org/04-08-2009/nehe-opengl-lessons-in-qt-chapter-3/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 19:57:01 +0000</pubDate>
		<dc:creator>Wesley</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://wesley.vidiqatch.org/?p=409</guid>
		<description><![CDATA[Here is the third chapter of the NeHe OpenGL lessons ported to make use of the Qt toolkit.
 
Third chapter: waving texture, display lists and a lot of fonts
The third chapter starts off with a cool looking waving flag effect. After that you will learn about display lists. The last three lessons focus on different [...]]]></description>
			<content:encoded><![CDATA[<p>Here is the third chapter of the <a href="http://nehe.gamedev.net/">NeHe OpenGL lessons</a> ported to make use of the <a href="http://www.qtsoftware.com/">Qt toolkit</a>.</p>
<p style="text-align: center;"><img title="OpenGL" src="http://www.fabioruini.eu/blog/wp-content/uploads/2008/07/opengl_logo.png" alt="" width="137" height="72" /> <img title="Qt 4" src="http://www.qtsoftware.com/logo.png" alt="" width="174" height="71" /></p>
<h4>Third chapter: waving texture, display lists and a lot of fonts</h4>
<p>The <a href="http://nehe.gamedev.net/lesson.asp?index=03">third chapter</a> starts off with a cool looking <strong>waving flag effect</strong>. After that you will learn about <strong>display lists</strong>. The last three lessons focus on different ways of <strong>displaying fonts</strong>. It is worth noting that rendering basic text at a chosen location, or translated into the OpenGL scene is extremely easy in Qt/OpenGL thanks to <a href="http://doc.qtsoftware.com/4.5/qglwidget.html#renderText">QGLWidget::renderText()</a>. For other basic text effects (such as rotated, skewed or otherwise transformed text) you could also use <a href="http://doc.qtsoftware.com/4.5/qpainter.html">QPainter</a> directly on a <a href="http://doc.qtsoftware.com/4.5/qglwidget.html">QGLWidget</a>. We won&#8217;t be doing this in our examples, but I just wanted to point out that it is possible.</p>
<p>I should also note that I have used an extra library in lesson 14 to display the 3D text. Qt itself is not able to display 3D text and doing this in a cross-platform way yourself would be rather hard. That&#8217;s why I have used the <a href="http://sourceforge.net/projects/ftgl/develop"><strong>FTGL</strong></a> library for this. FTGL is a very easy to use cross-platform library with the sole purpose of rendering (3D) text in OpenGL.</p>
<h4>Videos and source code</h4>
<p><a href="http://www.youtube.com/watch?v=jy3g5TV0WRg&amp;fmt=18">This video</a> shows the waving flag effect (lesson 11)<br />
<a href="http://www.youtube.com/watch?v=-uaRypjMJuo&amp;fmt=18">This video</a> shows the effect of using display lists (lesson 12)<br />
<a href="http://www.youtube.com/watch?v=MZlRzwxqw3c&amp;fmt=18">This video</a> shows rotated 3D text (lesson 14)<br />
You can download the Qt 4 source code for this chapter <a href="http://wesley.vidiqatch.org/files/chapter3.zip"><strong>here</strong></a>.</p>
<p><em>PS: You can expect chapter 4 in a few days <img src='http://wesley.vidiqatch.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </em></p>
]]></content:encoded>
			<wfw:commentRss>http://wesley.vidiqatch.org/04-08-2009/nehe-opengl-lessons-in-qt-chapter-3/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>NeHe OpenGL lessons in Qt &#8211; Chapter 1 and 2</title>
		<link>http://wesley.vidiqatch.org/03-08-2009/nehe-opengl-lessons-in-qt-chapter-1-and-2/</link>
		<comments>http://wesley.vidiqatch.org/03-08-2009/nehe-opengl-lessons-in-qt-chapter-1-and-2/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 17:16:38 +0000</pubDate>
		<dc:creator>Wesley</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://wesley.vidiqatch.org/?p=365</guid>
		<description><![CDATA[Last week I have ported two chapters (the first 10 lessons) of the NeHe OpenGL lessons to make use of the Qt toolkit. You will notice that the code in Qt is much cleaner and simpler than the code in the original NeHe lessons. There is no need to create a rendering or device context [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I have ported two chapters (the first 10 lessons) of the <a href="http://nehe.gamedev.net/">NeHe OpenGL lessons</a> to make use of the <a href="http://www.qtsoftware.com/">Qt toolkit</a>. You will notice that the code in Qt is much <strong>cleaner</strong> and <strong>simpler</strong> than the code in the original NeHe lessons. There is no need to create a rendering or device context yourself or anything like that, and input support like input from keyboard or mouse can simply be implemented by reimplementing one function. As an added bonus, your 3D applications will run on pretty much any platform.</p>
<p style="text-align: center;"><img title="OpenGL" src="http://www.fabioruini.eu/blog/wp-content/uploads/2008/07/opengl_logo.png" alt="" width="137" height="72" /> <img title="Qt 4" src="http://www.qtsoftware.com/logo.png" alt="" width="174" height="71" /></p>
<h4>First chapter: setting up an OpenGL window, polygons, colors, rotation, 3D shapes</h4>
<p>After completing the <a href="http://nehe.gamedev.net/lesson.asp?index=01">first chapter</a>, you will end up with a rotating pyramid and cube&#8230;<a href="http://www.youtube.com/watch?v=dE3_vgnm7Ck&amp;fmt=18"></a></p>
<p><a href="http://www.youtube.com/watch?v=dE3_vgnm7Ck&amp;fmt=18">This video</a> shows the end result (lesson 5).<br />
You can download the Qt 4 source code for this chapter <a href="http://wesley.vidiqatch.org/files/chapter1.zip"><strong>here</strong></a>.</p>
<h4>Second chapter: texture mapping, texture filters, lighting, keyboard control, blending, moving bitmaps in 3D space, loading and moving through a 3D world</h4>
<p>In the <a href="http://nehe.gamedev.net/lesson.asp?index=02">second chapter</a> you will learn a lot about textures, among some other things. Sometimes we make use of <a href="http://doc.qtsoftware.com/4.5/qglcontext.html#bindTexture">QGLContext::bindTexture()</a> to load an image, morph it into a texture and bind it to OpenGL all in one go. Other times we will do it manually because we want to specify the texture filter ourselves (but we do have <a href="http://doc.qtsoftware.com/4.5/qglwidget.html#convertToGLFormat">QGLWidget::convertToGLFormat()</a> which makes that easy as well). To handle keypresses we simply reimplement <a href="http://doc.qtsoftware.com/4.5/qwidget.html#keyPressEvent">keyPressEvent()</a>. To load in the 3D world from the file we make use of the excellent <a href="http://doc.qtsoftware.com/4.5/qfile.html">QFile</a> and <a href="http://doc.qtsoftware.com/4.5/qtextstream.html">QTextStream</a> classes. As an added <strong>bonus</strong>, we also make use of <a href="http://doc.qtsoftware.com/4.5/qglwidget.html#renderText">QGLWidget::renderText()</a> to show the user what has changed when a key is pressed inside the OpenGL window. Lesson 9 also features a <strong>bonus</strong> fade-in effect for the revived stars. This makes the effect look much cooler.</p>
<p><a href="http://www.youtube.com/watch?v=_apiJu9oF8A&amp;fmt=18">This video</a> shows the result of adding texture filters, lighting and keyboard control (lesson 7)<br />
<a href="http://www.youtube.com/watch?v=uoa8x4Vwxco&amp;fmt=18">This video</a> shows the result of all the above plus blending (lesson 8<em></em>)<br />
<a href="http://www.youtube.com/watch?v=MoFNngz7_qg&amp;fmt=18">This video</a> shows the result of moving bitmaps in 3D space (lesson 9)<br />
<a href="http://www.youtube.com/watch?v=JSybmJKGu1k&amp;fmt=18">This video</a> shows the result of moving through a very simple 3D world (lesson 10)<br />
You can download the Qt 4 source code for this chapter <a href="http://wesley.vidiqatch.org/files/chapter2.zip"><strong>here</strong></a>.</p>
<p>The <strong>third and fourth chapter</strong> are almost complete as well, but I will give you the Qt ports of those chapters another time. Perhaps tomorrow.</p>
]]></content:encoded>
			<wfw:commentRss>http://wesley.vidiqatch.org/03-08-2009/nehe-opengl-lessons-in-qt-chapter-1-and-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>x86 Linux assembler</title>
		<link>http://wesley.vidiqatch.org/02-08-2009/x86-linux-assembler/</link>
		<comments>http://wesley.vidiqatch.org/02-08-2009/x86-linux-assembler/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 20:00:04 +0000</pubDate>
		<dc:creator>Wesley</dc:creator>
				<category><![CDATA[Assembler]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://wesley.vidiqatch.org/?p=355</guid>
		<description><![CDATA[The last few days I&#8217;ve been looking at x86 Linux assembler programming. I think it&#8217;s important to know how the code which you write in higher-level languages gets translated to low-level instructions and in what way things like libc or the kernel are involved. With some knowledge of assembler you can not only directly optimize [...]]]></description>
			<content:encoded><![CDATA[<p>The last few days I&#8217;ve been looking at <strong>x86 Linux assembler </strong>programming. I think it&#8217;s important to know how the code which you write in <em>higher-level</em> languages gets translated to <em>low-level instructions</em> and in what way things like <em>libc</em> or the <em>kernel</em> are involved. With some knowledge of assembler you can not only directly optimize some slower operations by implementing them in low-level assembly and by utilizing specific processor features, but in general you will also learn in which ways you can optimize your software by just writing the high-level code a little bit different &#8211; by anticipating how your code will translate into low-level assembler instructions.</p>
<p>That was my motivation for trying to do a few things with the Netwide Assembler (NASM). The result is a simple demo which utilizes <em>libc</em>, <em>GLUT</em> and <em>OpenGL</em> to display a rotating pyramid and cube.</p>
<div class="wp-caption alignnone" style="width: 535px"><img title="ogl.asm" src="http://wesley.vidiqatch.org/images/ogl.png" alt="ogl.asm" width="525" height="359" /><p class="wp-caption-text">compiled ogl.asm application running in Ubuntu 8.04</p></div>
<p>The resulting code can be viewed here:</p>
<div class="codecolorer-container asm default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br />136<br />137<br />138<br />139<br />140<br />141<br />142<br />143<br />144<br />145<br />146<br />147<br />148<br />149<br />150<br />151<br />152<br />153<br />154<br />155<br />156<br />157<br />158<br />159<br />160<br />161<br />162<br />163<br />164<br />165<br />166<br />167<br />168<br />169<br />170<br />171<br />172<br />173<br />174<br />175<br />176<br />177<br />178<br />179<br />180<br />181<br />182<br />183<br />184<br />185<br />186<br />187<br />188<br />189<br />190<br />191<br />192<br />193<br />194<br />195<br />196<br />197<br />198<br />199<br />200<br />201<br />202<br />203<br />204<br />205<br />206<br />207<br />208<br />209<br />210<br />211<br />212<br />213<br />214<br />215<br />216<br />217<br />218<br />219<br />220<br />221<br />222<br />223<br />224<br />225<br />226<br />227<br />228<br />229<br />230<br />231<br />232<br />233<br />234<br />235<br />236<br />237<br />238<br />239<br />240<br />241<br />242<br />243<br />244<br />245<br />246<br />247<br />248<br />249<br />250<br />251<br />252<br />253<br />254<br />255<br />256<br />257<br />258<br />259<br />260<br />261<br />262<br />263<br />264<br />265<br />266<br />267<br />268<br />269<br />270<br />271<br />272<br />273<br />274<br />275<br />276<br />277<br />278<br />279<br />280<br />281<br />282<br />283<br />284<br />285<br />286<br />287<br />288<br />289<br />290<br />291<br />292<br />293<br />294<br />295<br />296<br />297<br />298<br />299<br />300<br />301<br />302<br />303<br />304<br />305<br />306<br />307<br />308<br />309<br />310<br />311<br />312<br />313<br />314<br />315<br />316<br />317<br />318<br />319<br />320<br />321<br />322<br />323<br />324<br />325<br />326<br />327<br />328<br />329<br />330<br />331<br />332<br />333<br />334<br /></div></td><td><div class="asm codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">; OpenGL example in x86 Linux assembler / NASM using Glut</span><br />
<span style="color: #666666; font-style: italic;">; Author: Wesley Stessens (wesley@ubuntu.com)</span><br />
<span style="color: #666666; font-style: italic;">;</span><br />
<span style="color: #666666; font-style: italic;">; OpenGL calls to create pyramid and cube are from Jeff Molofee's OpenGL tutorial</span><br />
<span style="color: #666666; font-style: italic;">; See: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=05</span><br />
<span style="color: #666666; font-style: italic;">;</span><br />
<span style="color: #666666; font-style: italic;">; Features:</span><br />
<span style="color: #666666; font-style: italic;">; &nbsp;- Calling C functions by cdecl conventions</span><br />
<span style="color: #666666; font-style: italic;">; &nbsp;- Using GLUT and OpenGL calls to perform 3D graphics</span><br />
<span style="color: #666666; font-style: italic;">; &nbsp;- Low-level framerate control</span><br />
<span style="color: #666666; font-style: italic;">;</span><br />
<span style="color: #666666; font-style: italic;">; Sample compile instructions:</span><br />
<span style="color: #666666; font-style: italic;">; nasm -felf ogl.asm &amp;&amp; ld -lglut -s -I/lib/ld-linux.so.2 -o ogl ogl.o</span><br />
<span style="color: #666666; font-style: italic;">;</span><br />
<span style="color: #666666; font-style: italic;">; This code is released as sample code in the public domain. Use it for whatever you want.</span><br />
<span style="color: #666666; font-style: italic;">; Feel free to let me know if you found this code useful in any way.</span><br />
<br />
<span style="color: #666666; font-style: italic;">; Glut</span><br />
<span style="color: #000000; font-weight: bold;">extern</span> glutInit<span style="color: #339933;">,</span> glutInitDisplayMode<span style="color: #339933;">,</span> glutInitWindowSize<span style="color: #339933;">,</span> glutInitWindowPosition<br />
<span style="color: #000000; font-weight: bold;">extern</span> glutCreateWindow<span style="color: #339933;">,</span> glutMainLoop<br />
<span style="color: #000000; font-weight: bold;">extern</span> glutDisplayFunc<span style="color: #339933;">,</span> glutIdleFunc<span style="color: #339933;">,</span> glutReshapeFunc<span style="color: #339933;">,</span> glutKeyboardFunc<br />
<span style="color: #000000; font-weight: bold;">extern</span> glutSwapBuffers<br />
<br />
<span style="color: #666666; font-style: italic;">; Glu</span><br />
<span style="color: #000000; font-weight: bold;">extern</span> gluPerspective<br />
<br />
<span style="color: #666666; font-style: italic;">; OpenGL</span><br />
<span style="color: #000000; font-weight: bold;">extern</span> glClearColor<span style="color: #339933;">,</span> glClearDepth<span style="color: #339933;">,</span> glDepthFunc<span style="color: #339933;">,</span> glEnable<span style="color: #339933;">,</span> glShadeModel<br />
<span style="color: #000000; font-weight: bold;">extern</span> glClear<span style="color: #339933;">,</span> glLoadIdentity<span style="color: #339933;">,</span> glMatrixMode<span style="color: #339933;">,</span> glViewport<br />
<span style="color: #000000; font-weight: bold;">extern</span> glTranslatef<span style="color: #339933;">,</span> glRotatef<span style="color: #339933;">,</span> glBegin<span style="color: #339933;">,</span> glEnd<span style="color: #339933;">,</span> glVertex3f<span style="color: #339933;">,</span> glColor3f<br />
<br />
<span style="color: #666666; font-style: italic;">; Needed for framerate control</span><br />
<span style="color: #000000; font-weight: bold;">extern</span> usleep<br />
<br />
<span style="color: #666666; font-style: italic;">; Macros</span><br />
<span style="color: #339933;">%</span><span style="color: #000000; font-weight: bold;">macro</span> _3call 4<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #339933;">%</span>4<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #339933;">%</span>3<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #339933;">%</span>2<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> <span style="color: #339933;">%</span>1<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> 12<br />
<span style="color: #339933;">%</span>endmacro<br />
<span style="color: #339933;">%</span><span style="color: #000000; font-weight: bold;">macro</span> _4call 5<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #339933;">%</span>5<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #339933;">%</span>4<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #339933;">%</span>3<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #339933;">%</span>2<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> <span style="color: #339933;">%</span>1<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> 16<br />
<span style="color: #339933;">%</span>endmacro<br />
<br />
section <span style="color: #000000; font-weight: bold;">.data</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">title</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">db</span> <span style="color: #7f007f;">'OpenGL in x86 Linux assembler / NASM using Glut'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">; Data for FP math with 4 bytes</span><br />
&nbsp; &nbsp; n7<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">dd</span> <span style="color: #339933;">-</span>7<span style="color: #339933;">.</span>0<br />
&nbsp; &nbsp; n6<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">dd</span> <span style="color: #339933;">-</span>6<span style="color: #339933;">.</span>0<br />
&nbsp; &nbsp; n1p5<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">dd</span> <span style="color: #339933;">-</span>1<span style="color: #339933;">.</span>5<br />
&nbsp; &nbsp; n1<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">dd</span> <span style="color: #339933;">-</span>1<span style="color: #339933;">.</span>0<br />
&nbsp; &nbsp; p0p4<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">dd</span> 0<span style="color: #339933;">.</span>4<br />
&nbsp; &nbsp; p0p5<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">dd</span> 0<span style="color: #339933;">.</span>5<br />
&nbsp; &nbsp; p1<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">dd</span> 1<span style="color: #339933;">.</span>0<br />
&nbsp; &nbsp; p1p5<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">dd</span> 1<span style="color: #339933;">.</span>5<br />
&nbsp; &nbsp; p3<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">dd</span> 3<span style="color: #339933;">.</span>0<br />
&nbsp; &nbsp; rottrm<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">dd</span> 4<span style="color: #339933;">.</span>5<br />
&nbsp; &nbsp; rotsqm<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">dd</span> <span style="color: #339933;">-</span><span style="color: #0000ff;">3.0</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">; Data for FP math with 8 bytes</span><br />
&nbsp; &nbsp; q0p1<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">dq</span> 0<span style="color: #339933;">.</span>1<br />
&nbsp; &nbsp; q1<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">dq</span> 1<span style="color: #339933;">.</span>0<br />
&nbsp; &nbsp; q45<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">dq</span> 45<span style="color: #339933;">.</span>0<br />
&nbsp; &nbsp; q100<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">dq</span> <span style="color: #0000ff;">100.0</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">; Data for framerate control</span><br />
&nbsp; &nbsp; mspf<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">dd</span> <span style="color: #0000ff;">20000</span> <span style="color: #666666; font-style: italic;">; ms per frame</span><br />
<br />
section <span style="color: #339933;">.</span>bss<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">; Vars for rotation</span><br />
&nbsp; &nbsp; rottr<span style="color: #339933;">:</span> resd <span style="color: #0000ff;">1</span><br />
&nbsp; &nbsp; rotsq<span style="color: #339933;">:</span> resd <span style="color: #0000ff;">1</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">; Var for aspect ratio</span><br />
&nbsp; &nbsp; aspr<span style="color: #339933;">:</span> resq <span style="color: #0000ff;">1</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">; Vars for framerate control</span><br />
&nbsp; &nbsp; time<span style="color: #339933;">:</span> resd 2<br />
&nbsp; &nbsp; usecs<span style="color: #339933;">:</span> resd 1<br />
&nbsp; &nbsp; oldslp<span style="color: #339933;">:</span> resd 1<br />
<br />
section <span style="color: #339933;">.</span>text<br />
&nbsp; &nbsp; global _start<br />
<br />
fpsmanager<span style="color: #339933;">:</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #00007f;">eax</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #00007f;">ebx</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #00007f;">ecx</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #00007f;">edx</span><br />
<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #00007f;">eax</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">78</span> <span style="color: #666666; font-style: italic;">; sys_gettimeofday</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #00007f;">ebx</span><span style="color: #339933;">,</span> time<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #00007f;">ecx</span><span style="color: #339933;">,</span> 0<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">int</span> 80h<br />
<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #00007f;">eax</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>time <span style="color: #339933;">+</span> 4<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">sub</span> <span style="color: #00007f;">eax</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>usecs<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #00007f;">ebx</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>mspf<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">sub</span> <span style="color: #00007f;">ebx</span><span style="color: #339933;">,</span> <span style="color: #00007f;">eax</span><br />
<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">test</span> <span style="color: #00007f;">eax</span><span style="color: #339933;">,</span> <span style="color: #00007f;">eax</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">js</span> keep_sleep<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">test</span> <span style="color: #00007f;">ebx</span><span style="color: #339933;">,</span> <span style="color: #00007f;">ebx</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">js</span> keep_sleep<br />
<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #00007f;">ebx</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> usleep<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> 4<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>oldslp<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #00007f;">ebx</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">jmp</span> done_sleep<br />
<br />
keep_sleep<span style="color: #339933;">:</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>oldslp<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> usleep<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> 4<br />
<br />
done_sleep<span style="color: #339933;">:</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #00007f;">eax</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>time <span style="color: #339933;">+</span> 4<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>usecs<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #00007f;">eax</span><br />
<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">pop</span> <span style="color: #00007f;">edx</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">pop</span> <span style="color: #00007f;">ecx</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">pop</span> <span style="color: #00007f;">ebx</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">pop</span> <span style="color: #00007f;">eax</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">ret</span><br />
<br />
display<span style="color: #339933;">:</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">; Prepare for drawing</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #0000ff;">4100h</span> <span style="color: #666666; font-style: italic;">; GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glClear<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> 4<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glLoadIdentity<br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">; Draw pyramid on the left of the screen</span><br />
&nbsp; &nbsp; _3call glTranslatef<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1p5<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> 0<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n6<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _4call glRotatef<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>rottr<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> 0<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> 0<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #0000ff;">9h</span> <span style="color: #666666; font-style: italic;">; GL_POLYGON</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glBegin<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span><br />
&nbsp; &nbsp; _3call glColor3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span> <span style="color: #666666; font-style: italic;">; Start drawing front face</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><br />
&nbsp; &nbsp; _3call glColor3f<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glColor3f<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glColor3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span> <span style="color: #666666; font-style: italic;">; Start drawing right face</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><br />
&nbsp; &nbsp; _3call glColor3f<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glColor3f<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glColor3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span> <span style="color: #666666; font-style: italic;">; Start drawing back face</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><br />
&nbsp; &nbsp; _3call glColor3f<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glColor3f<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glColor3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span> <span style="color: #666666; font-style: italic;">; Start drawing right face</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> 0<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> 0<br />
&nbsp; &nbsp; _3call glColor3f<span style="color: #339933;">,</span> 0<span style="color: #339933;">,</span> 0<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glColor3f<span style="color: #339933;">,</span> 0<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> 0<br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glEnd<br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">; Draw cube on the right of the screen</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glLoadIdentity<br />
&nbsp; &nbsp; _3call glTranslatef<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1p5<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> 0<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n7<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _4call glRotatef<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>rotsq<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p0p4<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p0p5<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #0000ff;">7h</span> <span style="color: #666666; font-style: italic;">; GL_QUADS</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glBegin<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span><br />
&nbsp; &nbsp; _3call glColor3f<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span> <span style="color: #666666; font-style: italic;">; Start drawing top face</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glColor3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p0p5<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span> <span style="color: #666666; font-style: italic;">; Start drawing bottom face</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glColor3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span> <span style="color: #666666; font-style: italic;">; Start drawing front face</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glColor3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span> <span style="color: #666666; font-style: italic;">; Start drawing back face</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glColor3f<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">; Start drawing left face</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glColor3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">; Start drawing right face</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; _3call glVertex3f<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>p1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>n1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glEnd<br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">; Update rotation</span><br />
&nbsp; &nbsp; <span style="color: #0000ff; font-weight: bold;">fld</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>rottr<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff; font-weight: bold;">fadd</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>rottrm<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff; font-weight: bold;">fstp</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>rottr<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff; font-weight: bold;">fld</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>rotsq<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff; font-weight: bold;">fadd</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>rotsqm<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff; font-weight: bold;">fstp</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>rotsq<span style="color: #009900; font-weight: bold;">&#93;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glutSwapBuffers <span style="color: #666666; font-style: italic;">; Swap buffers and display</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> fpsmanager <span style="color: #666666; font-style: italic;">; Cap framerate if necessary</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">ret</span><br />
<br />
reshape<span style="color: #339933;">:</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #00007f;">ebp</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #00007f;">ebp</span><span style="color: #339933;">,</span> <span style="color: #00007f;">esp</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">; Prevent division by zero</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">cmp</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">ebp</span><span style="color: #339933;">+</span>8<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> 0<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">jne</span> reshape_2<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">inc</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">ebp</span><span style="color: #339933;">+</span>8<span style="color: #009900; font-weight: bold;">&#93;</span><br />
<br />
reshape_2<span style="color: #339933;">:</span><br />
&nbsp; &nbsp; <span style="color: #0000ff; font-weight: bold;">fild</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">ebp</span><span style="color: #339933;">+</span>8<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff; font-weight: bold;">fidiv</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">ebp</span><span style="color: #339933;">+</span>12<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff; font-weight: bold;">fstp</span> <span style="color: #000000; font-weight: bold;">qword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>aspr<span style="color: #009900; font-weight: bold;">&#93;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">ebp</span><span style="color: #339933;">+</span>12<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">ebp</span><span style="color: #339933;">+</span>8<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> 0<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> 0<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glViewport<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> 16<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #0000ff;">1701h</span><span style="color: #666666; font-style: italic;">; GL_PROJECTION</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glMatrixMode<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> 4<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glLoadIdentity<br />
<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>q100<span style="color: #339933;">+</span>4<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>q100<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>q0p1<span style="color: #339933;">+</span>4<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>q0p1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>aspr<span style="color: #339933;">+</span>4<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>aspr<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>q45<span style="color: #339933;">+</span>4<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>q45<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> gluPerspective<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> 32<br />
<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #0000ff;">1700h</span><span style="color: #666666; font-style: italic;">; GL_MODELVIEW</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glMatrixMode<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> 4<br />
<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">pop</span> <span style="color: #00007f;">ebp</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">ret</span><br />
<br />
keyhandler<span style="color: #339933;">:</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">ret</span><br />
<br />
_start<span style="color: #339933;">:</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">; Initialize glut</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">esp</span><span style="color: #339933;">+</span>8<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">lea</span> <span style="color: #00007f;">eax</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span><span style="color: #00007f;">esp</span><span style="color: #339933;">+</span>8<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #00007f;">eax</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glutInit<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> 8<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #0000ff;">1ah</span> <span style="color: #666666; font-style: italic;">; GLUT_RGBA|GLUT_DOUBLE|GLUT_ALPHA|GLUT_DEPTH</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glutInitDisplayMode<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> 4<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> 480<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> 640<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glutInitWindowSize<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> 8<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> 0<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> 0<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glutInitWindowPosition<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">8</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">; Create window</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">title</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glutCreateWindow<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">; Register functions</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> display<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glutDisplayFunc<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glutIdleFunc<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> 4<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> reshape<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glutReshapeFunc<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> 4<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> keyhandler<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glutKeyboardFunc<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">; Initialize OpenGL</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> 0<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> 0<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> 0<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> 0<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glClearColor<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> 16<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>q1<span style="color: #339933;">+</span>4<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>q1<span style="color: #009900; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glClearDepth<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> 8<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #0000ff;">203h</span><span style="color: #666666; font-style: italic;">; GL_LEQUAL</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glDepthFunc<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> 4<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #0000ff;">0b71h</span><span style="color: #666666; font-style: italic;">; GL_DEPTH_TEST</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glEnable<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> 4<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #0000ff;">1d01h</span><span style="color: #666666; font-style: italic;">; GL_SMOOTH</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glShadeModel<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">esp</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">4</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">; Frame rate cap initialization</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #000000; font-weight: bold;">dword</span> <span style="color: #009900; font-weight: bold;">&#91;</span>oldslp<span style="color: #009900; font-weight: bold;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">; Enter main loop</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">call</span> glutMainLoop<br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">; Exit (return with error code 0)</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #00007f;">eax</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">1</span> <span style="color: #666666; font-style: italic;">; sys_exit</span><br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">mov</span> <span style="color: #00007f;">ebx</span><span style="color: #339933;">,</span> 0<br />
&nbsp; &nbsp; <span style="color: #00007f; font-weight: bold;">int</span> <span style="color: #0000ff;">80h</span></div></td></tr></tbody></table></div>
<p>I have also written two other smaller examples:<br />
- <a href="/code-snippets/ideal-statistical-sample-formula/">marketing.asm</a> is a really simple statistics application which calculates the ideal sample size given a few parameters<br />
- <a href="/code-snippets/simple-audio-playback-using-alsa/">alsawav.asm</a> is a simple audio library which utilizes ALSA to play an unbuffered raw WAV/PCM sample</p>
<p>Please note that all these examples require an x86 Linux distribution. These examples will not work on any other operating system.</p>
]]></content:encoded>
			<wfw:commentRss>http://wesley.vidiqatch.org/02-08-2009/x86-linux-assembler/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
