I am beginning Android development
This is useful for learning about the Android operating system ...
www.vogella.com/articles/Android/article.html
Thursday, 6 December 2012
AppMobi
Someone asked me to use Appmobi a couple of months ago. I hesitantly installed it on my second PC, fearing trojans on my main comp. Looking at the dev kit, I found it interesting, I could see they did some impressive work on the editor environment - it runs a local server on your computer from a .jar file, and then starts the development environment which is based in javascript, on your browser. I had to have chrome open (it installs in chrome) before it would run.
So far so good. The environment gives you a code editing view and an emulator view. The emulator view contains several popular devices, including iPad, iphone, android devices, windows mobile devices and laptops. So when you run your program in the emulator you can reload the app with the focus set to various other devices to see how it will look when it is built.
Now the development environment is pretty interesting. I found the javascript interesting, however I got the distinct impression that it was not going to be helpful if I did not pay for the Game package that contains the drag'n'drop game development kit. I was right, however I was able to start up the demo games (named DirectCanvas and Furious Fowl, a parody of furious birds I assume) and the javascript was certainly not for beginners. In fact I think certain things were more difficult than necessary, and they had worked more to impress the user with their code than to actually be helpful. So as a matter of fact I had to dig around for needed features, like the touch screen API. The rest of the setup was awkward. I really don't think javascript on html5 was designed for applications, and in fact the big problem is the User Interface Coherence, by that I mean that a UI based in html5 running a javascript suffers from the fact that the UI is the root of the application, and the JS is based upon the document object model of the web page, not that the web page is spawned by the script. So the temptation is to have 1 or 2 opening pages and then to do everything in html5 canvas. This is how I started up, my first page was a dummy page with some information, then I went straight into a constantly running javascript. The problem in this case is that I want my JS to spawn different pages and to maintain a data structure throughout (i.e. username, user data) , so to do this I would either have to design a page that contains all the divs for every page, or to design the pages in JS, and then of course you would want meta data (back to the divs).
In other words, if you change pages, your script dies and you might need to save a JSON containing information that is global to the app - all this seems over complicated and is perhaps a form of Kludge (over complicated solution).
Well that was all good, I found I was able to dig up the function for the touch screen easily enough, and the canvas was snappy and responsive on the emulator. Well the 3D tests I tried did not work, so perhaps they need to rebuild webkit sometime. That was a disappointment.
The problem occurred when I tried to test my app on a device. There where two options, push to the cloud and test on wifi, so I tried to test on wifi - first appmobi asked me to browse to a web address on the mobile device and then follow the instructions. I tried to follow the instructions to install an appmobi test app and the program failed to install, I was redirected to a page that showed an error message " '/' not found". So I refreshed the first page and this time I was prompted for my developer account login details - I entered my username and password 3 times before I realized - I don't have a developer account.
So ... appmobi is fun and intuitive at first, but when you really think about it, the bells and whistles don't compete with a good 'ol native program, i.e JNI program for the Android.
So far so good. The environment gives you a code editing view and an emulator view. The emulator view contains several popular devices, including iPad, iphone, android devices, windows mobile devices and laptops. So when you run your program in the emulator you can reload the app with the focus set to various other devices to see how it will look when it is built.
Now the development environment is pretty interesting. I found the javascript interesting, however I got the distinct impression that it was not going to be helpful if I did not pay for the Game package that contains the drag'n'drop game development kit. I was right, however I was able to start up the demo games (named DirectCanvas and Furious Fowl, a parody of furious birds I assume) and the javascript was certainly not for beginners. In fact I think certain things were more difficult than necessary, and they had worked more to impress the user with their code than to actually be helpful. So as a matter of fact I had to dig around for needed features, like the touch screen API. The rest of the setup was awkward. I really don't think javascript on html5 was designed for applications, and in fact the big problem is the User Interface Coherence, by that I mean that a UI based in html5 running a javascript suffers from the fact that the UI is the root of the application, and the JS is based upon the document object model of the web page, not that the web page is spawned by the script. So the temptation is to have 1 or 2 opening pages and then to do everything in html5 canvas. This is how I started up, my first page was a dummy page with some information, then I went straight into a constantly running javascript. The problem in this case is that I want my JS to spawn different pages and to maintain a data structure throughout (i.e. username, user data) , so to do this I would either have to design a page that contains all the divs for every page, or to design the pages in JS, and then of course you would want meta data (back to the divs).
In other words, if you change pages, your script dies and you might need to save a JSON containing information that is global to the app - all this seems over complicated and is perhaps a form of Kludge (over complicated solution).
Well that was all good, I found I was able to dig up the function for the touch screen easily enough, and the canvas was snappy and responsive on the emulator. Well the 3D tests I tried did not work, so perhaps they need to rebuild webkit sometime. That was a disappointment.
The problem occurred when I tried to test my app on a device. There where two options, push to the cloud and test on wifi, so I tried to test on wifi - first appmobi asked me to browse to a web address on the mobile device and then follow the instructions. I tried to follow the instructions to install an appmobi test app and the program failed to install, I was redirected to a page that showed an error message " '/' not found". So I refreshed the first page and this time I was prompted for my developer account login details - I entered my username and password 3 times before I realized - I don't have a developer account.
So ... appmobi is fun and intuitive at first, but when you really think about it, the bells and whistles don't compete with a good 'ol native program, i.e JNI program for the Android.
Thursday, 22 November 2012
OpenGL Bug Hell
OpenGL is one of the finest rendering API's available, the other being Direct3D.
For anyone who ever used OpenGL, this is worth reading
http://www.opengl.org/wiki/Common_Mistakes
To avoid mindless trial and error hacking ...
For anyone who ever used OpenGL, this is worth reading
http://www.opengl.org/wiki/Common_Mistakes
To avoid mindless trial and error hacking ...
Tuesday, 20 November 2012
...Busy
Well I was busy last year concentrating on a project that made heavy use of virtual memory, this year I have been busy looking at open source, moving from project to project to find inspiration, I still don't have a goal as such, however I am very interested in
Blender
FreeCAD
for all things concerned with Computer Aided Design. Blender seems to be quite difficult to learn, and as a consequence the first simple steps towards CSG were easier in FreeCAD. I would like FreeCAD to look (and feel) a lot more like Autocad, however I understand the Open Cascade API that it was built on is difficult to use, being intellectually demanding.
The other software that I have been looking at includes
WebGL
HTML5
Javascript
Android Development
Cross platform phone development
I'd still like to get my own game done on one of these platforms, I know it is almost easy now using an engine, but I bumped into the old problem of content development. I think this is why I became interested in CAD. I was certainly looking at blender for inspiration on User Interface design.
I also absolutely use Python ... I downloaded a package called Pythonxy over a month ago and set up the control systems toolbox (an achievement worth mentioning) . I am really impressed by the power of MathPlotLib combined with Scipy (scientific python package) and Numpy (numeral python package). I can actually run my old control systems studies in python and see the result plotted on screen.
Blender
FreeCAD
for all things concerned with Computer Aided Design. Blender seems to be quite difficult to learn, and as a consequence the first simple steps towards CSG were easier in FreeCAD. I would like FreeCAD to look (and feel) a lot more like Autocad, however I understand the Open Cascade API that it was built on is difficult to use, being intellectually demanding.
The other software that I have been looking at includes
WebGL
HTML5
Javascript
Android Development
Cross platform phone development
I'd still like to get my own game done on one of these platforms, I know it is almost easy now using an engine, but I bumped into the old problem of content development. I think this is why I became interested in CAD. I was certainly looking at blender for inspiration on User Interface design.
I also absolutely use Python ... I downloaded a package called Pythonxy over a month ago and set up the control systems toolbox (an achievement worth mentioning) . I am really impressed by the power of MathPlotLib combined with Scipy (scientific python package) and Numpy (numeral python package). I can actually run my old control systems studies in python and see the result plotted on screen.
Sunday, 11 November 2012
My idea, already made !
http://sourceforge.net/apps/mediawiki/free-cad/index.php?title=Main_Page
I even thought of the idea of python scripting too !
I was using Opencascade
with WxWidgets and my google efforts brought me to this!
I even thought of the idea of python scripting too !
I was using Opencascade
with WxWidgets and my google efforts brought me to this!
Wednesday, 31 October 2012
Saturday, 27 October 2012
languages
http://www.swig.org/papers/Tcl96/tcl96.html
a very nice tool for scripting
http://www.gnu.org/software/bison/
for creating languages
http://en.wikipedia.org/wiki/Emscripten
gcc language to javascript
a very nice tool for scripting
http://www.gnu.org/software/bison/
for creating languages
http://en.wikipedia.org/wiki/Emscripten
gcc language to javascript
Wednesday, 21 March 2012
Set Theory
I had a code problem that most programmers would be very familiar with. I wanted to create a set of names. The definition of set is basically a number of items where each item must be a unique element. So for example, if I add the name "Dave" twice it only stores one copy of the name. The important requirement was that the set returned the index (number) of the name in the array .. for example
0: Craig
1: Jen
2: Dave
3: Gary
4: Peter
when inserting the name "Dave" I want the number 2 to return from the function.
The easy way to perform this is to say "for each element, if name equals the new Name, return the number".
This method becomes quite slow for very large lists of names. So I wrote this class ...
class ArraySet
{
public:
string& Get(int p)
{
if( p < elems.size() )
{
return elems[p];
}
else return string("");
}
void Append(string &s)
{
elems.push_back(s);
}
vector<string> elems;
};
class TreeNode
{
public:
TreeNode()
{
parent = NULL;
left = right = NULL;
data = -1;
searchVisited = false;
}
TreeNode(TreeNode* pParent)
{
parent = pParent;
left = right = NULL;
data = -1;
searchVisited = false;
}
int data;
bool searchVisited ;
int Insert(string &s2, ArraySet &set)
{
string s1 = "";
s1 = set.Get(data);
if( s1 == s2 )
{
return data;
}
else
{
if( s1 < s2 )
{
if( right )
{
return right->Insert(s2, set);
}
else
{
right = new TreeNode(this);
set.Append(s2);
right->data = set.elems.size()-1;
return right->data;
}
}
else if( s1 > s2 )
{
if( left )
{
return left->Insert(s2, set);
}
else
{
left = new TreeNode(this);
set.Append(s2);
left->data = set.elems.size()-1;
return left->data;
}
}
}
}
void Visit(vector<int> &rmp)
{
if( left )
{
left->Visit(rmp);
}
rmp.push_back(data);
if( right )
{
right->Visit(rmp);
}
}
TreeNode* parent;
TreeNode* left;
TreeNode *right;
};
class TreeIndexedSet
{
public:
TreeIndexedSet()
{
root = NULL;
}
int InsertString(string &str)
{
if( root )
{
return root->Insert(str, m_set);
}
else
{
root = new TreeNode;
m_set.Append(str);
root->data = m_set.elems.size()-1;
return root->data;
}
}
string& LookupString(int p)
{
return m_set.Get(p);
}
void SortRemap()
{
if( m_set.elems.size() > 1000000 )
{
SortRemapIterate();
}
else
{
root->Visit(sortedRemapping);
}
}
void SortRemapIterate()
{
TreeNode *currNode = root;
while (true)
{
if (currNode == NULL)
break;
if (currNode->left != NULL && currNode->left->searchVisited != true)
{
currNode = currNode->left;
}
else if (currNode->right != NULL && currNode->right->searchVisited != true)
{
currNode = currNode->right;
}
else if (currNode->searchVisited == false)
{
sortedRemapping.push_back(currNode->data);
currNode->searchVisited = true;
}
else
{
currNode = currNode->parent;
}
}
}
vector< int > sortedRemapping;
TreeNode* root;
ArraySet m_set;
};
0: Craig
1: Jen
2: Dave
3: Gary
4: Peter
when inserting the name "Dave" I want the number 2 to return from the function.
The easy way to perform this is to say "for each element, if name equals the new Name, return the number".
This method becomes quite slow for very large lists of names. So I wrote this class ...
class ArraySet
{
public:
string& Get(int p)
{
if( p < elems.size() )
{
return elems[p];
}
else return string("");
}
void Append(string &s)
{
elems.push_back(s);
}
vector<string> elems;
};
class TreeNode
{
public:
TreeNode()
{
parent = NULL;
left = right = NULL;
data = -1;
searchVisited = false;
}
TreeNode(TreeNode* pParent)
{
parent = pParent;
left = right = NULL;
data = -1;
searchVisited = false;
}
int data;
bool searchVisited ;
int Insert(string &s2, ArraySet &set)
{
string s1 = "";
s1 = set.Get(data);
if( s1 == s2 )
{
return data;
}
else
{
if( s1 < s2 )
{
if( right )
{
return right->Insert(s2, set);
}
else
{
right = new TreeNode(this);
set.Append(s2);
right->data = set.elems.size()-1;
return right->data;
}
}
else if( s1 > s2 )
{
if( left )
{
return left->Insert(s2, set);
}
else
{
left = new TreeNode(this);
set.Append(s2);
left->data = set.elems.size()-1;
return left->data;
}
}
}
}
void Visit(vector<int> &rmp)
{
if( left )
{
left->Visit(rmp);
}
rmp.push_back(data);
if( right )
{
right->Visit(rmp);
}
}
TreeNode* parent;
TreeNode* left;
TreeNode *right;
};
class TreeIndexedSet
{
public:
TreeIndexedSet()
{
root = NULL;
}
int InsertString(string &str)
{
if( root )
{
return root->Insert(str, m_set);
}
else
{
root = new TreeNode;
m_set.Append(str);
root->data = m_set.elems.size()-1;
return root->data;
}
}
string& LookupString(int p)
{
return m_set.Get(p);
}
void SortRemap()
{
if( m_set.elems.size() > 1000000 )
{
SortRemapIterate();
}
else
{
root->Visit(sortedRemapping);
}
}
void SortRemapIterate()
{
TreeNode *currNode = root;
while (true)
{
if (currNode == NULL)
break;
if (currNode->left != NULL && currNode->left->searchVisited != true)
{
currNode = currNode->left;
}
else if (currNode->right != NULL && currNode->right->searchVisited != true)
{
currNode = currNode->right;
}
else if (currNode->searchVisited == false)
{
sortedRemapping.push_back(currNode->data);
currNode->searchVisited = true;
}
else
{
currNode = currNode->parent;
}
}
}
vector< int > sortedRemapping;
TreeNode* root;
ArraySet m_set;
};
Tuesday, 24 January 2012
Memory Management ...
My old post on Memory mapped files made me think about how to implement some technology that is rare in current software knowledge bases.
This lead me to delve into my memory for this website ... a strong and free memory manager is available here
http://www.paulnettle.com/
Listen to the music ...
The concept is simple ... to replace the hash table memory management system here by removing calls to malloc and to simply use a memory mapped file to map large areas of the disk to the process, the limitation is theoretically the address space of the program, but normal practical terms limits this to 2GB even for 64 bit applications (citation needed). This means technically that I can have computers use 2GB RAM and 2GB RAM for free!
http://msdn.microsoft.com/en-us/library/windows/desktop/aa366761(v=vs.85).aspx
The function MapViewOfFile(...)
The gives access to a portion of the file in memory, so if for example I open a 2GB file then I can map a portion, say 1MB at the 1.5GB boundary, and all I have to do is supply the numbers for the offsets into the file, then I have 1MB from the 2GB data pool to read and write to. I think this explains why I need a decent memory management implementation to work with.
This lead me to delve into my memory for this website ... a strong and free memory manager is available here
http://www.paulnettle.com/
Listen to the music ...
The concept is simple ... to replace the hash table memory management system here by removing calls to malloc and to simply use a memory mapped file to map large areas of the disk to the process, the limitation is theoretically the address space of the program, but normal practical terms limits this to 2GB even for 64 bit applications (citation needed). This means technically that I can have computers use 2GB RAM and 2GB RAM for free!
http://msdn.microsoft.com/en-us/library/windows/desktop/aa366761(v=vs.85).aspx
The function MapViewOfFile(...)
The gives access to a portion of the file in memory, so if for example I open a 2GB file then I can map a portion, say 1MB at the 1.5GB boundary, and all I have to do is supply the numbers for the offsets into the file, then I have 1MB from the 2GB data pool to read and write to. I think this explains why I need a decent memory management implementation to work with.
Sunday, 8 January 2012
Preparing for a release
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.
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.
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.
Subscribe to:
Posts (Atom)