Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 12 Oct 1999
Offline Last Active Jan 27 2015 03:40 AM

Topics I've Started

Decimal string to Pointer via StringStream

08 August 2012 - 06:36 AM

C++ iostreams provide a method to output (void *) pointers. The pointer is written to and read from a stream in hexadecimal notation.

How can I use decimal notation without resorting to a reinterpret_cast and ugly #ifdefs?

I tried this:
std::stringstream ss;

void *test = (void *)0x12345678;

// Output pointer as decimal number
ss << std::ios::dec << test; // Works!

// Read pointer from decimal number
void *x;
ss << dec; // Nope
ss.setf(std::ios::dec); // No change
ss >> dec >> x; // Neither

All the input variants do nothing. The pointer will not be assigned and keeps its "help I'm uninitialized" value of 0xcccccccc. The fail bit of the stream is set - probably because it tried to _still_ parse the number in hex and it was too large.

Wrote an article for gamedev.net in HTML...

05 August 2012 - 07:08 AM

I just finished work on an article I want to try and publish on gamedev.net. I used HTML all the way, because that's how I usually write my blog posts and documentation.

Now I notice that the article submitting page uses the same editor as the forum posts do and that this editor doesn't allow me to edit the raw HTML code. Is there any way to import HTML or will I have to copy it, paragraph by paragraph, and apply formatting to it?

Copy & paste from a browser into this editor breaks the formatting as well...

Put these 3D graphics terms into relation for me

17 July 2012 - 04:28 AM

I have last seriously worked with 3D graphics using Direct3D 9 and I'm now in the process of refreshing my knowledge for Direct3D 11. In D3D9 I already used shaders extensively and I understand the purpose and advantages of constant buffers in D3D11, but my mental map currently consists of some disconnected islands of which I'm not sure how they are properly arranged.

This is how I believe it fits together. Can someone rearrange the terms in this tree to how things actually are?

Graphics Pipeline




S0 ... S127


ConstantBuffer 1

ConstantBuffer 2


Sampler 1

Sampler 2


Texture 1

Texture 2


<same here as in vertex shaders>

So in words, shaders distinguish between constant buffers and resources (i.e. constant buffers are not resources). I base that assumption on the fact that HLSL lets you explicitly declare which register a constant buffer is in but not a sampler. Also on the fact that ID3D11DeviceContext::PSSetConstantBuffers() and ID3D11DeviceContext::PSSetShaderResources() are separate methods and I've seen examples assigning a constant buffer to constant buffer slot 0 and a texture to resource slot 0.

And I assume shader registers (S0 ... S127) are the same thing ID3D11DeviceContext::PSSetConstantBuffers() assigns. What happens when I load a pre-SM4.0 shader? Is a constant buffer implicitly created for the parameters it declares? Or can registers hold either a constant buffer or a variable (though I can't find any way to access registers or variables directly in the D3D11 API).

Visual Studio 2012 Express won't support Win32 Projects

04 June 2012 - 07:28 AM

If you followed Microsoft's recent plans or tried Windows 8 + Visual Studio 2012 yourself, you might have noticed already:

Starting with Visual Studio 2012, Microsoft will no longer offer a free C++ compiler for traditional application development. The Express editions will build Metro applications only.

Visual Studio 2012 is pretty interesting because it includes C++11 thread support - something which I've been waiting for very much since it finally resolves the situation of having to decide between Boost.Threads, TBB or POCO for portable threading. Now Microsoft has put me in a situation where I either have to shell out $500 to get the Professional edition or drop Windows 7 and Windows XP from my target group. Dropping Windows 7 is out of the question, as I have no doubt that many people will not be switching to Windows 8 any time soon.

What will you do? $500 for the Professional edition may be a reasonable price, but it's also a significant hurdle to collaborating with the Open Source community. Staying with Visual C++ 2010 Express means little to no C++11 features. That leaves Eclipse CDT + MingW and Code::Blocks + MingW which I'm currently checking out.


I'm not sure anyone can sway Microsoft's from their current path, but I've opened a ticket on Microsoft Connect that you can vote on: Support C++ Desktop Applications in Visual Studio 2012 Express

Realistic Missile Flight Paths

07 May 2012 - 05:56 AM

I'm writing a small strategy game that involves launching missiles from silos and mobile launchers over moderate distances (i.e. shooting across the entire map). These launches will also be shown like cinematics from the side and if I can manage, with the camera following a missile salvo.

I guess there won't be some kind of convenient library like there is for physics in driving games that I could just use to take care of everything?

My trouble already begins with the launch.
  • I'm assuming small missiles achieve aerodynamic flight right out of the launcher (their acceleration is huge), so these can go right over to the targeting phase.
  • Manned rockets seem to be launched vertically and have an acceleration phase during which they are unstable (being prevented from falling over by thrust vectoring) - is that the case with larger missiles like ICBMs, too? Are there any big missiles that are launched at an angle?
Next is targeting:
  • How does a missile hit a certain position on the ground? Probably, there is a cruise phase where the missile climbs to and holds a certain height, but at some point, it has to dive to the target. If the missile was capable of instantaneous direction changes, I could calculate the point where the dive begins given the desired angle of impact, but the direction change will hardly be that abrupt.
  • It gets even more difficult for missiles designed to intercept other missiles. If I have an object's position, direction & velocity, it's probably possible to calculate the direction a missile needs to travel in order to hit the target given an initial position and constant velocity. Any got such a formula or links to it?
I'm not aiming for total realism, I just want it to look good ;)