tag:blogger.com,1999:blog-26114450940034687912009-07-01T16:04:34.759+03:00OdeFuMy experiences with D, OpenGL and SDL...OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.comBlogger43125tag:blogger.com,1999:blog-2611445094003468791.post-4057289117191863402008-12-15T14:49:00.002+02:002008-12-15T15:09:34.428+02:00Composite Oriented Programming Part 2I made a slightly more complicated version of the hello world example. This time I made two composite implementations of a Speaker interface.<br /><pre><br />public interface Speaker<br />{<br /> public void setSpeech(char[] speech);<br /> <br /> public char[] speak();<br />}<br /></pre><br />Then I changed how the data is handled as I didn't want two different templates, HelloData and ByeData. So I made a PropertiesMixin template which contains a simple way to set and get properties as char[]s.<br /><pre><br />public template PropertiesMixin()<br />{<br /> private char[][char[]] properties;<br /> <br /> public void set(char[] name, char[] value)<br /> {<br /> properties[name] = value;<br /> }<br /> <br /> public char[] get(char[] name, char[] defaultValue = null)<br /> {<br /> if (name in properties)<br /> {<br /> return properties[name];<br /> }<br /> return defaultValue;<br /> }<br />}<br /></pre><br />This can be used to add properties support to a class. There is room for improvement, for example some how use the tango.text.Properties class to save and load the properties.<br /><br />Then the real meat are the new HelloMixin and ByeMixin, which handles the heavy lifting.<br /><pre><br />public template HelloMixin()<br />{<br /> private static const char[] HELLO = "hello";<br /> <br /> mixin PropertiesMixin;<br /> <br /> public void setSpeech(char[] speech)<br /> {<br /> set(HELLO, speech);<br /> }<br /> <br /> public char[] speak()<br /> {<br /> return get(HELLO);<br /> }<br />}<br /><br />public template ByeMixin()<br />{<br /> private static const char[] BYE = "bye";<br /> <br /> mixin PropertiesMixin;<br /> <br /> public void setSpeech(char[] speech)<br /> {<br /> set(BYE, speech);<br /> }<br /> <br /> public char[] speak()<br /> {<br /> return get(BYE);<br /> }<br />}<br /></pre><br />I've mixed in the PropertiesMixin for both of them, and then implemented the Speaker interface functions using properties. We could even have a default speech very easily, if needed.<br /><br />The composite classes are very simple as they do not contain any functionality whatsoever.<br /><pre><br />public class HelloSpeaker : Speaker<br />{<br /> mixin HelloMixin;<br />}<br /><br />public class ByeSpeaker : Speaker<br />{<br /> mixin ByeMixin;<br />}<br /></pre><br />I've put the setting of the speeches in the main function of the program, where the composites are created, to better demonstrate the usage of the Speaker interface.<br /><pre><br />public void main()<br />{<br /> Speaker hello = new HelloSpeaker();<br /> hello.setSpeech("Hello, World!");<br /> Stdout(hello.speak()).newline;<br /> <br /> Speaker bye = new ByeSpeaker();<br /> bye.setSpeech("Bye, World!");<br /> Stdout(bye.speak()).newline;<br />}<br /></pre><br />I'm pretty impressed about how easy it is to implement complex objects using mixins. Next I need to look into a more complicated version. Something like Fredrik Kalseth has done <a href="http://iridescence.no/post/Composite-Oriented-Programming.aspx">here</a>.<br /><br />Until then you can find the new code <a href="http://odefu.googlecode.com/svn/trunk/CompositeOrientedProgramming/HelloWorld2/">here</a>.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-405728911719186340?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com0tag:blogger.com,1999:blog-2611445094003468791.post-45707347656169328492008-12-15T11:12:00.002+02:002008-12-15T11:39:41.772+02:00Composite Oriented ProgrammingOk, so I found a new buzzword; Composite Oriented Programming. I first heard it from Thomas Biskup. He wrote about it on his JADE-blog, <a href="http://www.adom.de/blog/2008/12/08/the-state-of-jade/">here</a>. From there I started reading about COP on <a href="http://www.qi4j.org">qi4j.org</a>. I haven't completely understood it, but so far it seems to be quite nice buzzword.<br /><br />So I wrote a small hello world sample in D using templates. Got it working after a while with the help of downs and Bill Baxter, on #D and D.learn respectively.<br /><br />You can find the code <a href="http://odefu.googlecode.com/svn/trunk/CompositeOrientedProgramming/HelloWorld/">here</a>.<br /><br />I'll go over it here now.<br /><br />First we have a template to hold out data, namely helloStr:<br /><pre><br />public template HelloData<br />{<br /> private char[] helloStr;<br />}<br /></pre><br />Next we define the action or function for the whole composite. I don't remember what this is in COP-speak.<br /><pre><br />public interface HelloSpeech<br />{<br /> public char[] sayHello();<br />}<br /></pre><br />Then we implement the above function in HelloSpeaker.<br /><pre><br />public template HelloSpeaker<br />{<br /> mixin HelloData;<br /><br /> public char[] sayHello()<br /> {<br /> return helloStr;<br /> }<br />}<br /></pre><br />So we mixin the data template, so we can return the helloStr from sayHello. Notice that we don't need to import the actual interface for sayHello.<br /><br />Then we will create the actual composite.<br /><pre><br />public class HelloWorld : HelloSpeech<br />{<br /> mixin HelloSpeaker;<br /><br /> public this()<br /> {<br /> helloStr = "Hello, World!";<br /> }<br />}<br /></pre><br />Now we have a concrete class that implements HelloSpeech. If you look at the code <a href="http://odefu.googlecode.com/svn/trunk/CompositeOrientedProgramming/HelloWorld/hello/HelloWorld.d">here</a>, you notice that we've had to import the HelloData module. This is as far as I can see the only downside so far.<br /><br />We have now nicely removed the implementation for sayHello to their own modules. This is a very small example, but I can see it to be quite useful with bigger systems and with more interfaces.<br /><br />Now just add an interface for setting the value for helloStr and creating an implementation for it, then this would be complete. The helloStr could be hidden completely behind a getter/setter-pair.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-4570734765616932849?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com0tag:blogger.com,1999:blog-2611445094003468791.post-46736380125925524792008-09-08T13:58:00.002+02:002008-09-08T14:04:36.565+02:00Small UpdateIt seems that I won't have much free time in the future either, Ive decided to completely stop even thinking on doing any of the old NeHe tutorials anymore. Besides anyone can get a pretty good idea of how to do them from those that I've already done and do the ones they want. It's good practice that way too. =)<div><br /></div><div>I'll probably do any new tutorials for the new basecode, if ever there will be any.</div><div><br /></div><div>My next D project or journey will be to familiarize myself with <a href="http://hybrid.team0xf.com/wiki/Main/HomePage">Hybrid</a> and <a href="http://hybrid.team0xf.com/wiki/Main/Dog">Dog</a>. I've got a few ideas on what to do with them. But time will tell. I'll write anything worthwhile here.</div><div><br /></div><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-4673638012592552479?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com0tag:blogger.com,1999:blog-2611445094003468791.post-4364089783111839232008-06-30T14:22:00.003+03:002008-06-30T14:36:51.974+03:00NeHe UpdateThere's been some activity on the NeHe site recently. They have launched a <a href="http://nehe.gamedev.net/wiki/NeHeProductionsWiki.ashx">wiki</a>, and are planning on moving the old stuff from the website to the wiki. There is also new versions of the new lessons on the wiki. For some reason they rewrote the <a href="http://nehe.gamedev.net/wiki/NewLessons.ashx">basecode and the first three lessons</a>. The beta version wasn't that bad. On the plus side the code is much simpler, so they can extend the it later.<br /><br />I've ported the new lessons to D. Why else write this post. =) I didn't do it 1:1, as in my opinion there are too much c++(bad design) in them. I kept them mostly as they were, but fixed most of the more glaring problems in it, at least in my opinion. I'm still thinking on making them more D'ish/generally better. I'll decide probably after more lessons are available, and we'll see where they are taking the basecode.<br /><br />You can find the relevant information about the source code on the <a href="http://code.google.com/p/odefu/">google code project page</a>.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-436408978311183923?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com0tag:blogger.com,1999:blog-2611445094003468791.post-54557874653864686722008-04-04T09:06:00.002+02:002008-04-04T09:17:08.533+02:00GLFW DerelictifiedI started looking again at the <a href="http://glfw.sourceforge.net/">GLFW</a> library yesterday. I do really like the API. Somehow it's nicer than SDL's. The only thing missing is a better support for image loading.<br /><br />I remembered using a D binding for GLFW once and tried to find it. In the end I found it in the Schooner project in dsource, but it hasn't been updated in a long time. Plus it uses Phobos. I thought about trying to update and convert it to Tango for about a second or two, and then decided to do Derelict bindings for it instead. They are easier to maintain, but the downside is that you need to lug around the shared library for it.<br /><br />I used the latest release of GLFW (2.6), and only tested things with a simple test application on Windows XP.<br /><br />So if you like the framework go grab the D bindings from <a href="http://code.google.com/p/odefu/source/browse/trunk/DerelictGLFW/">here</a>.<br /><br />Windows users please read the <a href="http://code.google.com/p/odefu/source/browse/trunk/DerelictGLFW/README.txt">readme</a> file.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-5455787465386468672?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com2tag:blogger.com,1999:blog-2611445094003468791.post-19401514028599267302008-03-20T21:44:00.002+02:002008-03-20T21:54:43.032+02:00NeHe Lesson 25: Morphing & Loading Objects From A FileSomehow I found time to do the next one too. This was pretty fun one as well. I love the morphing effect. And I like the simpleness of the code compared to the c/c++ version. :)<br /><br />I left out the Object struct as the D version didn't need the field for the number of vertices, and then there wasn't anything else left than the array itself. So now there are just arrays of Vertices.<br />I also put a static opCall in the Vertex struct, although it isn't strictly necessary.<br /><br />And as with the lesson 10, the datais imported into the binary at compile time, so no file i/o is needed.<br /><br />You can check it out <a href="http://code.google.com/p/odefu/source/browse/trunk/NeHe/lesson25/lesson25.d">here</a>.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-1940151402859926730?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com0tag:blogger.com,1999:blog-2611445094003468791.post-24237666462126699482008-03-20T09:45:00.002+02:002008-03-20T09:53:21.725+02:00NeHe Lesson 24: Tokens, Extensions, Scissor Testing And TGA LoadingA new lesson done. Yay! I should have called this one the Extensions and Scissor Testing lesson, because I left the TGA stuff out and the token thingy was replaced with a call to split. But I wanted to keep to the pattern with the lesson titles.<br /><br />I changed the code to initialize the texts only once and not every draw-call. Better that way. Otherwise there isn't that much new stuff. Then <a href="http://www.opengl.org/sdk/docs/man/xhtml/glScissor.xml">glScissor</a> call is pretty simple.<br /><br />See the code <a href="http://code.google.com/p/odefu/source/browse/trunk/NeHe/lesson24/lesson24.d">here</a>.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-2423766646212669948?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com0tag:blogger.com,1999:blog-2611445094003468791.post-64730144923517522892008-01-22T22:41:00.000+02:002008-01-22T22:46:04.135+02:00NeHe Lessons UpdatedIt's been a while. Life has been busy. Haven't had the time and energy for coding at home. Although I still follow the happenings in the D world. And because of that I've updated all the NeHe lessons to work with the latest version of Tango. I'll try to get more done during the coming spring, but can't promise anything as there are lots of things happening at the moment.<br /><br />Happy new year and all that. =)<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-6473014492351752289?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com0tag:blogger.com,1999:blog-2611445094003468791.post-68260342471489368212007-10-08T09:17:00.000+02:002007-10-08T12:29:36.839+02:00NeHe Lesson 23: Sphere Mapping Quadrics In OpenGLThe 23rd lesson is finished. Nothing special on the D-front in this one. Go read the the text <a href="http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=23">here</a>.<br />Then grab the code from <a href="http://odefu.googlecode.com/svn/trunk/NeHe/lesson23/lesson23.d">here</a>.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-6826034247148936821?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com4tag:blogger.com,1999:blog-2611445094003468791.post-27233220352919624942007-10-03T13:06:00.000+02:002007-10-03T13:15:44.473+02:00NeHe Lesson 22: Bump-Mapping, Multi-Texturing & ExtensionsOh, it's been a while from my last post. Been busy with the life outside of computers.<br /><br />The next lesson has been done for a quite a while now, except for a small bug. When displaying the cube with mip-mapped textures the texture is not drawn for some reason. Today I got the drawing working, but it introduced a another problem. The fix was to remove the texture flipping and rotating code from the initGL function. This has the effect of displaying the logos upside down and as mirror images, but now the mip-mapped cube is displayed correctly.<br /><br />If any of you has any idea how to fix this small problem, let me know so I can fix it. Otherwise I'll move on to the next lesson.<br /><br />The NeHe's lesson can be found <a href="http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=22">here</a>.<br /><br />Btw, I've kept the broken mip-map version in the repository as I think it's a smaller problem than upside down logos.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-2723322035291962494?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com1tag:blogger.com,1999:blog-2611445094003468791.post-29410916829605144312007-08-20T15:42:00.000+03:002007-08-20T15:47:19.299+03:00NeHe tutorials ported to D news postThere is a news post of D in general and my NeHe lesson ports on <a href="http://nehe.gamedev.net/">http://nehe.gamedev.net</a>. =)<br /><br />Direct link: <a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=460765">here</a>.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-2941091682960514431?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com5tag:blogger.com,1999:blog-2611445094003468791.post-18823511391446002222007-07-24T11:07:00.000+03:002007-07-24T11:34:34.277+03:00NeHe Lesson 21: Lines, Antialiasing, Timing, Ortho View And Simple SoundsIt's time for a new <a href="http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=21">lesson</a>. This time NeHe has made a simple game for us to enjoy.<br /><br />First before doing anything else make sure that you have <a href="http://www.libsdl.org/projects/SDL_mixer/">SDL_Mixer</a> installed on your system, as we're going to use it to play back the music and sound effects.<br /><br />Next is a small improvement I made over the C version, is the use of the enemies-array. The original lesson uses it as a static array, but I made it dynamic. This way we can use the D's great foreach-loop to go over every enemy in the level.<br /><br /><br /><pre>/// Enemy Information<br />GameObject[] enemies;<br /><br />....<br /><br />/**<br />* Resets the player character and all the enemies.<br />*/<br />void resetObjects()<br />{<br /> player.x = 0; // Reset Player X Position To Far Left Of The Screen<br /> player.y = 0; // Reset Player Y Position To The Top Of The Screen<br /> player.fx = 0; // Set Fine X Position To Match<br /> player.fy = 0; // Set Fine Y Position To Match<br /><br /> // Create the enemies for the next level/stage<br /> enemies = new GameObject[stage * level];<br /> // Loop Through All The Enemies<br /> foreach (inout enemy ; enemies)<br /> {<br /> // A Random X Position<br /> enemy.x = 5 + rand.next() % 6;<br /> // A Random Y Position<br /> enemy.y = rand.next() % 11;<br /> // Set Fine X To Match<br /> enemy.fx = enemy.x * 60;<br /> // Set Fine Y To Match<br /> enemy.fy = enemy.y * 40;<br /> }<br />}<br /></pre><br />As you can see there, we use the new operator to create just the number of enemies for the level/stage. Then we can loop over the array with foreach and be certain that we always have the correct number of enemies.<br /><br />In the module constructor the parameter to SDL_Init has changed to SDL_INIT_EVERYTHING.<br /><br /><pre>if (SDL_Init(SDL_INIT_EVERYTHING) < 0)<br />{<br /> throw new Exception("Failed to initialize SDL: " ~ getSDLError());<br />}</pre><br />This is needed for audio. There are other options, which you can read about <a href="http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fInit">here</a>.<br /><br />The module destructor is responsible for freeing the textures and SDL_Mixer's buffers.<br /><br /><pre>static ~this()<br />{<br /> // Clean up our font list<br /> glDeleteLists(base, 256);<br /><br /> // Clean up our textures<br /> glDeleteTextures(NUM_TEXTURES, &textures[0]);<br /><br /> // Stop playing the music<br /> Mix_HaltMusic();<br /><br /> // Free up the memory for the music<br /> Mix_FreeMusic(music);<br /><br /> // Free up any memory for the sfx<br /> Mix_FreeChunk(chunk);<br /><br /> // Close our audio device<br /> Mix_CloseAudio();<br /><br /> SDL_Quit();<br />}</pre><br />That's about it. Everything else is hopefully easy enough to understand, so just <a href="http://odefu.googlecode.com/svn/trunk/NeHe/lesson21/lesson21.d">dig in</a>.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-1882351139144600222?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com1tag:blogger.com,1999:blog-2611445094003468791.post-59257944208354982082007-07-04T14:37:00.000+03:002007-07-04T14:42:11.984+03:00NeHe Lesson 20: MaskingPuuh! Full 20 lessons now. =) Almost half of them. With luck I'll get them all by the end of the year. ;)<br /><br />This lesson doesn't bring anything special on the D-table, but the lesson itself is interesting, so go read <a href="http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=20">it</a>.<br /><br />I separated the texture loading into two functions, because there is 5 different textures which need to be loaded.<br /><br />The source can be found <a href="http://odefu.googlecode.com/svn/trunk/NeHe/lesson20/lesson20.d">here</a>.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-5925794420835498208?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com0tag:blogger.com,1999:blog-2611445094003468791.post-54070644674631713812007-06-26T16:45:00.000+03:002007-06-26T17:00:22.700+03:00NeHE Lesson 19: Particle Engine Using Triangle StripsI've been sitting on this one far too long. It's a nice tutorial on particles and NeHe has written a long explanation for it <a href="http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=19">here</a>. There shouldn't be anything new on the D front that warrants an explanation. If you disagree then leave me a note and I'll go over it.<br /><br />The source can be found <a href="http://odefu.googlecode.com/svn/trunk/NeHe/lesson19/lesson19.d">here</a>.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-5407064467463171381?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com1tag:blogger.com,1999:blog-2611445094003468791.post-15211884819321317522007-06-21T09:49:00.000+03:002007-06-21T09:53:48.111+03:00The OpenGL Pipeline Newsletter Volume 004The newest edition of the Pipeline has been <a href="http://www.opengl.org/pipeline/vol004/">released</a>. I've been reading it and there was a small paragraph which contains information about the recent debug stuff that has been going on in the D-OpenGL-land.<br /><br />Here's the part:<br /><br /><b></b><blockquote><b>More context creation options are available.</b> In the previous edition of <a href="http://www.opengl.org/pipeline/article/vol003_1/">OpenGL Pipeline</a> I described how we are planning on handling interoperability of OpenGL 2.1 and Longs Peak code. As a result, the application needs to explicitly create an OpenGL Longs Peak or OpenGL 2.x context. To aid debugging, it is also possible to request the GL to create a debug context. A debug context is only intended for use during application development. It provides additional validation, logging and error checking, but possibly at the cost of performance.</blockquote><br />At last OpenGL itself will assist the poor programmer in debuggin.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-1521188481932131752?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com2tag:blogger.com,1999:blog-2611445094003468791.post-71395548041806758642007-06-15T16:48:00.000+03:002007-11-28T09:15:07.539+02:00DebugGLAfter reading Daniel's excellent post <a href="http://while-nan.blogspot.com/2007/06/wrapping-functions-for-fun-and-profit.html">here</a>, which by the way was something I've been thinking about a little. Although not to the extend that Daniel has. But he got me working on the foundation he made in the post, and the first results can be seen <a href="http://odefu.googlecode.com/svn/trunk/OpenGLUtils/DebugGL.d">here</a>.<br /><br />And thanks to h3r3tic and larsivi on #D.Tango. Without you I couldn't have done this. :)<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-7139554804180675864?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com6tag:blogger.com,1999:blog-2611445094003468791.post-3761226814736476252007-05-16T16:12:00.000+03:002007-05-16T16:15:24.292+03:00New PageI've finally made use of the OdeFu projects <a href="http://code.google.com/p/odefu/">main page</a>. There is now a table of the NeHe lessons that have been done, with links to their respective sources. I've also added a link to the page to my bookmarks on the right side.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-376122681473647625?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com2tag:blogger.com,1999:blog-2611445094003468791.post-27472861157459921402007-05-16T12:19:00.000+03:002007-05-16T12:22:01.827+03:00NeHE Lesson 18: QuadricsThe 18th lesson gives a tour of some of the GLU functions and how to display different shapes with them. The shortish text can be read <a href="http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=18">here</a>. There shouldn't be anything special.<br /><br />The D code is <a href="http://odefu.googlecode.com/svn/trunk/NeHe/lesson18/lesson18.d">here</a>.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-2747286115745992140?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com1tag:blogger.com,1999:blog-2611445094003468791.post-3781662681772887462007-05-15T10:00:00.000+03:002007-05-15T10:07:50.410+03:00NeHe Lesson 17: 2D Texture FontThis lesson should contain code for those who are interested in drawing text in an OpenGL window. After reading <a href="http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=17">the tutorial</a> text and getting the hang of it, you might want to implement support for <a href="http://www.angelcode.com/products/bmfont/">AngelCode's</a> Bitmap Font Generator. It's a nifty tool for making bitmap fonts for your games.<br /><br /><a href="http://odefu.googlecode.com/svn/trunk/NeHe/lesson17/lesson17.d">Here's</a> the D code for the lesson.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-378166268177288746?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com2tag:blogger.com,1999:blog-2611445094003468791.post-12100620100091499632007-05-14T20:33:00.000+03:002007-05-14T20:39:01.916+03:00NeHe Lesson 16: Cool Looking FogThis lesson doesn't bring that much new to the table. The fog functions should be pretty self-explanatory, but read what <span class="text"><span nd="2" class="text">Chris Aliotta has to say about it <a href="http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=16">here</a>.<br /><br />The D version is <a href="http://odefu.googlecode.com/svn/trunk/NeHe/lesson16/lesson16.d">here</a>.<br /><br /></span></span><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-1210062010009149963?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com0tag:blogger.com,1999:blog-2611445094003468791.post-88541952955208672002007-05-14T18:46:00.000+03:002007-05-14T20:33:30.481+03:00About Lessons 13, 14 and 15I've decided that I'm not going to cover the next 3 lessons(13, 14 and 15). They contain platform specific code, and I'm not into that kind of stuff. The lesson 17 contains a way to show text in a platform independent way for those that want to see text in an OpenGL application.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-8854195295520867200?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com5tag:blogger.com,1999:blog-2611445094003468791.post-25194143554700659632007-05-12T14:10:00.000+03:002007-05-12T14:19:08.420+03:00The New NeHe TutorialsSome of you are probably aware that a beta version of the new NeHe tutorials have been <a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=437842">released</a> earlier this year. There is a window backend for all the lessons which contains window creation and a simple framework for running the lesson applications. Then they have written 5 lessons already.<br /><br />I've been writing them in D for some time now. When ever I've had time. They are now done and working nicely. I'm not going to go over them yet, as the real tutorials haven't been released yet, but you can browse the sources <a href="http://odefu.googlecode.com/svn/trunk/NewNeHe/">here</a>, or if you want to try them out just checkout them. I've written DSSS configuration files for them, so you can just do 'dsss install', for NeHeWindow, and then 'dsss build' for the lessons.<br /><br />And now back to your regular old NeHe tutorial studying.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-2519414355470065963?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com1tag:blogger.com,1999:blog-2611445094003468791.post-4467729699978199452007-04-18T14:06:00.000+02:002007-04-18T14:16:05.128+02:00The New NeHe LessonsI just noticed that a beta release is available for the new NeHe lessons. You can see the release notes <a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=437836">here.</a><br /><br />I took a look at the code, and apart from the horrible naming convetion and the fact that they still use C++, it looks pretty good. So I've decided to do a port of them to D, but there is a catch:<br /><br /> * I'll only port the SDL backend<br /> * I'll "fix" the naming convertion to something more to my tastes<br /> * I don't know when I have the time to do this<br /><br />Probably the best place to start is from the window backend so that I can get something useful done as fast as possible.<br /><br />Stay tuned.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-446772969997819945?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com3tag:blogger.com,1999:blog-2611445094003468791.post-57216056829908828212007-04-18T08:24:00.000+02:002007-04-18T08:47:29.459+02:00NeHe Lesson 12: Display ListsOk, didn't get to test this on Windows, but it should work as the lesson doesn't contain platform specific code.<br /><br />First off there's an example on how to initialize a static multi-dimensional array:<br />(In case you didn't know already how to do it.)<br /><pre>/// Array For Box Colors<br />GLfloat boxcol[5][3] =<br />[<br /> // Bright: Red, Orange, Yellow, Green, Blue<br /> [1.0f, 0.0f, 0.0f], [1.0f, 0.5f, 0.0f], [1.0f, 1.0f, 0.0f], [0.0f, 1.0f, 0.0f], [0.0f, 1.0f, 1.0f]<br />];</pre><br />In the module constructor we have something new.<br /><pre>// Enable key repeating<br />if ((SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL)))<br />{<br /> throw new Exception("Failed to set key repeat: " ~ getSDLError());<br />}</pre>Here we enable SDL to repeat key presses if you keep a key down. I've used SDL's default values for the arguments.<br /><br />There isn't really anything special about the rest of the code, so grab a cola and go read what NeHe has written on the subject, <a href="http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=12">here</a>.<br /><br />Here's the link to <a href="http://odefu.googlecode.com/svn/trunk/NeHe/lesson12/lesson12.d">the source</a>.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-5721605682990882821?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com1tag:blogger.com,1999:blog-2611445094003468791.post-18198951258897859332007-04-17T12:58:00.000+02:002007-04-17T13:02:59.489+02:00Linux UpdateI wanted to leave a quite note on the Linux support. I tested all the current lessons on a Linux box with the following setup: Tango RC1 with DMD 1.012 and Rebuild 0.18. All of the worked fine. Found only couple typos in image filenames. Wrong case.<br /><br />Plus I've pretty much done lesson 12 and I'll put it up as soon as I get home.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2611445094003468791-1819895125889785933?l=odefu.blogspot.com'/></div>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com0