Wednesday, 21 December 2011

Self Project Management

I am starting to wonder if I will complete my list of tasks before Xmas ...

The best method seems to be to work with a Todo list, basically a notepad document that contains lists of bugs found during test sessions. If I spend too much time on the Todo list I sometimes find myself writing down things that can be fixed in a matter of minutes, so the list isn't my main focus of attention.

Tuesday, 20 December 2011

Back to the Old Skool with D3D9

I remember an early problem with D3D9 rendering windows was that the viewport projection matrix would resize everything in the viewport if and only if the window was resized vertically and not horizontally. This is the fault of the limited functions Direct3D supplies for manipulating projection matrices. I recently decided to delve into the mathematics for 5 minutes and found this quick fix for my display system ... the fault occurs when the screen resizes ... here is some code ...

[code]

/*


D3DXMatrixPerspectiveFovLH( &matProj, D3DXToRadian( 45.0f ),
                                (float)w / float(h), 0.1f, 100.0f );


produces this matrix:-


xScale     0          0               0
0        yScale       0               0
0          0       zf/(zf-zn)         1
0          0       -zn*zf/(zf-zn)     0
where:
yScale = cot(fovY/2)


xScale = yScale / aspect ratio
*/
/*


D3DXMatrixPerspectiveLH(&matProj,
                                (float)w, float(h), 1.0f, 100.0f );


produces this matrix:-


2*zn/w  0       0              0
0       2*zn/h  0              0
0       0       zf/(zf-zn)     1
0       0       zn*zf/(zn-zf)  0
*/

// the solution - to have a Field of View parameter using the top matrix this will fix the problem.
D3DXMATRIX matProj;
if( w > h )
    {
D3DXMatrixPerspectiveFovLH( &matProj, D3DXToRadian( 45.0f ),
                                (float)w / float(h), 0.1f, 100.0f );
}
else
{
D3DXMatrixPerspectiveFovLH( &matProj, D3DXToRadian( 45.0f ),
                                (float)h / float(w), 0.1f, 100.0f );
float temp = matProj._22;// =
matProj._22 = matProj._11;
matProj._11 = temp;
}
[/code]

 as shown the xscale and yscale parameters do not depend upon the values of x and y, and so they can be swapped. Additionally the aspect ratio must be h/w if the height is greater than the width.

(I don't know if anyone actually reads this).

Thursday, 15 December 2011

Better debugging

Amazing how a completely fresh copy of windows xp will complain about the slightest code problems ...
My app on windows 7 has a constructor for a graphical pane and the graphical pane has member variables
int w; // screen width
int h; // screen height

now the constructor has an error,

int w = this->GetWidth();
int h = this->GetHeight();

and this is incorrect because they are already declared in the class definition. But the constructor already works in Windows 7!!??!!

Friday, 9 December 2011

UI tutorial

http://wiki.eclipse.org/User_Interface_Guidelines
The part about icon lighting is very interesting ... also I can just imagine a tooltip that says something like
"DO NOT PRESS THIS BUTTON" causing a crash in a demo .... LoL

Friday, 28 October 2011

Google Chrome or Chromium

I found out yesterday that Google Chrome (also called Chromium) is open source ... I decided to look at the code ...

This experience made me realize that using design patterns, macros, heavy object orientation can be good, but also that it can be a bad thing. Google Chrome is such a large scale project that the leading developers need to use object orientation to that extent, but in small scale projects (i.e. solo projects) there is nothing wrong with using code like

if( A ) then B
else if ( C ) then D

instead of using objects for the same simple purpose. The point I realized is that just because it is heavily object oriented does not mean that the logic is correct.

The question is really, what should a solo developer do when faced with the task of writing a potentially commercial app? Heavy object orientation or good plain 'ol code? I am really not sure. I think that actually the good plain 'ol code technique is much more flexible ... so perhaps old-school procedural programming (i.e. everything in one big page of logic) will make a come-back later with the title "flexi-code".

Friday, 21 October 2011

Text Control Blues

I found out earlier that I was calling GetTextExtent( textString, &length, &height, &extent )
on an empty string! The "height" variable was very important to my program.

Friday, 7 October 2011

Website unsused ...

I am thinking about improving the theme on this page (still unused). The problem is that the site layout is very art-dependant.
http://superlifefood.co.uk/