![]() |
|
Whirl
By Vassili Philippov, October 03, 2001.
IntroductionWhirl is a demo full screen application that is written using EasyCE library. You can download installation (58 Kb). Here I describe how I created it. What You Need
Begin
I have decided to write a small demo program - something to show to my
friends. About 10 years ago I read in Scientific America
about a beautiful program. The algorithm was very simple, I will describe it below.
Here is some picture that explains what is my target. We need to see something
beautiful in the end it increases motivation. And name - let's call this program Whirl. I think it will be interesting to show program development from the idea to publishing to download sites (like pocketgear.com and handango.com). I will develop this program and write everything I do. One day will be enough to complete it. First of all I need EasyCE library. I have never used it before but I have used GAPI without wrappers and I don't want to do it again. What do I expect from EasyCE? ... nothing more then using RGB array instead of device depended buffer, the library description says that EasyCE provides much more features but I don't need them in this program. As I remember EasyCE is free for freeware programs - great, I am not going to sale my small application. Program descriptionThis program will be a funny demo nothing more. It is similar to good known "life". There is a cell plane. Each cell could have one of N colors. There is only one rule: Colors are in circle sequence. It means that next to the color N is color 0. This algorithm can be written in C++ as: Initially the field should be filled with random colors. Another problem in this application is finding good palette. I will use the rainbow palette. Program development. Step by stepStep 1. Download EasyCE libraryIt was simple to find EasyCE library because I created a list of all existing libraries for Pocket PC developers. EasyCE was the first in this list. Many thanks to Jacco Bikker. I have also downloaded the sample application because it is more easy to understand a library using samples then reading helps. I have spent about 30 minutes looking though the sample and the library. Step 2. Create new projectI have created new project using WCE Pocket PC Application project template. Then copy EasyCE library files to my project and included them into the project (Project\Add To Project\Files). Step 3. Simple EasyCE applicationWhat I am going to do now is writing very simple application that uses EasyCE. For example it will fill the screen with red color and wait a click. ...done. Here is the code: I am trying to compile it... buh! Compile error:
After 20 minutes I have solved the problem. Don't using precompiled headers helped
in my case ( After small linking error (it is described in EasyCE documentation) that can be solved by adding gx.lib library my project is compiled. It is time to run my application. To run my application I need gx.dll. The simple application works just as I expected. Step 4. Whirl logicNow I will add whirl functionality. I think it will take about 1 hour.... done. And it works. But works slow - only 2 FPS. I expected it, now it is time for optimization. Here is my code before optimizations whirlcode1.html. As you see it is very close to my algorithm description above. Step 5. Optimization 1Optimizing code is one of the most interesting jobs. First of all the method Copy2To1 can be changed by simple memcpy. The second think I think take a lot of time is color calculation. I will create an array of EasyCE format colors for each my color. I think it will be much faster then call BuildColor function for each point. Running ... 2.6 FPS. Better but is not good enough. I think I need about 4-5 FPS. Step 5. Optimization 2I will try to remove the neighbor circle and optimize calculations. The result is not simple. You can found it here: optimized.html. Running ... 6 FPS. Enough. Optimizations are finished. Step 6. IconTo finish the code we need to add an icon. It is enough just to add any icon to the resources and it will be an application icon. Step 7. InstallationIf your program is very simple and consists of one executable file you don't need any installations. In my case I have to insert gx.dll file also. I will not describe how I created the installation because this procedure is described in many articles. I used standard free Cab Wizard. The EndYou can download sources that include the application and the installation. Whirl.zip (386 Kb). Related resources:
DiscussDiscuss this article. Here you can write your comments and read comments of other developers. |
|||||||||||||||||||||