<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
	<title>GameDev.net Forums RSS</title>
	<description>RSS Feed for all GameDev.net forums.</description>
	<link>http://www.gamedev.net</link>
	<pubDate>Thu, 23 May 2013 10:07:21 +0000</pubDate>
	<ttl>5</ttl>
	<image>
		<title>GameDev.net Forums RSS</title>
		<url>http://www.gamedev.net/favicon.ico</url>
		<link>http://www.gamedev.net</link>
	</image>
	<item>
		<title><![CDATA[Texture readback (from GPU-&#62;CPU)]]></title>
		<link>http://www.gamedev.net/topic/643451-texture-readback-from-gpu-cpu/</link>
		<description><![CDATA[<p>Hi gamedev community,</p>
<p>&nbsp;</p>
<p>I have been asked to implement a method by which a single depth value can be sampled from the depth information of a g-buffer (deferred renderer using a 32-bit floating point texture storing viewspace depth) and then this floating point value returned to system memory for storage and use in calculations on the CPU.</p>
<p>&nbsp;</p>
<p>For example, I would like to query the centre of the screen (effectively obtaining a depth value from the centre of the depth buffer) and then pass this back to the CPU / system memory. Sadly the depth buffer is the only source of depth information I have available to query for this particular application hence the need to pull values from it rather than elsewhere.</p>
<p>&nbsp;</p>
<p>I am limited to using DirectX9 feature set, HLSL and Shader Model 3.0.</p>
<p>&nbsp;</p>
<p>I am looking for suggestions as to how I might achieve this. I would suspect that I have to ultimately make use of the GetRenderTargetData function at some point and suffer the inherent GPU stalls that this results in. Any other ideas or things I may have missed?</p>
<p>&nbsp;</p>
<p>Thanks in advance for your time.</p>
<p>&nbsp;</p>
<p>p.s. I guess I'm basically looking for a view ray-&gt;scene intersection test that returns the first hit depth value whereby the only depth information I have available is that in the g-buffer. I hope that makes sense...</p>
]]></description>
		<pubDate>Thu, 23 May 2013 10:07:21 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643451-texture-readback-from-gpu-cpu/</guid>
	</item>
	<item>
		<title>Player Jittering with Camera Follow</title>
		<link>http://www.gamedev.net/topic/643450-player-jittering-with-camera-follow/</link>
		<description><![CDATA[<p>I'm making a 2D sidescroller in XNA &nbsp;and I'm having an issue with the way the camera follows the player. When the player walks left or right, and its walk speed is a decimal number, there's jitter.</p>
<p>&nbsp;</p>
<p><span rel='lightbox'><img class='bbc_img' src="http://i.imgur.com/Lpwkcxh.gif" alt="Lpwkcxh.gif"></span></p>
<p>This is what it looks like. I had to slow the game down to 50% speed for the gif to catch the jitter frames.</p>
<p>(Ignore the random vertical twitching, that's just some strange graphical bug that happens when I scale the backbuffer up too far.)</p>
<p>&nbsp;</p>
<p>I believe the cause of this is the relative speed between the camera and the player.</p>
<p>In the gif, the player's speed is at 1.5, so it will alternate between moving one pixel and two pixels per frame. This causes a sort of desync between the player and camera movement which causes the jitter.</p>
<p>&nbsp;</p>
<p>I need to be able to use decimal speeds because first of all, a speed of 1 is a bit slow for the player, and 2 is a bit fast, but also, if I add acceleration/deceleration&nbsp;the player's speed won't always be a whole number.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Some details:</p>
<p>&nbsp;</p>
<p>- Nothing is rounded in-code. All positions and velocities are floats. Rounding isn't needed since nothing can move in sub-pixels. I reduced the backbuffer resolution so changing an object's position by 1 will move it one pixel. Everything is drawn at integer positions, of course.</p>
<p>&nbsp;</p>
<p>- It's not the update order. The cycle is simple right now. The player moves, then the camera is updated. Switching the order doesn't fix the issue.</p>
<p>&nbsp;</p>
<p>- I remembered that Cave Story has nice and smooth camera interpolation, and large pixels, so I fired it up to see what it looks like, and I was really surprised too see that it suffers the same problem. For roughly a second after the camera starts moving, the player jitters by one horizontal pixel.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>My camera movement interpolation code is this:</p>
<pre class="prettyprint linenums:1">
if (camPos != playerPos) camPos += (playerPos - camPos) * strength;</pre>
<p>&nbsp;</p>
<p>Any ideas on how to fix this? I'm sure SOMEBODY has had this issue before other than me (and Pixel).</p>
<p>&nbsp;</p>
<p>If I need to include any more relevant code snippets, just let me know. I can't really think of any that would help at the moment.</p>
]]></description>
		<pubDate>Thu, 23 May 2013 09:39:31 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643450-player-jittering-with-camera-follow/</guid>
	</item>
	<item>
		<title>Mapping / Projecting a Pixel to a Hexagon?</title>
		<link>http://www.gamedev.net/topic/643449-mapping-projecting-a-pixel-to-a-hexagon/</link>
		<description><![CDATA[<p>Hello!</p>
<p>&nbsp;</p>
<p>I'm working on a hexagonal grid based setup in an engine that doesn't have any kind of native support for it (in fact, I'm quite limited) - at present I'm looking to build the grid into the world shaders; projecting it downwards over the game world. This part is relatively cheap and easy and doesn't worry me. Doing more complicated stuff, such as drawing ranges (such as character movement, or weapon ranges or whatever you might expect in a 2d grid based game) by shading the appropriate tiles is seemingly quite a lot more difficult.</p>
<p>&nbsp;</p>
<p>One suggestion that seems valid, is to draw out the selection to be shaded to a render target. Since a hexagonal grid is structured more or less the same way as a square grid, you could represent each hexagonal cell with a single pixel - meaning that a selection that is a maximum of 8x8 cells square wouldn't need to use a render target any larger than 64 total pixels.</p>
<p>&nbsp;</p>
<p>My question is thus - how would one go about the maths to project each pixel in the render target into a hexagon in world space?</p>
<p>&nbsp;</p>
<p>Or is there a more valid approach to my problem?</p>
<p>&nbsp;</p>
<p>Thanks!</p>
<p>&nbsp;</p>
<p>Luke</p>
]]></description>
		<pubDate>Thu, 23 May 2013 09:33:27 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643449-mapping-projecting-a-pixel-to-a-hexagon/</guid>
	</item>
	<item>
		<title>Hardware/Software rasterizer vs Ray-tracing</title>
		<link>http://www.gamedev.net/topic/643448-hardwaresoftware-rasterizer-vs-ray-tracing/</link>
		<description><![CDATA[<p><span style="font-family:arial, sans-serif;font-size:13px;">Hi people <img src='http://public.gamedev5.net//public/style_emoticons/default/smile.png' class='bbc_emoticon' alt=':)' />,</span></p>
<div style="font-family:arial, sans-serif;font-size:13px;">&nbsp;</div>
<div style="font-family:arial, sans-serif;font-size:13px;">I saw the presentation at the High-Perf Graphics "High-Performance Software Rasterization on GPUs" and I was very impressed of the work/analysis/comparison.. it looks amazing..</div>
<div style="font-family:arial, sans-serif;font-size:13px;">&nbsp;</div>
<div style="font-family:arial, sans-serif;font-size:13px;">My background was Cuda, then I started learning OpenGL two years ago to develop the 3d interface of EMM-Check, a field-of-view-analyze program to check if a vehicle is going to fulfill a specific standard or not. essentially you load a vehicle (or different parts), then you can move it completely or separately, add mirrors/cameras, analyze the point of view and shadows for the point of view of the driver, etc..</div>
<div style="font-family:arial, sans-serif;font-size:13px;">&nbsp;</div>
<div style="font-family:arial, sans-serif;font-size:13px;">We are dealing with some transparent elements (mainly the field of views, but also vehicle themselves might be), therefore I wrote some&nbsp;rough algorithm to sort on fly the elements to be rendered (at primitive level, a kind of Painter's algorithm) but of course there are cases in which it easily fails, although for most of cases is enough..</div>
<div style="font-family:arial, sans-serif;font-size:13px;">&nbsp;</div>
<div style="font-family:arial, sans-serif;font-size:13px;">For this reason I started googling, I found many techniques, like (dual) depth peeling, A/R/K/F-buffer, ecc ecc</div>
<div style="font-family:arial, sans-serif;font-size:13px;">&nbsp;</div>
<div style="font-family:arial, sans-serif;font-size:13px;">But it looks like all of them suffer at high resolution and/or large number of triangles..</div>
<div style="font-family:arial, sans-serif;font-size:13px;">&nbsp;</div>
<div style="font-family:arial, sans-serif;font-size:13px;">Since we also deal with&nbsp;millions&nbsp;of triangles (up to 10 more or less), I was looking for something else and I ended up to software renderers, compared to the hw ones, they offer free programmability but they are slower..</div>
<div style="font-family:arial, sans-serif;font-size:13px;">&nbsp;</div>
<div style="font-family:arial, sans-serif;font-size:13px;">So I wonder if it might be possible to implement something hybrid, that is using the hardware renderer for the opaque elements and the software one for the transparent elements and then combining the two results..</div>
<div style="font-family:arial, sans-serif;font-size:13px;">&nbsp;</div>
<div style="font-family:arial, sans-serif;font-size:13px;">Or maybe a simple (no complex visual effect required, just position, color and simple light) ray-tracing algorithm in cuda/opencl might be much simpler from this point of view and give us also a lot of freedom/flexibility in the future?</div>
<div style="font-family:arial, sans-serif;font-size:13px;">&nbsp;</div>
<div style="font-family:arial, sans-serif;font-size:13px;">I did not find anything on the net regarding this... maybe is there any particular obstacle?</div>
<div style="font-family:arial, sans-serif;font-size:13px;">&nbsp;</div>
<div style="font-family:arial, sans-serif;font-size:13px;">I would like to know every single think/tips/idea/suggestion that you have regarding this</div>
<div style="font-family:arial, sans-serif;font-size:13px;">&nbsp;</div>
<div style="font-family:arial, sans-serif;font-size:13px;">&nbsp;</div>
<div style="font-family:arial, sans-serif;font-size:13px;">Ps: I also found "Single Pass Depth Peeling via CUDA Rasterizer" by Liu, but the solution from the first paper seems fair faster</div>
<div id='attach_wrap' class='clearfix'>
	<h4>Attached Files</h4>
	<ul>
		
			<li class='attachment'>
				<a href="http://www.gamedev.net/index.php?app=core&module=attach&section=attach&attach_id=15870" title="Download attachment"><img src="http://www.gamedev.net/public/style_extra/mime_types/pdf.gif" alt="Attached File" /></a>
&nbsp;<a href="http://www.gamedev.net/index.php?app=core&module=attach&section=attach&attach_id=15870" title="Download attachment"><strong>laine2011hpg_paper.pdf</strong></a> &nbsp;&nbsp;<span class='desc'><strong>7.93MB</strong></span>
&nbsp;&nbsp;<span class="desc lighter">6 downloads</span>
			</li>
		

			<li class='attachment'>
				<a href="http://www.gamedev.net/index.php?app=core&module=attach&section=attach&attach_id=15871" title="Download attachment"><img src="http://www.gamedev.net/public/style_extra/mime_types/pdf.gif" alt="Attached File" /></a>
&nbsp;<a href="http://www.gamedev.net/index.php?app=core&module=attach&section=attach&attach_id=15871" title="Download attachment"><strong>062-liu.pdf</strong></a> &nbsp;&nbsp;<span class='desc'><strong>111.81K</strong></span>
&nbsp;&nbsp;<span class="desc lighter">7 downloads</span>
			</li>
		
	</ul>
</div>]]></description>
		<pubDate>Thu, 23 May 2013 09:04:10 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643448-hardwaresoftware-rasterizer-vs-ray-tracing/</guid>
	</item>
	<item>
		<title><![CDATA[Framework Question &#38; Advice!]]></title>
		<link>http://www.gamedev.net/topic/643445-framework-question-advice/</link>
		<description><![CDATA[<p>I just have a simple question regarding frameworks that is compatible to a text based game as I displayed in&nbsp;attachments (<strong>as examples</strong>) for a game I am developing that has very somewhat similar qualities. My&nbsp;colleague is the main programmer on the project at the moment (which is quite large in scale) but we became stuck on the MVC&nbsp;Robot-legs&nbsp;framework but apparently it didn't adjust too well but he did suggest possibly using Entity but he as an I am not sure whether or not Entity would be&nbsp;compatible&nbsp;that type of game I have in mind so anyone that is familiar with Entity or any other framework that would adjust as well (that could help organize the coding) please reply back and to add the game will be using Flash.&nbsp;</p>
<p>&nbsp;</p>
<p>Thank You much&nbsp;appreciated.&nbsp;</p>
<div id='attach_wrap' class='clearfix'>
	<h4>Attached Thumbnails</h4>
	<ul>
		
			<li class=''>
				<a class='resized_img' rel='lightbox[5064059]' id='ipb-attach-url-15868-0-04129700-1369304600' href="http://www.gamedev.net/index.php?app=core&module=attach&section=attach&attach_rel_module=post&attach_id=15868" title="music_wars_rebirth_02.jpg - Size: 125.16K, Downloads: 8"><img itemprop="image" src="http://uploads.gamedev.net/monthly_05_2013/post-191675-0-97533900-1369293532_thumb.jpg" id='ipb-attach-img-15868-0-04129700-1369304600' style='width:480;height:361' class='attach' width="480" height="361" alt="music_wars_rebirth_02.jpg" /></a>

			</li>
		

			<li class=''>
				<a class='resized_img' rel='lightbox[5064059]' id='ipb-attach-url-15869-0-04148900-1369304600' href="http://www.gamedev.net/index.php?app=core&module=attach&section=attach&attach_rel_module=post&attach_id=15869" title="hollywood-mogul-4.jpg - Size: 78.89K, Downloads: 8"><img itemprop="image" src="http://uploads.gamedev.net/monthly_05_2013/post-191675-0-31757800-1369293547_thumb.jpg" id='ipb-attach-img-15869-0-04148900-1369304600' style='width:480;height:359' class='attach' width="480" height="359" alt="hollywood-mogul-4.jpg" /></a>

			</li>
		
	</ul>
</div>]]></description>
		<pubDate>Thu, 23 May 2013 07:29:52 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643445-framework-question-advice/</guid>
	</item>
	<item>
		<title>How to structure a game in OOP</title>
		<link>http://www.gamedev.net/topic/643444-how-to-structure-a-game-in-oop/</link>
		<description><![CDATA[<p>Hi, I have rewritten my project several times to adapt to new game structures. I do this to conform to rules such as, no static or global variables, no singleton patterns and the single responsibility principle.</p>
<p>&nbsp;</p>
<p>The&nbsp;application consist of class objects. I often find myself creating a "super" class to only make one instance of it. Such as a Renderer class. This class handles the window, resolution, fullscreen toggle and draws the scene.</p>
<p>&nbsp;</p>
<p>Another class is the Asset Manager, one instance is created and it handles loading files and preparing them for later use. It keeps an array of all assets. Since the Asset Manager needs the <strong>device </strong>to create resources (VB, IB, Textures)&nbsp;in the managed pool, I keep a private pointer to the device in Asset&nbsp;Class and make a copy in the constructor. This cross object dependancy is to conform to the "rules", maybe there is a better solution?</p>
<p>&nbsp;</p>
<p>The Entity class has one instance, it has a list of (pointers to)&nbsp;Player objects (struct). These player structs contain information such as what Skeleton to use, what Mesh to use,&nbsp;and character variables.</p>
<p>&nbsp;</p>
<p>When rendering I pass the list of Entities to the renderer which looks up the Asset Manager&nbsp;for the resources and draws them as&nbsp;described in the Player object.&nbsp;</p>
<p>&nbsp;</p>
<p>There are also other classes such as the animator and&nbsp;gui but I kept those out to keep it short. Is this a good game structure? What should I pay attention to, and are there any other game structures I should consider?</p>
<p>&nbsp;</p>
<p>The pseudo-code:</p>
<pre class="prettyprint lang-">
main(){
InputOutputClass IO;
DeviceClass Renderer;
AssetClass Assets(Renderer.GetDevice());
EntityClass Entities;
GuiClass Gui(Renderer.GetDevice());

MainLoop(Renderer, Assets, Entities, IO, Gui);

}
</pre>]]></description>
		<pubDate>Thu, 23 May 2013 07:13:42 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643444-how-to-structure-a-game-in-oop/</guid>
	</item>
	<item>
		<title><![CDATA[Implementing &#34;actions&#34;  in an action game]]></title>
		<link>http://www.gamedev.net/topic/643442-implementing-actions-in-an-action-game/</link>
		<description><![CDATA[<p>I'll use Link to the Past as an example</p>
<p>&nbsp;</p>
<p>Frame 1:</p>
<p><a class='resized_img' rel='lightbox[5064046]' id='ipb-attach-url-15864-0-05299800-1369304600' href="http://www.gamedev.net/index.php?app=core&module=attach&section=attach&attach_rel_module=post&attach_id=15864" title="link1.jpg - Size: 11.34K, Downloads: 5"><img itemprop="image" src="http://uploads.gamedev.net/monthly_05_2013/post-211146-0-90027700-1369290094.jpg" id='ipb-attach-img-15864-0-05299800-1369304600' style='width:86;height:101' class='attach' width="86" height="101" alt="link1.jpg" /></a>
</p>
<p>&nbsp;</p>
<p>Link takes out his sword and begins the attack animation. Though the sword is being rendered, it has no hitbox yet. For the next couple of frames, pressing the d-pad or any buttons will have no effect on Link.&nbsp;</p>
<p>&nbsp;</p>
<p>Frame 3:</p>
<p><a class='resized_img' rel='lightbox[5064046]' id='ipb-attach-url-15865-0-05318400-1369304600' href="http://www.gamedev.net/index.php?app=core&module=attach&section=attach&attach_rel_module=post&attach_id=15865" title="link2.jpg - Size: 16.87K, Downloads: 4"><img itemprop="image" src="http://uploads.gamedev.net/monthly_05_2013/post-211146-0-33262500-1369290313.jpg" id='ipb-attach-img-15865-0-05318400-1369304600' style='width:116;height:112' class='attach' width="116" height="112" alt="link2.jpg" /></a>
</p>
<p>&nbsp;</p>
<p>The sword now has a hitbox and can collide with enemies.</p>
<p>&nbsp;</p>
<p>Frame 6:</p>
<p><a class='resized_img' rel='lightbox[5064046]' id='ipb-attach-url-15866-0-05334300-1369304600' href="http://www.gamedev.net/index.php?app=core&module=attach&section=attach&attach_rel_module=post&attach_id=15866" title="link3.jpg - Size: 17.3K, Downloads: 5"><img itemprop="image" src="http://uploads.gamedev.net/monthly_05_2013/post-211146-0-53411900-1369290353.jpg" id='ipb-attach-img-15866-0-05334300-1369304600' style='width:105;height:141' class='attach' width="105" height="141" alt="link3.jpg" /></a>
</p>
<p>&nbsp;</p>
<p>The player can now press attack to interrupt the current attack animation and start a new one. Any other input is still ignored.&nbsp;</p>
<p>&nbsp;</p>
<p><a class='resized_img' rel='lightbox[5064046]' id='ipb-attach-url-15867-0-05352200-1369304600' href="http://www.gamedev.net/index.php?app=core&module=attach&section=attach&attach_rel_module=post&attach_id=15867" title="link4.jpg - Size: 19.51K, Downloads: 5"><img itemprop="image" src="http://uploads.gamedev.net/monthly_05_2013/post-211146-0-50720900-1369290650.jpg" id='ipb-attach-img-15867-0-05352200-1369304600' style='width:152;height:123' class='attach' width="152" height="123" alt="link4.jpg" /></a>
</p>
<p>&nbsp;</p>
<p>On the last frame of the animation (13), the game checks to see if the attack button is held down. If it is, Link enters a new state where he begins charging his sword. If not, on the next frame, the animation ends, the sword disappears, and full control is given back to the player.</p>
<p>&nbsp;</p>
<p>I'm wondering, how would people approach the problem of implementing "actions" like these in a video game? Where rather than the action taking place in a single frame, it takes place over several frames and updates certain things(like the position of the sword is always attached to link's hand, even if he is moved by some outside force during the animation) each frame. With access to today's technologies of course.&nbsp;</p>
<p>&nbsp;</p>
<p>Best i can come up with for an "attack" action is hard coding it based on states. Pressing attack puts Link in the "Sword Attack" state and starts a timer. The game sees this, then creates the sword and starts playing out the animations. Each frame, the game updates, checks the time passed to see if it should add the hitbox or whatever it needs to do. The second half of the animation would have its own state, so the game knows that it is allowed to accept input for another attack to interrupt the current one.</p>
<p>&nbsp;</p>
<p>That means coming up with a different set of states for every action in the game though, which would be a pain. Especially in a component+entity system, where you would need to add the code into a State System or something instead of each entity's &nbsp;own update method. &nbsp;So i'm wondering to see if there are better ways to handle this, especially more data-driven ways.&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></description>
		<pubDate>Thu, 23 May 2013 07:04:43 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643442-implementing-actions-in-an-action-game/</guid>
	</item>
	<item>
		<title><![CDATA[i want to make games for people to be happy but don't know how]]></title>
		<link>http://www.gamedev.net/topic/643440-i-want-to-make-games-for-people-to-be-happy-but-dont-know-how/</link>
		<description>Hi there... as you are reading this, there are some things you should know. First, i am new to this fourm.  Second, i am a 14 year old who just recently had a serious talk with his parents about life.  Now, i have now decided in my life that i Want to make video games because i get to design, compose music, and draw my own game. Though, i do need help in knowing how to make a game, so if anyone can help me, it would be majorly appreciated.</description>
		<pubDate>Thu, 23 May 2013 05:12:56 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643440-i-want-to-make-games-for-people-to-be-happy-but-dont-know-how/</guid>
	</item>
	<item>
		<title><![CDATA[[FFP] Lighting for terrain so dull (dark)]]></title>
		<link>http://www.gamedev.net/topic/643438-ffp-lighting-for-terrain-so-dull-dark/</link>
		<description><![CDATA[<p>Hi,</p>
<p>&nbsp; &nbsp; I'm working with an tile based terrain. The terrain is display in an isometric view. I try to limit myself to FFP because I want to target low system computers. The problem is that I tried so many light direction, the world light is so dull. The maximum bright (the surface face the light ? ) is the current texture color. Every other surface look darker. I think the surface that direct the light should get brighter than it's normal texture color! How can I achieve it with old FFP ?<br>
I want to achieve the flat terrain surface should get lit 100% (normal texture color). the slope face the light should get brighter, the other slopes should get darker!</p>
<p><span rel='lightbox'><img class='bbc_img' src="http://i1335.photobucket.com/albums/w666/greenpig83/sc3_zps386ada13.png" alt="sc3_zps386ada13.png"></span></p>
<p>(same normal for 1 Triangle)</p>
<p>&nbsp;</p>
<p><span rel='lightbox'><img class='bbc_img' src="http://i1335.photobucket.com/albums/w666/greenpig83/sc4_zps228f11e0.png" alt="sc4_zps228f11e0.png"></span></p>
<p>(Each vertex have its own Normal - &nbsp;the edge look smooth, but the lighting even darker!)</p>
<p>&nbsp;</p>
<p>Original Texture :&nbsp;</p>
<p><span rel='lightbox'><img class='bbc_img' src="http://i1335.photobucket.com/albums/w666/greenpig83/15030_zps7e49cc20.png" alt="15030_zps7e49cc20.png"></span></p>
]]></description>
		<pubDate>Thu, 23 May 2013 02:53:55 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643438-ffp-lighting-for-terrain-so-dull-dark/</guid>
	</item>
	<item>
		<title>Python Twisted Question: Return Deferred Result</title>
		<link>http://www.gamedev.net/topic/643437-python-twisted-question-return-deferred-result/</link>
		<description><![CDATA[<p>Hi everyone. I'm writing a Twisted based daemon for a simple text-based multiplayer game. The game logic goes like this. The client sends a string in a particular format (command.arguments) to the server. The server receives that string, split it, and run the command along with the arguments. I already made it working.</p>
<p>&nbsp;</p>
<p>One of the command called has to get data from database. I'm using Twistar to make things fancy.&nbsp; The problem is, I need to return the result of the deferred made by the query. I know it sounds so newbie, but this is my first Twisted program, and I'm still learning.</p>
<p>&nbsp;</p>
<p>Well, I think the scripts will make things clearer:</p>
<p>&nbsp;</p>
<p>The server.py (don't worry, it's inside a code tag):</p>
<div class='bbc_spoiler'>
	<span class='spoiler_title'>Spoiler</span> <input type='button' class='bbc_spoiler_show' value='Show' />
	<div class='bbc_spoiler_wrapper'><div class='bbc_spoiler_content' style="display:none;">
<pre class="prettyprint">
from twisted.application import internet, service

import protocols, services


udp_port = 10000
multicast_addr = '234.0.0.1'

dbuser = 'testuser'
dbpass = 'password'

main_service = service.MultiService()

game_service = services.GameService(dbuser, dbpass)
game_service.setServiceParent(main_service)

udp_service = internet.MulticastServer(udp_port, protocols.MulticastGameProtocol(multicast_addr, game_service), listenMultiple=True)
udp_service.setServiceParent(main_service)

application = service.Application('Simple Thing')

main_service.setServiceParent(application)

&nbsp;</pre>
</div></div>
</div>
<p>&nbsp;</p>
<p>The protocols.py</p>
<p>&nbsp;</p>
<div class='bbc_spoiler'>
	<span class='spoiler_title'>Spoiler</span> <input type='button' class='bbc_spoiler_show' value='Show' />
	<div class='bbc_spoiler_wrapper'><div class='bbc_spoiler_content' style="display:none;">
<p>&nbsp;</p>
<pre class="prettyprint">
from twisted.internet.protocol import DatagramProtocol


class MulticastGameProtocol(DatagramProtocol):

&nbsp;&nbsp;&nbsp; def __init__(self, multicast_addr, service):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.multicast_addr = multicast_addr
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.service = service


&nbsp;&nbsp;&nbsp; def startProtocol(self):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.transport.setTTL(5)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.transport.joinGroup(self.multicast_addr)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp;&nbsp; def datagramReceived(self, datagram, address):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'Datagram %s received from %s' % (repr(datagram), repr(address))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if '.' not in datagram:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 'Invalid command format.'

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; celcommand_name, arguments = datagram.split('.', 1)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.celcommandRequestReceived(celcommand_name, arguments, address)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp;&nbsp; def celcommandRequestReceived(self, celcommand_name, arguments, address):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; command_result = self.doCommand(celcommand_name, arguments)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if command_result is not None:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.transport.write(command_result, address)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp;&nbsp; def doCommand(self, celcommand_name, arguments):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; submitted_command = getattr(self, 'celcommand_%s' % (celcommand_name), None)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if submitted_command is None:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 'Invalid command.'
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #return 'COMMAND SUCCESS!!!'
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return repr(submitted_command(arguments))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; except:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #return 'Command failed.'
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return repr(submitted_command(arguments))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp;&nbsp; def celcommand_login(self, arguments):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; username, password = arguments.split('.', 1)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return self.service.login(username, password)
</pre>
</div></div>
</div>
<p>&nbsp;</p>
<p>The services.py</p>
<div class='bbc_spoiler'>
	<span class='spoiler_title'>Spoiler</span> <input type='button' class='bbc_spoiler_show' value='Show' />
	<div class='bbc_spoiler_wrapper'><div class='bbc_spoiler_content' style="display:none;">
<p>&nbsp;</p>
<pre class="prettyprint">
from twisted.application import service
from twisted.python import log
from twisted.internet import defer

from twistar.dbobject import DBObject

class Users(DBObject):
&nbsp;&nbsp;&nbsp; pass
&nbsp;&nbsp; &nbsp;
class GameService(service.Service):

&nbsp;&nbsp;&nbsp; def __init__(self, dbuser, dbpass):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.dbuser = dbuser
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.dbpass = dbpass
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp;&nbsp; def startService(self):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; service.Service.startService(self)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from twisted.enterprise import adbapi
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from twistar.registry import Registry

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Registry.DBPOOL = adbapi.ConnectionPool('MySQLdb', user=dbuser, passwd=dbpass, db='test')
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.user = Users()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; log.msg('Made connection to database.')
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp;&nbsp; def login(self, username, password):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.loginUser = self.user.find(where=['username="%s" AND password_hash="%s"' % (username, password)], limit=1)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.loginUser.addCallback(self.checkLogin)
        return self.loginUser
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp;&nbsp; def checkLogin(self, query_result):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if query_result is None:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 'Login failed!'
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print '%s logged in' % (query_result.username)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return query_result.username
&nbsp;
</pre>
</div></div>
</div>
<p>&nbsp;</p>
<p>I'm sure the error is in the login function. I think it's like saying "Wait. My result isn't here yet" by returning a deferred, but it will be the deferred which is sent to the client.</p>
<p>&nbsp;</p>
<p>Well, there's no complicated logic yet. I started writing this just two days ago. All I want is to send the query_result.username to the client. The query is fine. I can print that thingy on the server.</p>
<p>&nbsp;</p>
<p>The client is just a simple client which sends 'login.Sky Warden.123'. The arguments will be separated by the '.' as well.</p>
<p>&nbsp;</p>
<p>I think that's all. Maybe it's just me who don't fully understand deferreds, or it's just a logic hole. Or maybe both. XD</p>
<p>&nbsp;</p>
<p>Thank you everyone. <span rel='lightbox'><img class='bbc_img' src="http://public.gamedev5.net//public/style_emoticons/default/smile.png" title=":)" alt="smile.png"></span></p>
]]></description>
		<pubDate>Thu, 23 May 2013 02:06:24 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643437-python-twisted-question-return-deferred-result/</guid>
	</item>
	<item>
		<title>2D Game library that uses OpenGL but works great with Linux</title>
		<link>http://www.gamedev.net/topic/643436-2d-game-library-that-uses-opengl-but-works-great-with-linux/</link>
		<description><![CDATA[<p>I'm looking for a library like "cocos2d-x" that&nbsp;abstracts the OpenGL library for 2D games. I don't need to make 3D games, I'm just need all power of OpenGL for a 2D game. The problem with&nbsp;"cocos2d-x" is have a poor support for Linux (not stable only "usable") and requires a relative high version of OpenGL, that means a lot of "middle age" computers will not run the game. Don't matter if such library don't manages sound or events, I can complement this with SDL. Thanks in advance!</p>
]]></description>
		<pubDate>Thu, 23 May 2013 01:23:27 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643436-2d-game-library-that-uses-opengl-but-works-great-with-linux/</guid>
	</item>
	<item>
		<title>expected template ambiguity</title>
		<link>http://www.gamedev.net/topic/643434-expected-template-ambiguity/</link>
		<description><![CDATA[<div>i expected the following code to raise an error because the compiler doesnt know wich func to use, the template or non-template one</div>
<div><pre class="prettyprint linenums:0">
#include &lt;string&gt;
#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
&nbsp;
template&lt;typename T&gt;
T func(T arg) { return arg; }
&nbsp;
std::string func(std::string arg) { return "surprise!"; }
&nbsp;
&nbsp;
int main(int argc, char **argv) {
&nbsp; &nbsp; std::cout &lt;&lt; func(std::string("no surprise please!") );
&nbsp; &nbsp; system("PAUSE");
&nbsp; &nbsp; return 0;
}
</pre></div>
<div>however the code always calls the non-template function.&nbsp;</div>
<div>1.Why is that?</div>
<div>2.If that kind of behaviour is part of the standard (calling non-template functions rather than fitting templates), whats the point of the special syntax for template specialization?</div>
<div>i.e.<br><pre class="prettyprint linenums:0">
template&lt;&gt;
std::string func&lt;std::string&gt;(std::string arg) { return "surprise!"; }
</pre></div>]]></description>
		<pubDate>Wed, 22 May 2013 23:42:07 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643434-expected-template-ambiguity/</guid>
	</item>
	<item>
		<title>high over 3d engine design</title>
		<link>http://www.gamedev.net/topic/643433-high-over-3d-engine-design/</link>
		<description><![CDATA[<p>Hi all,</p>
<p><br>
For the last years (with pauses) I've been working on my own C++ 3d engine.</p>
<p>I'm using D3D9 for rendering up till today (DX11 later now, gathering knowledge and experience first).</p>
<p>&nbsp;</p>
<p>Everything's done on a hobby basis and last months I've been working myself through basics, like brushing up C++ and 2d games.</p>
<p>For who's interested: <a href='http://www.crealysm.com/games/Asteroidz%20v0.3.zip' class='bbc_url' title='External link' rel='nofollow external'>http://www.crealysm.com/games/Asteroidz%20v0.3.zip</a>.</p>
<p>&nbsp;</p>
<p>With all knowledge gained and articles/ books read, I'm rethinking my high over 3d engine design.</p>
<p>I would really like to hear your thoughts and gather input, before adding more and more functionality.</p>
<p>&nbsp;</p>
<p>Below I've tried to explain 'the basic layout'.</p>
<p>Any input is really appreciated, what would you do, what do you think is wrong as initial design etc.</p>
<p>&nbsp;</p>
<p>Next steps will be</p>
<p>- implemening correct usage of 'const'&nbsp;(when passing objects by reference)</p>
<p>-&nbsp;adding an entity manager/class structure (with vectors instead of dynamic arrays, which I now do for the 'static scene')</p>
<p>- rethink/ design classes using inheritance, not done up till now</p>
<p>- make some simple demo's along the way, adjust and improvise along the way</p>
<p>&nbsp;</p>
<p>(my apologies for using text, the VS class diagram doesn't work somehow, something about keys being added already)</p>
<p>&nbsp;</p>
<p>TOP LEVEL: NAMESPACES (including classes, .....)</p>
<p>&nbsp;</p>
<p>- d3drenderer (camera, font, light, mesh, mesh instance, scene, shader, skybox)</p>
<p>- dxinput</p>
<p>- dxmath (boundingbox, struct likes vectors, materials, vertices)</p>
<p>- game (player)</p>
<p>- general (FPS/ timer)</p>
<p>- IO (fileformat for scenes, classes for light, mesh, meshinstance etc., api independent)</p>
<p>- math (structs API independent, vector, indices for materials/ submeshes, colors etc.)</p>
<p>- renderer (scenegraph class and structs for effects/shaders, lights, materials, meshes, instances etc.)</p>
<p>- audio (FMod audio wrapper, class)</p>]]></description>
		<pubDate>Wed, 22 May 2013 22:16:46 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643433-high-over-3d-engine-design/</guid>
	</item>
	<item>
		<title>Health Effect</title>
		<link>http://www.gamedev.net/topic/643431-health-effect/</link>
		<description><![CDATA[<p style="color:rgb(51,51,51);font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;">I want to make something already done by a lot of games , which is when I am taking so much hits from enemy red screen drawn like the following , using XNA 4.0:</p>
<p style="color:rgb(51,51,51);font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;">after it's drawn and I am still alive I want to be removed slightly as in the call of duty !!!<br><br><span rel='lightbox'><img class='bbc_img' src="http://www.mediafire.com/convkey/2e7a/4r9xgose284oedd6g.jpg" alt="4r9xgose284oedd6g.jpg"></span></p>
]]></description>
		<pubDate>Wed, 22 May 2013 22:01:36 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643431-health-effect/</guid>
	</item>
	<item>
		<title>Shader Library design and implementation</title>
		<link>http://www.gamedev.net/topic/643430-shader-library-design-and-implementation/</link>
		<description><![CDATA[<p>I'm trying to come up with a good design for a convenient and low-overhead shader library abstracting away low-level graphics API details and allowing me to focus on shaders/game renderer development.</p>
<p>&nbsp;</p>
<p>Basically, i'm pursuing the following goals:</p>
<p>&nbsp;</p>
<p>1) minimal memory footprint - no string names at run-time, minimal amount of metadata if any;</p>
<p>&nbsp;</p>
<p>2) support for hot-reloading modified shader files;</p>
<p>&nbsp;</p>
<p>3) support for caching compiled shader bytecode and filtering out duplicates;</p>
<p>&nbsp;</p>
<p>How are such shader libraries usually built and how should it be used in actual engine code?</p>
<p>Are there any more performant alternatives to DirectX effects?</p>
<p>&nbsp;</p>
<p>The first problem can be solved by storing name hashes instead of full strings (in C++ code compile-time string hashing could be used).</p>
<p>The second one is tough for me, because my shader techniques can depend on global stuff (constant buffers, sampler states and shader resources) and before reloading changed technique i'll have to 'link' it (to avoid recreating those globals).</p>
<p>&nbsp;</p>
<p>Right now, my pipeline structure conceptually looks like this:</p>
<pre class="prettyprint">
struct Pipeline
{
              // global stuff
	Array&lt; RenderTargetResource &gt;		renderTargets;
	Array&lt; DepthStencilStateResource &gt;	depthStencilStates;
	Array&lt; RasterizerStateResource &gt;	rasterizerStates;
	Array&lt; SamplerStateResource &gt;		samplerStates;
	Array&lt; BlendStateResource &gt;		blendStates;
	Array&lt; StateBlock &gt;			stateBlocks;

	Array&lt; CBufferResource &gt;	constantBuffers;       //&lt;= global constant buffers (e.g. cbPerFrame, per-view, per-instance)
             // handles to shader sampler states are stored in the 'samplerStates' array above
	Array&lt; ShaderResource &gt;	shaderResources;   //&lt;= 

	Array&lt; ShaderTechnique &gt;	techniques;

              // all created shader programs (VS/GS/PS) for fixing-up HShaderProgram handles in technique passes (when serialized, they store indices into this array in place of handles)
	Array&lt; HShaderProgram &gt;	programs[ ShaderType::Count ];

	// this is used for locating shader cache on disk
	String		name;
};

// technique: name and array of passes

// pass - array of shader instances (combinations, identified by a bitmask), default shader instance id,
// and parameter bindings info (cbuffers,samplers,textures) in the form {array, start, count}

</pre>
<p>&nbsp;</p>
<p>Global shader resources are shared between different shader programs, e.g. updating a global constant buffer would look so:</p>
<p>&nbsp;</p>
<p>SetStateBlock(Default); // Default is LessEqZNoStencil, NoBlending, CullBack.</p>
<p>CBuffer& perFrame = pipeline.GetCBufferByName("cbPerFrame");</p>
<p>cbPerFrame* data = cast(cbPerFrame*) perFrame.ToPtr();</p>
<p>...</p>
<p>perFrame.Commit();</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></description>
		<pubDate>Wed, 22 May 2013 21:35:15 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643430-shader-library-design-and-implementation/</guid>
	</item>
	<item>
		<title>Stange animation artifact</title>
		<link>http://www.gamedev.net/topic/643429-stange-animation-artifact/</link>
		<description><![CDATA[<p>All I wasn't sure which forum to place this in as it's quite an odd question. My 2d platformer has an odd problem but I'm not sure it's a real problem as such. I'll try to explain as best I can. When my character jumps into the side of a platform, and then on top of it, it looks, momentarily like there is a 'glitch' in the animation. Thing is, if I put a thread.sleep in to slow the game down, I can't see any such glitch. If I video it and plat it back, again I can't seem to see anything. Has anyone come across something like this before? Could it be an issue bought about by my frame rate? Sorry it's so vague but I'm not sure how else to explain it. It's not a deal-breaker but it is extrememly annoying. Any thoughts would be welcome. Thanks.</p>
]]></description>
		<pubDate>Wed, 22 May 2013 21:16:03 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643429-stange-animation-artifact/</guid>
	</item>
	<item>
		<title>Quickest way to iterate through a rectangles lines?</title>
		<link>http://www.gamedev.net/topic/643428-quickest-way-to-iterate-through-a-rectangles-lines/</link>
		<description><![CDATA[<p>I have a rectangle, with an x and y coordinate which represent the top-left corner of the rectangle. I also have the width and the height.</p>
<p>&nbsp;</p>
<p>I need a piece of code that can iterate through all the four lines of the rectangle fast.</p>
<p>&nbsp;</p>
<p>My crap code works but have 4 for-loops o_0</p>
]]></description>
		<pubDate>Wed, 22 May 2013 20:48:47 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643428-quickest-way-to-iterate-through-a-rectangles-lines/</guid>
	</item>
	<item>
		<title>Drawing many textured quads at once</title>
		<link>http://www.gamedev.net/topic/643427-drawing-many-textured-quads-at-once/</link>
		<description><![CDATA[<p>In my DirectX 11 application, I would like to draw a scene consisting of many textured quads. For the sake of efficiency, my first thought was to use instancing to pull this off in a single draw call - four common vertices and an instance buffer containing transformation matrices to handle positioning of each instance, and an index for which texture to sample from. I had hoped I could do this using a single Texture2DArray resource for storing my collection of textures, but the textures all vary in size (though would share the same format). This does not appear to be possible with a Texture2DArray.</p>
<p>&nbsp;</p>
<p>I would really like to avoid a separate draw call for each of these quads. From what I understand there is overhead involved in draw calls that can create a CPU bottleneck, especially considering I would only be drawing two triangles per call.</p>
<p>&nbsp;</p>
<p>Anyone have suggestions on the most efficient way to do this?</p>
]]></description>
		<pubDate>Wed, 22 May 2013 20:19:50 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643427-drawing-many-textured-quads-at-once/</guid>
	</item>
	<item>
		<title><![CDATA[Ray Tracing Blog &#38; Forum]]></title>
		<link>http://www.gamedev.net/topic/643426-ray-tracing-blog-forum/</link>
		<description><![CDATA[<p>Hi all,</p>
<p>&nbsp;</p>
<p>I am not sure how many of you know about this forum:</p>
<p><a href='http://ompf2.com' class='bbc_url' title='External link' rel='nofollow external'>http://ompf2.com</a></p>
<p>It started as a replacement for the great ompf forum, which focuses on ray tracing, both from an academic point of view and more hobyist oriented. Obviously you are welcome to join this forum to stay updated on the latest and greatest advances in ray tracing, both real-time and off-line.</p>
<p>Recently (as in: today <span rel='lightbox'><img class='bbc_img' src="http://public.gamedev5.net//public/style_emoticons/default/smile.png" title=":)" alt="smile.png"></span> ), we added a blog, which will provide daily (hopefully) news from ray tracing land. Url:</p>
<p><a href='http://ompf2.com/blog.php' class='bbc_url' title='External link' rel='nofollow external'>http://ompf2.com/blog.php</a></p>
<p>&nbsp;</p>
<p>Hope to see you there,</p>
<p>- Jacco.</p>
<p>&nbsp;</p>
<p>EDIT: fixed url to blog.</p>
]]></description>
		<pubDate>Wed, 22 May 2013 19:39:26 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643426-ray-tracing-blog-forum/</guid>
	</item>
	<item>
		<title>Mip Mapping in the Domain Shader</title>
		<link>http://www.gamedev.net/topic/643425-mip-mapping-in-the-domain-shader/</link>
		<description><![CDATA[<p>Ok, I want to do some displacement mapping in my domain shader, and some corresponding normal mapping in my pixel shader. I've never done displacement mapping before, but I would guess that it is very important to use the same mip mapping technique for both shader stages. In the pixel shader, mip-mapping happens&nbsp;sort of&nbsp;automatically so I don't really know exactly what's happening enough to emulate it in the domain shader.</p>
<p>&nbsp;</p>
<p>I figure that for something this basic, there's probably a well established way to use the same mips for sampling in the domain and pixel shaders. Can anyone point me to an article somewhere with some code examples? I'm finding articles that say you should use mip-mapping in the domain shader, but nothing as to how to do that exactly.</p>
]]></description>
		<pubDate>Wed, 22 May 2013 19:25:24 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643425-mip-mapping-in-the-domain-shader/</guid>
	</item>
	<item>
		<title>Aliasing confusion</title>
		<link>http://www.gamedev.net/topic/643424-aliasing-confusion/</link>
		<description><![CDATA[<p>Hello,</p>
<p>&nbsp;</p>
<p>I am a bit confused on the aliasing problem in computer graphics(OpenGL), specifically:</p>
<p>&nbsp;</p>
<p>1. In the picture below, the checkerboard texture is laid on a rectangle consisting of 2 triangles. Please note at the bottom of the image the jagged &nbsp;edges of black and white blocks of the texture:</p>
<p>&nbsp;</p>
<p><a href='http://www.arcsynthesis.org/gltut/Texturing/BasicCheckerboardPlane.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.arcsynthesis.org/gltut/Texturing/BasicCheckerboardPlane.png</a></p>
<p>&nbsp;</p>
<p>Is that problem called aliasing?</p>
<p>&nbsp;</p>
<p>2. In the picture below, the same jagged effect can be seen on the edges of the right-most two triangles:</p>
<p>&nbsp;</p>
<p><a href='http://slizerboy.files.wordpress.com/2009/11/anti-alias.png?w=343&h=150' class='bbc_url' title='External link' rel='nofollow external'>http://slizerboy.files.wordpress.com/2009/11/anti-alias.png?w=343&h=150</a></p>
<p>&nbsp;</p>
<p>Is that the same aliasing problem?</p>
<p>&nbsp;</p>
<p>I'm asking this because in first case, texture sampling is involved but in the second case there is no texture.&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>3. If in the first example the issue is called aliasing, can we say that using linear filtering as magnification/minification filters in sampling the texture represent an anti-aliasing technique? I have searched the web for OpenGL anti-aliasing and I mostly read about "multisampling", so I'm wondering if linear and mipmap filtering can be considered anti-aliasing techniques?</p>]]></description>
		<pubDate>Wed, 22 May 2013 18:51:57 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643424-aliasing-confusion/</guid>
	</item>
	<item>
		<title><![CDATA[What's next in Game programming]]></title>
		<link>http://www.gamedev.net/topic/643421-whats-next-in-game-programming/</link>
		<description><![CDATA[<p>Hello,</p>
<p>I want to be a game programmer. I want to work in game company as Ubisoft, Naughty Dog..</p>
<p>It's my dream and I do for it everything.</p>
<p>It's about one year, when I start programming. I understood concept OOP, and C++ too. I've created 8 2D Games as Super Mario, Snake, Pong ...</p>
<p>&nbsp;</p>
<p>But now, I don't know what I do next. I can go on 3D programming? If yes, which library a should use? Or I can go on Engines? Or I can stayed in 2D Game?</p>
]]></description>
		<pubDate>Wed, 22 May 2013 17:05:04 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643421-whats-next-in-game-programming/</guid>
	</item>
	<item>
		<title>Unity offers basic service for Android and iOS for free.</title>
		<link>http://www.gamedev.net/topic/643420-unity-offers-basic-service-for-android-and-ios-for-free/</link>
		<description><![CDATA[<p>The full story is at their web site:</p>
<p>&nbsp;</p>
<p><a href='http://blogs.unity3d.com/2013/05/21/putting-the-power-of-unity-in-the-hands-of-every-mobile-developer/' class='bbc_url' title='External link' rel='nofollow external'>http://blogs.unity3d.com/2013/05/21/putting-the-power-of-unity-in-the-hands-of-every-mobile-developer/</a></p>
<p>&nbsp;</p>
<p>In the past they have had offers of the Android and iOS licenses for free, looks like they are making it a permanent thing.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></description>
		<pubDate>Wed, 22 May 2013 16:45:51 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643420-unity-offers-basic-service-for-android-and-ios-for-free/</guid>
	</item>
	<item>
		<title>Light Shader</title>
		<link>http://www.gamedev.net/topic/643419-light-shader/</link>
		<description><![CDATA[<p>I'm looking for a shader example that I can use to setup any type of light in any position in the scene.</p>
]]></description>
		<pubDate>Wed, 22 May 2013 16:07:40 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643419-light-shader/</guid>
	</item>
	<item>
		<title>Camera rotation is a little off</title>
		<link>http://www.gamedev.net/topic/643417-camera-rotation-is-a-little-off/</link>
		<description><![CDATA[<p>Hey, I'm trying to get my camera to work right. But I'm having trouble and I can't figure out why.</p>
<p>&nbsp;</p>
<p>I've even looked up tutorials and basically copy-pasted the code from the tutorials and it still wont work.</p>
<p>&nbsp;</p>
<p>But, I'm trying to do it the way I learned in school.</p>
<p>&nbsp;</p>
<p></p><pre class="prettyprint linenums:0">
&nbsp;
Matrix camRot = Matrix.CreateRotationY(mouseX * dt) * Matrix.CreateRotationX(mouseY * dt);
&nbsp;
// Rotate like this?
cam *= camRot;
&nbsp;
// Fix up the broken axis's
cam.Right = Vector3.Cross(cam.Forward, Vector3.Up);
cam.Right.Normalize();
&nbsp;
cam.Up = Vector3.Cross(cam.Backward, cam.Right);
cam.Up.Normalize();
&nbsp;
//cam.Forward = Vector3.Cross(Vector3.Up, cam.Right);
//cam.Forward.Normalize();
</pre>
<p>&nbsp;</p>
<p>This code works perfectly fine for rotating left and right, but when I rotate up and down, everything is skewed and awkward looking.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></description>
		<pubDate>Wed, 22 May 2013 15:12:25 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643417-camera-rotation-is-a-little-off/</guid>
	</item>
	<item>
		<title>File Loading Module</title>
		<link>http://www.gamedev.net/topic/643416-file-loading-module/</link>
		<description><![CDATA[<p>Hey guys,</p>
<p>&nbsp;</p>
<p>I've been thinking over a problem today and I wanted to have some input from you lot! <img src='http://public.gamedev5.net//public/style_emoticons/default/biggrin.png' class='bbc_emoticon' alt=':D' /></p>
<p>I have a DX11 engine I'm building up and I need a system where I can load in different model types, .obj, .md5 that sorta thing. But I can't seem to come up with a way to decouple the file loading from the data itself.&nbsp;</p>
<p>&nbsp;</p>
<p>I thought I'd start here because you have much more experience than me <img src='http://public.gamedev5.net//public/style_emoticons/default/tongue.png' class='bbc_emoticon' alt=':P' />&nbsp;</p>
<p>&nbsp;</p>
<p><span rel='lightbox'><img class='bbc_img' src="http://i.imgur.com/3oaP1BJ.png" alt="3oaP1BJ.png"></span></p>
<p>&nbsp;</p>
<p>This is the general Idea I have in my head. Using FileLoadingManager as a singleton and IFileImporter as an interface.</p>
<p>&nbsp;</p>
<p>How would you do it? Design limitations?</p>
<p>&nbsp;</p>
<p>This is a learning exercise for me so throw books, examples and whatever else you want at me too <img src='http://public.gamedev5.net//public/style_emoticons/default/biggrin.png' class='bbc_emoticon' alt=':D' /></p>
<p>&nbsp;</p>
<p>Many Thanks.</p>
]]></description>
		<pubDate>Wed, 22 May 2013 14:32:18 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643416-file-loading-module/</guid>
	</item>
	<item>
		<title>Drawing multiple lines with one draw call</title>
		<link>http://www.gamedev.net/topic/643414-drawing-multiple-lines-with-one-draw-call/</link>
		<description><![CDATA[<p>I'm trying to fill the indices to draw multiple lines with a single draw call:</p>
<pre class="prettyprint">
DWORD linesCount = 4; // Draw 4 lines with one draw call
TVertex* vrts = new TVertex[linesCount]();

for(DWORD i = 0; i &lt; linesCount; i++)
{&nbsp; &nbsp; &nbsp;
     vrts[i+0].pos = v0; vrts[0].otherPos = v1;
&nbsp; &nbsp; &nbsp;vrts[i+1].pos = v1; vrts[1].otherPos = v0;
&nbsp; &nbsp; &nbsp;vrts[i+2].pos = v0; vrts[2].otherPos = v1;
&nbsp; &nbsp; &nbsp;vrts[i+3].pos = v1; vrts[3].otherPos = v0;

&nbsp; &nbsp; &nbsp;g_fThickness = 0.5f;
&nbsp; &nbsp; &nbsp;vrts[i+0].thickness = D3DXVECTOR3( -g_fThickness, 0.f, g_fThickness * 0.5f );
&nbsp; &nbsp; &nbsp;vrts[i+1].thickness = D3DXVECTOR3( &nbsp;g_fThickness, 0.f, g_fThickness * 0.5f );
&nbsp; &nbsp; &nbsp;vrts[i+2].thickness = D3DXVECTOR3( &nbsp;g_fThickness, 0.f, g_fThickness * 0.5f );
&nbsp; &nbsp; &nbsp;vrts[i+3].thickness = D3DXVECTOR3( -g_fThickness, 0.f, g_fThickness * 0.5f );

&nbsp; &nbsp; &nbsp;vrts[i+0].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.f, 0.f );
&nbsp; &nbsp; &nbsp;vrts[i+1].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.25f, 0.f );
&nbsp; &nbsp; &nbsp;vrts[i+2].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.f, 0.25f );
&nbsp; &nbsp; &nbsp;vrts[i+3].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.25f, 0.25f );
}

device-&gt;DrawIndexedPrimitiveUP( D3DPT_TRIANGLELIST, 0, linesCount*4, linesCount*2, indexBuffer, D3DFMT_INDEX32, vrts, sizeof( TVertex ) );
</pre>
<p>&nbsp;</p>
<p>Now, I'm not sure how to fill&nbsp;<strong>indexBuffer,</strong> what values I should give to the index buffer?</p>
]]></description>
		<pubDate>Wed, 22 May 2013 13:38:00 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643414-drawing-multiple-lines-with-one-draw-call/</guid>
	</item>
	<item>
		<title>reset fail in d3d retail mode but success in debug mode</title>
		<link>http://www.gamedev.net/topic/643413-reset-fail-in-d3d-retail-mode-but-success-in-debug-mode/</link>
		<description><![CDATA[<p>hi there. I have a problem when I want to resize the windows size .I adjust the windows size and then use reset function to reset the device . It success in d3d debug mode but fail in d3d retail mode.... and the reset function return&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div>HRESULT: 0xfaacfaca (4205640394)</div>
<div>Name: Unknown</div>
<div>Description: n/a</div>
<div>Severity code: Failed</div>
<div>Facility Code: Unknown (6828)</div>
<div>Error Code: 0xfaca (64202)</div>
<div>&nbsp;</div>
<div>I don't know why it's fail and I don't know any way to find the reason because there are nothing to ouput the retail mode.... Do you have any ideas.thank you .&nbsp;</div>
<p>&nbsp;</p>
]]></description>
		<pubDate>Wed, 22 May 2013 13:34:07 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643413-reset-fail-in-d3d-retail-mode-but-success-in-debug-mode/</guid>
	</item>
	<item>
		<title>Bumpy grass on terrain</title>
		<link>http://www.gamedev.net/topic/643412-bumpy-grass-on-terrain/</link>
		<description><![CDATA[<p>Hello.</p>
<p>I am trying to make my flat terrain a little bumpy and I saw Outerra's old implementation.</p>
<p><span rel='lightbox'><img class='bbc_img' src="http://3.bp.blogspot.com/-J7pghQul-0g/Tcg1_Jau3HI/AAAAAAAAAGs/z4xl42P48KY/s1600/grass1n.jpg" alt="grass1n.jpg"></span></p>
<p>&nbsp;</p>
<p>It looks pretty well but I couldn't figure it out. It seem POM is used but I tried lots of combinations with POM and normal mapping and I couldn't achieve that sight.</p>
<p>&nbsp;</p>
<p>Do you have any idea about how to achieve such a perfect bumps on grass.</p>
]]></description>
		<pubDate>Wed, 22 May 2013 13:31:50 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643412-bumpy-grass-on-terrain/</guid>
	</item>
	<item>
		<title>Lens Flare in motion (camera question)</title>
		<link>http://www.gamedev.net/topic/643410-lens-flare-in-motion-camera-question/</link>
		<description><![CDATA[<p>I'm trying to understand what happens to a lens flare effect during fast motion. Unfortunately I don't have an opportunity to test this myself so I thought someone in here probably knows this. Will the lens flare get affected by the motion blur ? I'm leaning towards yes...since motion blur happens to every "light" that camera sensor receives, right ? So even the light that's not coming in directly and bouncing around the lens should.</p>
]]></description>
		<pubDate>Wed, 22 May 2013 12:15:16 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643410-lens-flare-in-motion-camera-question/</guid>
	</item>
	<item>
		<title>Online multiplayer Game programming</title>
		<link>http://www.gamedev.net/topic/643409-online-multiplayer-game-programming/</link>
		<description><![CDATA[<p>Hi people ! I have a game making project in my college, and I wanted a little help about how to go on about it. So let me first describe the project.</p>
<p>I have made a box filling game using python and pygame, so i know how to make UI, and the game programming. Apart from it, I know C language. I don't know JAVA and other stuff as yet, but if needed i can try that.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Phase 1: Make a GUI game, LUDO in which, 2 or 4 people can play against each other, through net login. If possible, do something so that these players can play this game through their browser, like online games are done. I saw one of my classmates implemented a version where the game would ask the ip of the computer to play against, and then these two people can play together online, but this idiot won't tell me how she did it.</p>
<p>&nbsp;</p>
<p>Phase 2: Add another mode to the game, to play against computer. If chosen to play against the computer, the game should behave as an artificially intelligent player to play against a human.</p>
<p>&nbsp;</p>
<p>I need help regarding this. First of all, as yet, i have decided to use python and pygame for it. But i really don't have any idea whether it's a good choice or not, how i'm going to implement these things, etc. Please suggest an approach to complete the game. Eg:- You should use this "blah blah" language, because it has "blah blah" feature, which will help you. Then you can implement it online using "blah blah" thing. also this language will make it easier for AI programming... etc. I hope you get the idea what i want to really ask. Please help.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></description>
		<pubDate>Wed, 22 May 2013 11:10:18 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643409-online-multiplayer-game-programming/</guid>
	</item>
	<item>
		<title>Prebuild of static library not executed.</title>
		<link>http://www.gamedev.net/topic/643405-prebuild-of-static-library-not-executed/</link>
		<description><![CDATA[<p>I've implemented a simple static test library foo and perform a successfully build of this library. Now I try to include this library as static prebuild to my simple shared bar library, based on android documentation. But this fails. My shared library is build successfully but my prebuild is not executed (finally not copied).</p>
<p>&nbsp;</p>
<p>Here ist my bar Android.mk file</p>
<pre class="prettyprint">
LOCAL_PATH := D:/binrev/repository/bar
include $(CLEAR_VARS)

LOCAL_MODULE    := foo-prebuilt
LOCAL_SRC_FILES := external-deps/foo/lib/android/$(TARGET_ARCH_ABI)/libfoo.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)           
LOCAL_MODULE    := bar
LOCAL_C_INCLUDES:= D:/binrev/repository/bar/include
LOCAL_C_INCLUDES+= D:/binrev/repository/bar/external-deps/foo/include
LOCAL_SRC_FILES := src/bar.cpp

LOCAL_LDLIBS := -llog
LOCAL_LDLIBS += -landroid 
 
LOCAL_SHARED_LIBRARIES := foo-prebuilt
include $(BUILD_SHARED_LIBRARY)
</pre>
<p>&nbsp;</p>
<p>And here is my Application.mk file:</p>
<p>&nbsp;</p>
<pre class="prettyprint">
APP_PROJECT_PATH := D:/binrev/repository/bar
APP_BUILD_SCRIPT := $(APP_PROJECT_PATH)/Android.mk 

APP_CPPFLAGS := -std=gnu++0x  
APP_CPPFLAGS += -frtti
APP_CPPFLAGS += -fexceptions
APP_CPPFLAGS += -DDEBUG  

APP_STL := gnustl_static
APP_GNUSTL_CPP_FEATURES := rtti exceptions
APP_OPTIM := debug

APP_ABI := armeabi-v7a
APP_PLATFORM:=android-10          
APP_MODULES := bar
</pre>
<p>&nbsp;</p>
<p>I use MinGW64 in hanshake with NDK 8re. I could exclude MinGW64 as possible source of defects, while this failure also occurs, if I perform the build using Windows command line. While the upload is blocked by our proxy you could download the test project here:</p>
<p>&nbsp;</p>
<p><a href='http://sourceforge.net/projects/binrevengine/files/publications//bar.7z' class='bbc_url' title='External link' rel='nofollow external'>http://sourceforge.net/projects/binrevengine/files/publications//bar.7z</a></p>
<p>&nbsp;</p>
<p>I checked my sources and scripts multiple times, but can't find any failure.</p>
<p>I completly get lost and running out of ideas ...<br>
Thanks for any help.</p>
]]></description>
		<pubDate>Wed, 22 May 2013 10:11:40 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643405-prebuild-of-static-library-not-executed/</guid>
	</item>
	<item>
		<title>else if question</title>
		<link>http://www.gamedev.net/topic/643404-else-if-question/</link>
		<description><![CDATA[<p>First of all, I am reading a book on C++ - there was this one example in it:</p>
<pre class="prettyprint lang-">
#include &lt;iostream&gt;
using namespace std;

class Date
{
private:
	int day, month, year;
public:
	Date(int inputDay, int inputMonth, int inputYear)
		: day(inputDay), month(inputMonth), year(inputYear){}


	bool operator== (const Date& input)
	{
		if( (day == input.day) && (month == input.month) && (year == input.year) )
			return true;
		else
			return false;
	}

	bool operator&lt; (const Date& input)
	{
		if(year &lt; input.year)
			return true;
		else if(month &lt; input.month)
			return true;
		else if(day &lt; input.day)
			return true;
		else 
			return false;
	}

	bool operator&lt;= (const Date& input)
	{
		if(this-&gt;operator== (input))
			return true;
		else 
			return this-&gt;operator&lt; (input);
	}

};

int main()
{
	Date d1(19 , 4, 2013);
	Date d2(19, 5, 2012);
	cout &lt;&lt; (d1&lt;d2) &lt;&lt; endl;

	cin.ignore();
	return 0;
}
</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Btw it's me that changed the main a little - just to show what a ridiculous output I get.</p>
<p>Is it me or is the inequality operator coded wrong?</p>
<pre class="prettyprint lang-">
	bool operator&lt; (const Date& input)
	{
		if(year &lt; input.year)
			return true;
		else if(month &lt; input.month)
			return true;
		else if(day &lt; input.day)
			return true;
		else 
			return false;
	}
</pre>
<p>&nbsp;</p>
<p>If it were me I'd code it like this:</p>
<pre class="prettyprint lang-">
	bool operator&lt; (const Date& input)
	{
		if(year &lt; input.year)
			return true;
		else if(year &gt; input.year)
			return false;
		else //when year == input.year
		{
			if(month &lt; input.month)
				return true;
			else if(month &gt; input.month)
				return false;
			else //when month == input.month
			{
				if(day &lt; input.day)
					return true;
				else 
					return false;
			}
		}
	}
</pre>
<p>&nbsp;</p>
<p>Is it the book's example that is wrong or is it me missing something crucial?</p>
]]></description>
		<pubDate>Wed, 22 May 2013 10:04:41 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643404-else-if-question/</guid>
	</item>
	<item>
		<title>MD5 Skinned Mesh</title>
		<link>http://www.gamedev.net/topic/643402-md5-skinned-mesh/</link>
		<description><![CDATA[<p>I'm following this tutorial:&nbsp;<a href='http://3dgep.com/?p=1053' class='bbc_url' title='External link' rel='nofollow external'>http://3dgep.com/?p=1053</a></p>
<p>So far everything works, things render as expected. But i'm having a hard time understanding the PrepareMesh method:</p>
<pre class="prettyprint lang-">
void MD5Model::PrepareMesh(MD5Mesh& mesh) {
    mesh.m_vPositionBuffer.clear();
    mesh.m_vTexCoordBuffer.clear();
    
    for (unsigned int i = 0; i &lt; mesh.m_vVerts.size(); ++i) {
        MD5Vertex& vert = mesh.m_vVerts&#91;i&#93;;
        
        vert.position = Vector();
        vert.normal = Vector();
        vert.position.w = 1.0f;
        vert.normal.w = 0.0f;
        
        for (int j = 0; j &lt; vert.weightCount; ++j) {
            MD5Weight& weight = mesh.m_vWeights&#91;vert.startWeight + j&#93;;
            MD5Joint& joint = m_vJoints&#91;weight.jointId&#93;;
            
            Vector rotPos = joint.orientation.Inverse() * weight.position;
            vert.position += (joint.position + rotPos) * weight.bias;
        }
        
        mesh.m_vPositionBuffer.push_back(vert.position);
        mesh.m_vTexCoordBuffer.push_back(vert.uv);
    }
}
</pre>
<p>&nbsp;</p>
<p>The vertex has no position before this method. From what i gather, weight.position is the position of the vertex in bone space local to the bone we're looking at. This leads me to my question, do we have one unique weight for every vertex per bone it attaches to? Or can vertices share weights?</p>
<p>&nbsp;</p>
<p>Also, is this standard? Is there perhaps another file format that does vertex with a different approach? This seems so wasteful for some reason, but if it can't be worked around, oh well.</p>
]]></description>
		<pubDate>Wed, 22 May 2013 09:29:41 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643402-md5-skinned-mesh/</guid>
	</item>
	<item>
		<title>SDL_Surface to OpenGL texture problem.</title>
		<link>http://www.gamedev.net/topic/643400-sdl-surface-to-opengl-texture-problem/</link>
		<description><![CDATA[<p>Hello. I have a bit of a problem, so a little help from someone more experienced would be appreciated. :-)</p>
<p>&nbsp;</p>
<p>I've been using SDL for a few months, and have gotten quite good at it and started making my first game. But now I want my game to use hardware accelerated rendering because software rendering won't cut it any more, so I started looking into OpenGL.</p>
<p>&nbsp;</p>
<p>Since I have some experience in SDL and kind of know what I'm doing with it, but know nothing about OpenGL, I tried to find the simplest way possible to convert my SDL surfaces to OpenGL textures and render them with OpenGL.</p>
<p>&nbsp;</p>
<p>So I found <a href='http://www.sdltutorials.com/sdl-tip-sdl-surface-to-opengl-texture' class='bbc_url' title='External link' rel='nofollow external'>THIS</a> and <a href='http://www.sdltutorials.com/sdl-opengl-tutorial-basics' class='bbc_url' title='External link' rel='nofollow external'>THIS</a> from <a href='http://www.sdltutorials.com' class='bbc_url' title='External link' rel='nofollow external'>sdltutorials.com</a></p>
<p>&nbsp;</p>
<p>Following these instructions, I altered my Initialization and rendering functions from this:</p>
<p>&nbsp;</p>
<pre class="prettyprint">
bool init()
{
    if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 ) return false;

    screen = SDL_SetVideoMode( SCREEN_WIDTH , SCREEN_HEIGHT , BITS_PER_PIXEL , SDL_HWSURFACE | SDL_DOUBLEBUF );
    if( screen == NULL ) return false;
    if( Mix_OpenAudio( 44100 , MIX_DEFAULT_FORMAT , 2 , 512 ) &lt; 0 ) return false;
    SDL_WM_SetCaption( "Test!" , NULL );
    return true;
}

SDL_Surface * load( std::string file )
{
    SDL_Surface * loaded = NULL;
    SDL_Surface * optimized = NULL;
    loaded = IMG_Load( file.c_str() );
    if( loaded != NULL )
    {
        optimized = SDL_DisplayFormatAlpha( loaded );
        SDL_FreeSurface( loaded );
    }
    return optimized;
}

void apply_surface( int x , int y , SDL_Surface * get = NULL , SDL_Surface * give = NULL , SDL_Rect * clips = NULL )
{
    SDL_Rect offsets;

    offsets.x = x;
    offsets.y = y;

    SDL_BlitSurface( get , clips , give , &offsets );
}

void apply_surface( int x , int y , SDL_Surface * get , SDL_Surface * give , int clips_x , int clips_y , int w , int h )
{
    SDL_Rect offsets;

    offsets.x = x;
    offsets.y = y;

    SDL_Rect clips;

    clips.x = clips_x;
    clips.y = clips_y;
    clips.w = w;
    clips.h = h;

    SDL_BlitSurface( get , &clips , give , &offsets );
}
</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>...To this:</p>
<p>&nbsp;</p>
<pre class="prettyprint">
bool init()
{
    if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 ) return false;

    SDL_GL_SetAttribute(SDL_GL_RED_SIZE,8);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,8);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,8);
    SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,8);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,16);
    SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE,32);
    SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE,8);
    SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE,8);
    SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE,8);
    SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE,8);
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS,1);
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES,2);

    screen = SDL_SetVideoMode( SCREEN_WIDTH , SCREEN_HEIGHT , BITS_PER_PIXEL , SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL );

    glClearColor(0, 0, 0, 0);
    glClearDepth(1.0f);
    glViewport(0, 0, SCREEN_WIDTH , SCREEN_HEIGHT);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, SCREEN_WIDTH , SCREEN_HEIGHT, 0, 1, -1);
    glMatrixMode(GL_MODELVIEW);
    glEnable(GL_TEXTURE_2D);
    glLoadIdentity();

    if( screen == NULL ) return false;
    if( Mix_OpenAudio( 44100 , MIX_DEFAULT_FORMAT , 2 , 512 ) &lt; 0 ) return false;
    SDL_WM_SetCaption( "OpenGL Test!" , NULL );
    return true;
}

SDL_Surface * load( std::string file )
{
    SDL_Surface * loaded = NULL;
    loaded = IMG_Load( file.c_str() );

    return loaded;
}

void apply_surface( int x , int y , SDL_Surface * get = NULL )
{
    GLuint textureID = 0;

    glGenTextures(1, &textureID);

    glBindTexture(GL_TEXTURE_2D, textureID);

    int Mode = GL_RGBA;

    glTexImage2D(GL_TEXTURE_2D, 0, Mode, get-&gt;w, get-&gt;h, 0, Mode, GL_UNSIGNED_BYTE, get-&gt;pixels);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();

    glBindTexture(GL_TEXTURE_2D, textureID);

    glBegin(GL_QUADS);

        glTexCoord2f(0, 0);
        glVertex2f(x, y);

        glTexCoord2f(1, 0);
        glVertex2f(x+get-&gt;w, y);

        glTexCoord2f(1, 1);
        glVertex2f(x+get-&gt;w, y+get-&gt;h);

        glTexCoord2f(0, 1);
        glVertex2f(x, y+get-&gt;h);
    glEnd();
    glDeleteTextures(1, &textureID);
    glDisable(GL_TEXTURE_2D);

    SDL_GL_SwapBuffers();
}

void apply_surface( int x , int y , SDL_Surface * get , int clips_x , int clips_y , int w , int h )
{
    GLuint textureID = 0;
    glGenTextures(1, &textureID);
    glBindTexture(GL_TEXTURE_2D, textureID);

    int Mode = GL_RGBA;

    glTexImage2D(GL_TEXTURE_2D, 0, Mode, get-&gt;w, get-&gt;h, 0, Mode, GL_UNSIGNED_BYTE, get-&gt;pixels);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();

    glBindTexture(GL_TEXTURE_2D, textureID);

    int cx = clips_x / get-&gt;w;
    int cy = clips_y / get-&gt;h;
    int cw = clips_x+w / get-&gt;w;
    int ch = clips_y+h / get-&gt;h;

    glBegin(GL_QUADS);

        glTexCoord2f(cx, cy);
        glVertex2f(x, y);

        glTexCoord2f(cx+cw, cy);
        glVertex2f(x+get-&gt;w, y);

        glTexCoord2f(cx+cw, cy+ch);
        glVertex2f(x+get-&gt;w, y+get-&gt;h);

        glTexCoord2f(cx, cy+ch);
        glVertex2f(x, y+get-&gt;h);
    glEnd();
    glDeleteTextures(1, &textureID);
    glDisable(GL_TEXTURE_2D);

    SDL_GL_SwapBuffers();
}
</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>...But all I see when I run it is a black screen with a few glitchy rectangles flying by diagonally, and the program runs at 4 frames per second.</p>
<p>&nbsp;</p>
<p>I will not lie, I have absolutely no idea what I'm actually doing, I just want an easy and fast way to have hardware acceleration without having to change too much of my code. I do want to learn how to properly use OpenGL eventually, but not before I at least finish my first game.</p>
<p>&nbsp;</p>
<p>If someone can offer some advice on what I'm doing wrong, I would really appreciate it. :-)</p>
<p>&nbsp;</p>
<p>Thank you in advance. :-)</p>
]]></description>
		<pubDate>Wed, 22 May 2013 08:56:53 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643400-sdl-surface-to-opengl-texture-problem/</guid>
	</item>
	<item>
		<title>Moving with delta time.</title>
		<link>http://www.gamedev.net/topic/643399-moving-with-delta-time/</link>
		<description><![CDATA[<p>So im making a pong clone and i have a silly problem.</p>
<p>&nbsp;</p>
<p>I have a Paddle class with HandleInput(), Update(), and Draw() functions. The HandleIput and Update functions look like this at the moment.</p>
<p>&nbsp;</p>
<pre class="prettyprint">
void Paddle::HandleInput( Keyboard& keyboard )
{
    if( keyboard.KeyIsHeld( m_upKey ) )
	m_position.y -= m_moveSpeed;

    if( keyboard.KeyIsHeld( m_downKey ) )
	m_position.y += m_moveSpeed;
}

void Paddle::Update( float deltaTime )
{

}
</pre>
<p>&nbsp;</p>
<p>The problem is that i want the position to be changed over time but at the moment the "Update" function is the one who is passed the delta time. It's a stupid problem but i can't figure out a nice way around it.</p>
<p>&nbsp;</p>
<p>I want to avoid passing the delta time to the "HandleInput" function because it wouldn't really make sense, and also these function are actually an interface to a game object so it would mean passing it to every "HandleInput" function, whether it needed it or not. I could add a couple booleans to track whether either of the keys were pressed during "HandleInput" but that is essentially testing the same thing twice. I'm leaning towards the idea of adding a "delta position" variable to track the change in position, so the code would look something like this.</p>
<p>&nbsp;</p>
<pre class="prettyprint">
void Paddle::HandleInput( Keyboard& keyboard )
{
    if( keyboard.KeyIsHeld( m_upKey ) )
	m_deltaY -= m_moveSpeed;

    if( keyboard.KeyIsHeld( m_downKey ) )
	m_deltaY += m_moveSpeed;
}

void Paddle::Update( float deltaTime )
{
    m_position.y += (m_deltaY * deltaTime);
    m_deltaY = 0;
}
</pre>
<p>&nbsp;</p>
<p>What do you guys think is the best solution?</p>
]]></description>
		<pubDate>Wed, 22 May 2013 06:32:41 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643399-moving-with-delta-time/</guid>
	</item>
	<item>
		<title>why unreal and cryengine overload global operator new / delete</title>
		<link>http://www.gamedev.net/topic/643397-why-unreal-and-cryengine-overload-global-operator-new-delete/</link>
		<description><![CDATA[<p>most programmers are advised not to overload global operator new/delete, especially when you are writing a library for users. But I find these game engines do it. Any reasons?&nbsp;</p>
<p>&nbsp;</p>
]]></description>
		<pubDate>Wed, 22 May 2013 05:52:59 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643397-why-unreal-and-cryengine-overload-global-operator-new-delete/</guid>
	</item>
	<item>
		<title>Language Advice</title>
		<link>http://www.gamedev.net/topic/643394-language-advice/</link>
		<description><![CDATA[<p>Hello!<br><br>
First and foremost, I'm very very sorry for creating&nbsp;<em>another</em> thread about this same topic. I've been searching the internet for opinions regarding this, but there's quite the diversity in responses it appears. Basically, I'm in a pickle between learning C++ and C# at this point. I'd like to elaborate for those who are interested in helping me.</p>
<p>&nbsp;</p>
<p>I've been programming for many years, on and&nbsp;<strong>off,&nbsp;</strong>originally learning C++ and then migrating to C# when I realized how much easier it was. I absolutely love to program, but when I start to need to learn the "intermediate" or "advanced" topics of a language, I start to get discouraged and stop programming for months. I want to dedicate an hour or two of my time each day for the next year or so to just learn a language from the absolute basics to the more advanced topics. I don't just want to develop games, I want to become a programmer. I know for a fact that I'll have to learn C++ at one point in my life, but when I think about pointers, linked lists, algorithms, etc., I just want to immediately say "nope" and go back to C# where it's nice and cozy and I have someone holding my hand.</p>
<p>&nbsp;</p>
<p>Basically, I'm relatively comfortable with both; with C++ I stopped using it when pointers were involved, and with C#, I stopped when I realized I had no idea what dictionaries do, how to do exception handling, or how to handle events. I want to become a programmer but I always get intimidated when it comes to more complicated topics and discourage myself from programming the next day. Not only that, but I can't ever find any good resources that appeal and grab my attention, and when I search on the forums, it usually has outdated recommendations that don't really work for me.</p>
<p>&nbsp;</p>
<p>Anyways, I hope that covered where I'm at. If you have any recommendations, please feel free to throw them my way.&nbsp;<span style="font-size:14px;">Thanks so much!</span></p>
<p>&nbsp;</p>
<p><span style="font-size:14px;"><strong>TLDR:&nbsp;</strong>Stopped learning C++, went to C#, getting stuck at the "harder" subjects for both languages, and now I'm having trouble deciding if I should continue down C# or start to learn C++ now to make myself a better programmer.&nbsp;</span></p>
]]></description>
		<pubDate>Wed, 22 May 2013 02:55:21 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643394-language-advice/</guid>
	</item>
	<item>
		<title>Mouse and rectangle problems</title>
		<link>http://www.gamedev.net/topic/643393-mouse-and-rectangle-problems/</link>
		<description><![CDATA[<p>So, basically I've been trying to make a draggable&nbsp;menu, with buttons contained inside of it. The problem I've run into is trying to make the menu so that it will not move when the mouse is over any of it's buttons. The classes involved are Resources, Mouse, Object, ClickableObject, ClickableMenu, and Button (ClickableMenu and Button are children of ClickableObject, which is a child of Object). I apologize in advance for the amount of code.</p>
<p>&nbsp;</p>
<p>Resources.cs</p>
<pre class="prettyprint lang- linenums:1">
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace RPG
{
    class Resources
    {
        public Texture2D texBG;

        //Menu textures
        public Texture2D texMenuTL;
        public Texture2D texMenuTR;
        public Texture2D texMenuBL;
        public Texture2D texMenuBR;
        public Texture2D texMenuVert;
        public Texture2D texMenuHor;
        public Texture2D texMenuC;

        public SpriteFont spCustom;

        public Resources(ContentManager Content)
        {
            texBG = Content.Load&lt;Texture2D&gt;("bg");
            
            texMenuTL = Content.Load&lt;Texture2D&gt;("menu_tl");
            texMenuTR = Content.Load&lt;Texture2D&gt;("menu_tr");
            texMenuBL = Content.Load&lt;Texture2D&gt;("menu_bl");
            texMenuBR = Content.Load&lt;Texture2D&gt;("menu_br");
            texMenuVert = Content.Load&lt;Texture2D&gt;("menu_vert");
            texMenuHor = Content.Load&lt;Texture2D&gt;("menu_hor");
            texMenuC = Content.Load&lt;Texture2D&gt;("menu_c");

            spCustom = Content.Load&lt;SpriteFont&gt;("Custom");
        }
    }
}
</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Mouse.cs</p>
<pre class="prettyprint lang- linenums:1">
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace RPG
{
    class Mouse
    {
        MouseState previousState, currentState;
        Texture2D texture;

        public Vector2 Position
        {
            get;
            protected set;
        }

        public Rectangle Rectangle
        {
            get;
            protected set;
        }

        public bool LeftClick
        {
            get
            {
                return currentState.LeftButton == ButtonState.Pressed
                    && previousState.LeftButton == ButtonState.Released;
            }
        }

        public bool LeftPress
        {
            get
            {
                return currentState.LeftButton == ButtonState.Pressed;
            }
        }

        public bool LeftRelease
        {
            get
            {
                return !LeftPress && previousState.LeftButton == ButtonState.Pressed;
            }
        }

        public bool RightClick
        {
            get
            {
                return currentState.RightButton == ButtonState.Pressed
                    && previousState.RightButton == ButtonState.Released;
            }
        }

        public bool RightPress
        {
            get
            {
                return currentState.RightButton == ButtonState.Pressed;
            }
        }

        public bool RightRelease
        {
            get
            {
                return !RightPress && previousState.RightButton == ButtonState.Pressed;
            }
        }

        public bool NormalState
        {
            get
            {
                return !LeftPress && !LeftRelease && !RightPress && !RightRelease;
            }
        }

        public ClickableObject ClickedObject
        {
            get;
            set;
        }

        public Mouse(Texture2D texture)
        {
            this.texture = texture;
        }

        public void Update()
        {
            previousState = currentState;
            currentState = Microsoft.Xna.Framework.Input.Mouse.GetState();

            Position = new Vector2(currentState.X, currentState.Y);
            Rectangle = new Rectangle((int)Position.X, (int)Position.Y, texture.Width, texture.Height);
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            if (texture != null)
            {
                spriteBatch.Begin();
                spriteBatch.Draw(texture, Position, Color.White);
                spriteBatch.End();
            }
        }
    }
}
</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Object.cs</p>
<pre class="prettyprint lang- linenums:1">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace RPG
{
    class Object
    {
        public Texture2D Texture
        {
            get;
            set;
        }

        private Rectangle rec;
        public Rectangle Rectangle
        {
            get
            {
                return rec;
            }
            set
            {
                rec = value;
                Position = new Vector2(Rectangle.X, Rectangle.Y);
            }
        }

        public Vector2 Position
        {
            get;
            set;
        }

        public bool Visible
        {
            get;
            set;
        }

        public Object()
        {
            Visible = true;
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            if (spriteBatch != null)
                if (Texture != null)
                    spriteBatch.Draw(Texture, Position, Color.White);
        }
    }
}
</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>ClickableObject.cs</p>
<pre class="prettyprint lang- linenums:1">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RPG
{
    public enum ObjectClickedState
    {
        Normal,
        Clicked,
        Released
    }

    class ClickableObject : Object
    {
        public ObjectClickedState LeftState
        {
            get;
            protected set;
        }

        public ObjectClickedState RightState
        {
            get;
            protected set;
        }

        public Mouse ActiveMouse
        {
            get;
            protected set;
        }

        public ClickableObject() : base()
        {
            LeftState = RightState = ObjectClickedState.Normal;
        }

        public virtual void OnLeftClick() { }
        public virtual void OnLeftPress() { }
        public virtual void OnLeftRelease() { }
        public virtual void OnLeftNormal() { }
        public virtual void OnRightClick() { }
        public virtual void OnRightPress() { }
        public virtual void OnRightRelease() { }
        public virtual void OnRightNormal() { }

        public virtual void OnHover() { }
        public virtual void OnLeave() { }

        public void Update(Mouse activeMouse)
        {
            bool intersect = activeMouse.Rectangle.Intersects(Rectangle);

            if (intersect || (ActiveMouse != null && (LeftState != ObjectClickedState.Normal || RightState != ObjectClickedState.Normal)))
            {
                ActiveMouse = activeMouse;
                ActiveMouse.ClickedObject = this;
                if (intersect)
                    OnHover();
                if (ActiveMouse.LeftPress && (LeftState == ObjectClickedState.Normal || LeftState == ObjectClickedState.Released))
                {
                    LeftState = ObjectClickedState.Clicked;
                    OnLeftClick();
                }
                else if (ActiveMouse.LeftPress && LeftState == ObjectClickedState.Clicked)
                    OnLeftPress();
                else if (ActiveMouse.LeftRelease && LeftState == ObjectClickedState.Clicked)
                {
                    LeftState = ObjectClickedState.Released;
                    OnLeftRelease();
                }
                else if (!ActiveMouse.LeftPress && LeftState == ObjectClickedState.Released)
                {
                    LeftState = ObjectClickedState.Normal;
                    OnLeftNormal();
                }

                if (ActiveMouse.RightPress && (RightState == ObjectClickedState.Normal || RightState == ObjectClickedState.Released))
                {
                    RightState = ObjectClickedState.Clicked;
                    OnRightClick();
                }
                else if (ActiveMouse.RightPress && RightState == ObjectClickedState.Clicked)
                    OnRightPress();
                else if (ActiveMouse.RightRelease && RightState == ObjectClickedState.Clicked)
                {
                    RightState = ObjectClickedState.Released;
                    OnRightRelease();
                }
                else if (!ActiveMouse.RightPress && RightState == ObjectClickedState.Released)
                {
                    RightState = ObjectClickedState.Normal;
                    OnRightNormal();
                }
            }
            else
            {
                if (ActiveMouse != null)
                {
                    ActiveMouse.ClickedObject = null;
                    ActiveMouse = null;
                    OnLeave();
                }
            }
        }
    }
}
</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>ClickableMenu.cs</p>
<pre class="prettyprint lang- linenums:1">
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace RPG
{

    class ClickableMenu : ClickableObject
    {

        private SpriteFont SpriteText
        {
            get;
            set;
        }
        private Texture2D TextureTopLeft
        {
            get;
            set;
        }
        private Texture2D TextureTopRight
        {
            get;
            set;
        }
        private Texture2D TextureBottomLeft
        {
            get;
            set;
        }
        private Texture2D TextureBottomRight
        {
            get;
            set;
        }
        private Texture2D TextureVertical
        {
            get;
            set;
        }
        private Texture2D TextureHorizontal
        {
            get;
            set;
        }
        private Texture2D TextureCenter
        {
            get;
            set;
        }

        private string Title
        {
            get;
            set;
        }

        public Vector2 DragPoint
        {
            get;
            set;
        }

        List&lt;Button&gt; Buttons = new List&lt;Button&gt;();

        public ClickableMenu(Rectangle rectangle) : base()
        {
            Rectangle = rectangle;            
            Title = "Menu";
            Visible = true;
            DragPoint = new Vector2(-1, -1);
        }

        public ClickableMenu(Rectangle rectangle, string title) : base()
        {
            Rectangle = rectangle;
            Title = title;
            Visible = true;
            DragPoint = new Vector2(-1, -1);
        }

        public void Init(Resources r)
        {
            SpriteText = r.spCustom;
            TextureTopLeft = r.texMenuTL;
            TextureTopRight = r.texMenuTR;
            TextureBottomLeft = r.texMenuBL;
            TextureBottomRight = r.texMenuBR;
            TextureVertical = r.texMenuVert;
            TextureHorizontal = r.texMenuHor;
            TextureCenter = r.texMenuC;
        }

        public void AddButton(Rectangle relativeRectangle, Resources r)
        {
            Button button = new Button(this, relativeRectangle);
            button.Init&#40;r&#41;;
            Buttons.Add(button);
        }

        public override void OnLeftPress()
        {
            if (DragPoint == new Vector2(-1, -1))
                DragPoint = new Vector2(ActiveMouse.Rectangle.X - Rectangle.X, ActiveMouse.Rectangle.Y - Rectangle.Y);
            Rectangle = new Rectangle(ActiveMouse.Rectangle.X - (int)DragPoint.X, ActiveMouse.Rectangle.Y - (int)DragPoint.Y, Rectangle.Width, Rectangle.Height);
            foreach (Button button in Buttons)
                button.Update(this);
        }

        public override void OnLeftRelease()
        {
            DragPoint = new Vector2(-1, -1);
        }

        new public void Draw(SpriteBatch spriteBatch)
        {
            if (spriteBatch != null && TextureTopLeft != null && TextureTopRight != null && TextureBottomLeft != null && TextureBottomRight != null && TextureVertical != null && TextureHorizontal != null && TextureCenter != null && Visible)
            {
                spriteBatch.Draw(TextureTopLeft, new Rectangle(Rectangle.X, Rectangle.Y, 9, 9), Color.White);
                spriteBatch.Draw(TextureVertical, new Rectangle(Rectangle.X + 9, Rectangle.Y, Rectangle.Width - 18, 9), Color.White);
                spriteBatch.Draw(TextureTopRight, new Rectangle(Rectangle.X + (Rectangle.Width - 9), Rectangle.Y, 9, 9), Color.White);
                spriteBatch.Draw(TextureHorizontal, new Rectangle(Rectangle.X, Rectangle.Y + 9, 9, Rectangle.Height - 18), Color.White);
                spriteBatch.Draw(TextureCenter, new Rectangle(Rectangle.X + 9, Rectangle.Y + 9, Rectangle.Width - 18, Rectangle.Height - 18), Color.White);
                spriteBatch.Draw(TextureHorizontal, new Rectangle(Rectangle.X + (Rectangle.Width - 9), Rectangle.Y + 9, 9, Rectangle.Height - 18), Color.White);
                spriteBatch.Draw(TextureBottomLeft, new Rectangle(Rectangle.X, Rectangle.Y + (Rectangle.Height - 9), 9, 9), Color.White);
                spriteBatch.Draw(TextureVertical, new Rectangle(Rectangle.X + 9, Rectangle.Y + (Rectangle.Height - 9), Rectangle.Width - 18, 9), Color.White);
                spriteBatch.Draw(TextureBottomRight, new Rectangle(Rectangle.X + (Rectangle.Width - 9), Rectangle.Y + (Rectangle.Height - 9), 9, 9), Color.White);
                spriteBatch.DrawString(SpriteText, Title, new Vector2(Rectangle.X + 15, Rectangle.Y + 15), Color.White);
                foreach (Button button in Buttons)
                    button.Draw(spriteBatch);
            }
        }
    }
}
</pre>
<p>&nbsp;</p>
<p>Button.cs</p>
<pre class="prettyprint lang- linenums:1">
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace RPG
{
    class Button : ClickableObject
    {
        private SpriteFont SpriteText
        {
            get;
            set;
        }

        private string Title
        {
            get;
            set;
        }

        public Rectangle RelativeRectangle
        {
            get;
            set;
        }

        public Button(Object obj, Rectangle relativeRectangle) : base()
        {
            Rectangle = obj.Rectangle;
            RelativeRectangle = relativeRectangle;
            Visible = true;
            Title = "Button";
        }

        public Button(Object obj, Rectangle relativeRectangle, string title)
            : base()
        {
            Rectangle = obj.Rectangle;
            RelativeRectangle = relativeRectangle;
            Visible = true;
            Title = title;
        }

        public void Init(Resources r)
        {
            SpriteText = r.spCustom;
            Texture = r.texMenuC;
        }

        public void Update(Object obj)
        {
            Rectangle = obj.Rectangle;
        }

        new public void Draw(SpriteBatch spriteBatch)
        {
            if (spriteBatch != null && Texture != null && Visible)
            {
                spriteBatch.Draw(Texture, new Rectangle(Rectangle.X + RelativeRectangle.X, Rectangle.Y + RelativeRectangle.Y, RelativeRectangle.Width, RelativeRectangle.Height), Color.Black);
                spriteBatch.DrawString(SpriteText, Title, new Vector2(Rectangle.X + RelativeRectangle.X + 10, Rectangle.Y + RelativeRectangle.Y + 10), Color.White);
            }
        }
    }
}
</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>and lastly the Game1.cs</p>
<pre class="prettyprint lang- linenums:1">
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace RPG
{
    /// &lt;summary&gt;
    /// This is the main type for your game
    /// &lt;/summary&gt;
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        Resources res;

        Mouse mouse;

        ClickableMenu objMenu;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        /// &lt;summary&gt;
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// &lt;/summary&gt;
        protected override void Initialize()
        {
            graphics.PreferredBackBufferWidth = 800;
            graphics.PreferredBackBufferHeight = 640;
            graphics.IsFullScreen = false;
            graphics.ApplyChanges();
            Window.Title = "RPG";
            objMenu = new ClickableMenu(new Rectangle(50, 400, 300, 200));
            base.Initialize();
        }

        /// &lt;summary&gt;
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// &lt;/summary&gt;
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            res = new Resources(this.Content);
            mouse = new Mouse(Content.Load&lt;Texture2D&gt;("cursor"));
            objMenu.Init(res);
            objMenu.AddButton(new Rectangle(20, 60, 80, 40), res);
        }

        /// &lt;summary&gt;
        /// UnloadContent will be called once per game and is the place to unload
        /// all content.
        /// &lt;/summary&gt;
        protected override void UnloadContent()
        {
        }

        /// &lt;summary&gt;
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// &lt;/summary&gt;
        /// &lt;param name="gameTime"&gt;Provides a snapshot of timing values.&lt;/param&gt;
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();
            mouse.Update();
            PerformUpdates();
            base.Update(gameTime);
        }

        private void PerformUpdates()
        {
            if (mouse.ClickedObject == null)
            {
                objMenu.Update(mouse);
            }
            else
            {
                mouse.ClickedObject.Update(mouse);
            }
        }

        /// &lt;summary&gt;
        /// This is called when the game should draw itself.
        /// &lt;/summary&gt;
        /// &lt;param name="gameTime"&gt;Provides a snapshot of timing values.&lt;/param&gt;
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin();
            spriteBatch.Draw(res.texBG, new Rectangle(0, 0, 800, 640), Color.White);
            objMenu.Draw(spriteBatch);
            spriteBatch.End();
            mouse.Draw(spriteBatch);
            base.Draw(gameTime);
        }
    }
}
</pre>
]]></description>
		<pubDate>Wed, 22 May 2013 02:34:55 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643393-mouse-and-rectangle-problems/</guid>
	</item>
	<item>
		<title>typedef a primitive type</title>
		<link>http://www.gamedev.net/topic/643392-typedef-a-primitive-type/</link>
		<description><![CDATA[<p>I often see typedefs on a primitive type.&nbsp;</p>
<p>For example</p>
<pre class="prettyprint lang-">
    typedef signed   char int8;
    typedef unsigned char uint8;

    typedef signed   short int16;
    typedef unsigned short uint16;
</pre>
<p>&nbsp;</p>
<p>What's the point of this?</p>
]]></description>
		<pubDate>Wed, 22 May 2013 02:19:14 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643392-typedef-a-primitive-type/</guid>
	</item>
	<item>
		<title>RenderWindow + GBuffer + Events</title>
		<link>http://www.gamedev.net/topic/643391-renderwindow-gbuffer-events/</link>
		<description><![CDATA[<p>Hi all,</p>
<p>I have a RenderWindow class who is inherited by renderer (D3D11 and OGL4).</p>
<p>In each of them they have a GBuffer instance and have an array to get events.</p>
<p>What i'm saying in my head is, only one GBuffer is needed and so it can be managed by the render window.</p>
<p>Same for the ortho matrix, only one is needed so it can be managed by the render window.</p>
<p>Is it a correct design to handle that ?</p>
<p>&nbsp;</p>
<p>My second question is :</p>
<p>Do you have a nice design to handle event ? Actually I have a callback in IGameState and the MainLoop sends</p>
<p>each event stored for the active RenderWindow and the application manage each one.</p>
<p>&nbsp;</p>
<p>Thanks</p>
]]></description>
		<pubDate>Wed, 22 May 2013 01:55:58 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643391-renderwindow-gbuffer-events/</guid>
	</item>
	<item>
		<title>Game programming vs. other programming occupations in the UK?</title>
		<link>http://www.gamedev.net/topic/643388-game-programming-vs-other-programming-occupations-in-the-uk/</link>
		<description><![CDATA[<p><span style="color:rgb(80,80,80);font-family:Arial, Geneva, Lucida, sans-serif;">I am wondering which career path to choose, I'd preferably like a job which will involve lots of math & developing algorithms, game programming certainly has that, but I am worried about job hours and being taken advantage of, worried that companies may see me as a typical graduate fresh in the industry and will make me work 10 hours a day for much lower pay than other programming jobs, as I hear happens a lot in America, but I really have no idea what it's like here in the UK. Is it much different here? I am motivated and am willing to work hard, but not like that.</span><br><br><span style="color:rgb(80,80,80);font-family:Arial, Geneva, Lucida, sans-serif;">Also any info on the approximate salary of game programmers compared to other programmers would be helpful.&nbsp;</span><span rel='lightbox'><img class='bbc_img' src="http://static1.tsrfiles.co.uk/6.3.1/images/smilies/smile.png" title=":)" alt="smile.png"></span></p>
<p>&nbsp;</p>
<p>P.S. I've read lots of articles comparing software programming vs. game programming but it's always America or some other country. But the UK has different laws & regulations, i.e I can't imagine making a graduate work 12 hours a day with unpaid overtime would even be legal here.</p>
]]></description>
		<pubDate>Wed, 22 May 2013 00:53:17 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643388-game-programming-vs-other-programming-occupations-in-the-uk/</guid>
	</item>
	<item>
		<title>random numbers</title>
		<link>http://www.gamedev.net/topic/643387-random-numbers/</link>
		<description><![CDATA[<p>I am trying to generate 9 random numbers that do not repeat. here is the code I am using.</p>
<p></p><pre class="prettyprint linenums:0">
srand(
&nbsp;
unsigned(time(NULL)));
&nbsp;
&nbsp;
&nbsp;
int x=0;
&nbsp;
&nbsp;
&nbsp;
vector &lt;int&gt; Num_Array;
&nbsp;
&nbsp;
for(int i=1; i&lt;=9; i++)
{
Num_Array.push_back(i);
}
random_shuffle(Num_Array.begin(),Num_Array.end());
player_O=Num_Array[x];
x++;
</pre>
<p>I am attempting to do some AI for a tic tac toe game.</p>
]]></description>
		<pubDate>Tue, 21 May 2013 23:24:04 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643387-random-numbers/</guid>
	</item>
	<item>
		<title>Render to texture while reading from existing framebuffer</title>
		<link>http://www.gamedev.net/topic/643386-render-to-texture-while-reading-from-existing-framebuffer/</link>
		<description><![CDATA[<p>Is this possible?</p>
<p>&nbsp;</p>
<p>What I'm looking to do is render a load of particles into a texture however still using the framebuffer's zbuffer which hasn't been cleared and then composite that with the main color framebuffer (which already has the scene rendered into it).<br>
&nbsp;</p>
<p>I've tried just not attaching the depth component to the FBO but that didn't work.</p>
<p>&nbsp;</p>
<p>Or do I need to render the scene to a rtt, copy it's depth texture into the particles rtt depth texture and then render into the particles rtt?</p>
<p>&nbsp;</p>
<p>Thanks</p>
]]></description>
		<pubDate>Tue, 21 May 2013 22:55:05 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643386-render-to-texture-while-reading-from-existing-framebuffer/</guid>
	</item>
	<item>
		<title>Connecting to MySQL Database</title>
		<link>http://www.gamedev.net/topic/643385-connecting-to-mysql-database/</link>
		<description><![CDATA[I've connected my games to databases in the past using HTTP requests to PHP as the middle man using libcurl and the libmysql connector. I wonder though, which would be more secure: libcurl or directly via libmysql? A direct connection means to me, that queries I send could be compromised, and TS better POSTing ambiguous data via HTTP requests a d sending the data back in a tokenized or possibly binary format.<br><br>
What would be the best?]]></description>
		<pubDate>Tue, 21 May 2013 22:49:40 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643385-connecting-to-mysql-database/</guid>
	</item>
	<item>
		<title>Shadow Mapping: Understanding Orthographic Projection</title>
		<link>http://www.gamedev.net/topic/643384-shadow-mapping-understanding-orthographic-projection/</link>
		<description><![CDATA[<p>Hello,</p>
<p>&nbsp;</p>
<p>Im currently in the process of implementing shadow mapping on my engine, im using a deferred renderer for now and works just fine, my main issue comes to implementing directional lights.</p>
<p>&nbsp;</p>
<p>I've managed to setup a ortographic matrix and multiply it with a view matrix to obtain a camera who can render the scene and draw proper shadows, the problem arises in the fact that not the entire geometry is covered in the camera range.</p>
<p>&nbsp;</p>
<p>The solution i've read is to create the camera based on the user-controlled camera frustum, however, i do not quite understand how the ortho projection works, mainly what each parameter means, right now im using a function who takes 4 parameters, this is the code (im using the irrlicht math library for my engine as i was used to it already).</p>
<p>&nbsp;</p>
<pre class="prettyprint">
	template &lt;class T&gt;
	inline CMatrix4&lt;T&gt;& CMatrix4&lt;T&gt;::buildProjectionMatrixOrthoLH(
			float widthOfViewVolume, float heightOfViewVolume, float zNear, float zFar)
	{
		AX_ASSERT_IF(widthOfViewVolume==0.f); //divide by zero
		AX_ASSERT_IF(heightOfViewVolume==0.f); //divide by zero
		AX_ASSERT_IF(zNear==zFar); //divide by zero
		M[0] = (T)(2/widthOfViewVolume);
		M[1] = 0;
		M[2] = 0;
		M[3] = 0;

		M[4] = 0;
		M[5] = (T)(2/heightOfViewVolume);
		M[6] = 0;
		M[7] = 0;

		M[8] = 0;
		M[9] = 0;
		M[10] = (T)(1/(zFar-zNear));
		M[11] = 0;

		M[12] = 0;
		M[13] = 0;
		M[14] = (T)(zNear/(zNear-zFar));
		M[15] = 1;

#if defined ( USE_MATRIX_TEST )
		definitelyIdentityMatrix=false;
#endif
		return *this;
	}
</pre>
<p>&nbsp;</p>
<p>I dont know what exactly each parameter means when it comes to projection, i'm also not quite sure if i need a view matrix to create the light camera, maybe someone can help me with this.</p>
<p>&nbsp;</p>
<p>Thanks!</p>
]]></description>
		<pubDate>Tue, 21 May 2013 22:38:36 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643384-shadow-mapping-understanding-orthographic-projection/</guid>
	</item>
	<item>
		<title>OpenGL 3?</title>
		<link>http://www.gamedev.net/topic/643382-opengl-3/</link>
		<description><![CDATA[Before anybody says thats an old version i am aware. Unfortunatley, even with mesa i can only support up to that as Intel HD 3000 is the best i have.<br><br>
I have done C for around 3 months and i believe that i have established a reasonable base in it. I believe i know all the basics (structs, headers, dynamic memory allocation, bitwise to a certain degree etc.).<br><br>
What i wanted to know if it would be reasonable to start learning opengl with this(not c++ as i have had bad experiences with it prior). And also it would be nice to know anything hardware specific i would need to know(as Intel HD is notoriously bad for opengl AFAIK).<br><br>
Thanks]]></description>
		<pubDate>Tue, 21 May 2013 21:52:05 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643382-opengl-3/</guid>
	</item>
	<item>
		<title>what books or tutorials are available</title>
		<link>http://www.gamedev.net/topic/643378-what-books-or-tutorials-are-available/</link>
		<description><![CDATA[<p>What Framework , API is best for creating an online 2D desktop game ( multiplayer ) ?</p>
<p>&nbsp;</p>
<p>I started studying XNA but I am discouraged because the book tells me that XNA studio has to be installed</p>
<p>on any computer PC using the built app . I can't really expect that from the users .</p>
<p>&nbsp;</p>
<p>I have some programming experience ( mostly web and database ) but i am new to games and online games .</p>
<p>Trying to find tutorials , books etc. best to learn from to build what I want .</p>
]]></description>
		<pubDate>Tue, 21 May 2013 20:01:51 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643378-what-books-or-tutorials-are-available/</guid>
	</item>
	<item>
		<title>public engine code, private game code, git repositories, projectsXsolutions, how to?</title>
		<link>http://www.gamedev.net/topic/643374-public-engine-code-private-game-code-git-repositories-projectsxsolutions-how-to/</link>
		<description><![CDATA[<div>Ive been using github public repository till now for the engine Im doing, but now I will start, along with the engine, to develop the game code (real game code, not just test code), which uses the engine.</div>
<div>&nbsp;</div>
<div>Should I create another project under the "engine" solution in VS, and create a repository for it?..not sure whats gonna happen with the current repository..should I just gitignore the folder where the new project will lie? is it enough?</div>
<div>&nbsp;</div>
<div>Im just confused on what to do, Ive been using git for only a few weeks, windows gui only (guithub for windows), so yeah, to me its all magic yet.</div>
<div>I already have imported the github repo to my bitbucket account (cause it allows private repos), but I dont even know if I should have done that ._.</div>
<div>&nbsp;</div>
<div>The engine is not a dll or lib yet, its just code, I dont know how to do a project on VS without a main entry point..am I obligated to create a lib? cant it just compile?</div>
<div>&nbsp;</div>
<div>what should I do?</div>]]></description>
		<pubDate>Tue, 21 May 2013 19:34:34 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643374-public-engine-code-private-game-code-git-repositories-projectsxsolutions-how-to/</guid>
	</item>
	<item>
		<title>what framework and api is best</title>
		<link>http://www.gamedev.net/topic/643372-what-framework-and-api-is-best/</link>
		<description><![CDATA[<p>Moving this to another forum ... sorry .</p>
]]></description>
		<pubDate>Tue, 21 May 2013 18:52:03 +0000</pubDate>
		<guid>http://www.gamedev.net/topic/643372-what-framework-and-api-is-best/</guid>
	</item>
</channel>
</rss>