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);

Monday, 19 May 2014

QScrollArea squashing its contents

If a QScrollArea is squashing its contents when resized instead of adjusting the scrollbar, set widgetResizable to false.

Tuesday, 13 May 2014

UNIQUE constraints in SQLite FTS (FTS3/FTS4) tables

The correct way to do this:
CREATE VIEW playlist_view AS SELECT * FROM playlist;

CREATE TRIGGER insert_playlist INSTEAD OF INSERT ON playlist_view
BEGIN
    SELECT RAISE(ABORT, 'column user_id is not unique') FROM playlist 
        WHERE user_id=new.user_id;
    INSERT INTO playlist (from_user, from_id, created_time, 
                          created_time_formated, user_id) 
    VALUES (NEW.from_user, NEW.from_id, NEW.created_time, 
            NEW.created_time_formated, NEW.user_id);
END;

-- And you do the insertion on the view 
INSERT INTO playlist_view (from_user,from_id,created_time,created_time_formated,user_id) SELECT ...;

Wednesday, 7 May 2014

Custom Build Tools in Visual Studio

Custom Build Tools in Visual Studio

You can compile non-standard file types with arbitrary programs in Visual studio by specifying a Custom Build Tool. But often the tool expects to be running in the same directory as the target file, and it won't be, it will be running in the Project directory. And multiline batch commands are not allowed in Visual Studio 2012.

So we use the START batch command to specify the directory with /D, followed by the exe and its parameters:

START "title" /D"%(RootDir)%(Directory)" "win_flex.exe" "%(FullPath)"

Property Sheets in Visual Studio are super-important.

If you are making a lot of projects in Visual Studio and having to set up a lot of project options, you need Property Sheets. Go to the Property Manager window, and you can create .props files here that whole projects or individual configurations can inherit from.

http://msdn.microsoft.com/en-US/library/z1f703z5(v=vs.80).aspxhttp://stackoverflow.com/questions/17754038/visual-studio-express-2012-properties-of-property-sheet-trouble

Sunday, 4 May 2014

Effect groups - grouping techniques in DirectX 11 Effects

See http://msdn.microsoft.com/en-us/library/windows/desktop/ff476120.aspx for details, but in general, in .fx:

fxgroup Group1
{
     technique11 Tech1 { ... }
     technique11 Tech2 { ... }
}
and in C++:
pEffect->GetTechniqueByName( "Group1|Tech2" );
or
pEffect->GetGroupByName("Group1")->GetTechniqueByName( "Tech1" );