I am working on finishing my task list for version 1 of my recent project, and I have a todo list with 79 tasks mostly marked as "ready for retest". The development process involves much testing and bug fixing, possibly more testing than anything else, so I am moving to a beta test phase asap.
I run into a psychological barrier when I try to work on dialog's ...
Dialog's are the small windows that appear when a program function requires some settings and user input, usually filled with radio boxes, check boxes, choice boxes and buttons. The problem is that they are just completely boring, and so development stops for a while.
Sunday, 8 January 2012
Wednesday, 4 January 2012
Memory Mapped Files
Ok so I am at the pre-beta stage in my project and I discover that I cannot effectively load 100Mb files without using huge amounts of system memory, I look for a solution and find this ...
Memory Mapped Files.
These files are stored in virtual memory and allow the program to have read/write access - and they can be huge in the range of >2Gb. They also speed up read/write access by lowering the number of copy operations needed.
They are implemented in Boost for C++ and have been considered for elevation to the standard C++ library (unless they haven't already been included). So I had to download Boost and try to use one ... Boost is currently building atm, a completely ingenious build system that is very complex to work out.
Memory Mapped Files.
These files are stored in virtual memory and allow the program to have read/write access - and they can be huge in the range of >2Gb. They also speed up read/write access by lowering the number of copy operations needed.
They are implemented in Boost for C++ and have been considered for elevation to the standard C++ library (unless they haven't already been included). So I had to download Boost and try to use one ... Boost is currently building atm, a completely ingenious build system that is very complex to work out.
Sunday, 1 January 2012
C++ programming Getting rid of sprintf()
like the name, I suspect the function "sprintf()" is very fast, but for the sake of non-programmers I am going to explain what it does.
http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/
so if I want to format a block of text into a buffer with numbers I can use sprintf(). The only problem is with the safety of using sprintf, the convenience of allocating an array of bytes in memory every time I want to make some text
Well now (and for a very long time since the creation of the C++ std library) there is a safer and less buggy solution, that also makes the code look a lot neater. Its called "crawls()" ... just kidding.
Now I use this function
template <class T>
inline std::string to_string (const T& t)
{
std::stringstream strStream;
strStream<< t;
return strStream .str();
}
this turns the number into a string without all the old-style conditional statements.
http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/
so if I want to format a block of text into a buffer with numbers I can use sprintf(). The only problem is with the safety of using sprintf, the convenience of allocating an array of bytes in memory every time I want to make some text
Well now (and for a very long time since the creation of the C++ std library) there is a safer and less buggy solution, that also makes the code look a lot neater. Its called "crawls()" ... just kidding.
Now I use this function
template <class T>
inline std::string to_string (const T& t)
{
std::stringstream strStream;
strStream<< t;
return strStream .str();
}
this turns the number into a string without all the old-style conditional statements.
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.
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).
[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!!??!!
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
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
Subscribe to:
Posts (Atom)