Thursday, 9 October 2014

@err,hr

https://twitter.com/grahamsellers/status/460840588456128512

If you're debugging Win32 code, stick this in your watch window:

"@err,hr"

Tuesday, 7 October 2014

How to use "Move" on the Windows Menu

http://www.howtogeek.com/howto/windows/bring-misplaced-off-screen-windows-back-to-your-desktop-keyboard-trick/

Tuesday, 22 July 2014

Dual-source blending in DirectX 11

It's not described in the documentation, but dual-source blending in DirectX 11 D3D11_BLEND_SRC1_COLOR is achieved using SV_TARGET1. You would have a BlendState like this (all in fx format):
BlendState CompositeBlend
{
    BlendEnable[0]  =TRUE;
    SrcBlend        =ONE;
    DestBlend       =SRC1_COLOR;
    BlendOp         =ADD;
};
And an output structure that looks like it's writing to two rendertargets. But you only have one rendertarget!
struct TwoColourOutput
{
    float4 add      :SV_TARGET0;
    float4 multiply :SV_TARGET1;
};
And then the pixel shader does:
TwoColourOutput PSMain(v2f IN) : SV_TARGET
{
    TwoColourOutput result =...
    return result;
}
The result - the value in the rendertarget is multiplied by result.multiply, and then result.add is added to it. Viola!

Saturday, 19 July 2014

How to remove the annoying "External Dependencies" pretend-folder from Visual Studio

http://stackoverflow.com/questions/2466286/vs2010-how-to-remove-hide-the-external-dependencies-folder-in-solution-explor
On the right side panel expand the Text Editor section, then expand C/C++ and then click on Advanced. Set the Disable External Dependencies Folder to True and restart Visual Studio.

Thursday, 26 June 2014

DirectX crashes inside the intel igd10iumd32.dll driver

Sometimes, a DX11 pixel shader that does nothing but "discard", causes mystery access violations deep inside igd10iumd32.dll. So watch out for that.

Monday, 16 June 2014

Uniform buffers in OpenGL

In OpenGL, the uniform buffer "Binding Index" is the equivalent of DX11's buffer slots. However, GL has many, many more indices available for than DX - about 35000.

You should therefore NEVER use the same index to bind two different blocks in the same frame - there's simply no need.

e.g


 static int lastBindingIndex=21;
 if(lastBindingIndex>=GL_MAX_UNIFORM_BUFFER_BINDINGS)
  lastBindingIndex=1;
 bindingIndex=lastBindingIndex;
 lastBindingIndex++;
 
 glUniformBlockBinding(program,indexInShader,bindingIndex);