2009-11-27

Run OpenGL demos on Mini2440

Mini2440-Arm9 has no graphic hardware accelerator. In order to make opengl program run on it, I think we need do following things:

=======================
Install a crossing toolchain
=======================
  • Extract the package to root
>tar zxvf arm920t-eabi.tgz –C /
  • Export path of toolchains, run also add following line in /root/.bashrc
==================================
Cross-compile mesa library (openGL in Linux)
==================================
  • Download and unpack mesa libraries. See the tutorial here (http://www.mesa3d.org/)
  • You need to use arm-gcc instead of your host gcc to build the mesa library. Max just create a symbolic link refer to the arm-gcc, by
>ln -s /opt/toolchains/arm920t-eabi/bin/arm-linux-gcc /usr/bin/gcc
>cd ~/project/mesa/Mesa-7.5.1
>./configure --host=arm-linux --prefix=/usr/local/mesa
>make
>make install
  • Then, you can find the library and include files at /usr/local/mesa.
=======================
Copy the demo to target board
=======================
My mini2440 is remotely loaded by nfs network on my host machine. The root directory of mini2440 is located at /disk1/nfs/root/ on my host machine. Just copy some demo executables (you can find at for examples Mesa-7.5.1/progs/xdemos) to /disk1/nfs/root/. And start the demos by minicom. See the tutorial.

2009-11-25

OpenGL for Qt

OpenGL for qt-x11-opensource-src.
  • You have to install mesa, which is open source OpenGL library in Linux. Follow this thread: http://www.larsen-b.com/Article/231.html
  • When you configure your Qt-X11, you would see a text info like : "OpenGL support .... yes (Desktop)"
OpenGL for qt-embedded-linux-opensource-src

  • Embedded Qt doesn't support full OpenGL, instead, it supports OpenGL ES (OpenGL for embedded system), a subset of full OpenGL with a smaller, more constrained API. The most important to OpenGL ES is its header file (API) and specification, you can find them at www.khronos.org. There exist various opensource libraries implementing OpenGL ES. You can find more opensource implementations at http://www.khronos.org/developers/resources/opengles/.
OpegGL for Qtopia
  • Starting with the 4.2 release, Qtopia Core supports OpenGL ES (OpenGL for Embedded Systems). To be able to use the OpenGL API in Qtopia Core, it must be integrated with the Q Window System (QWS). This is done by providing an EGL implementation, i.e., a native platform window system interface.

Reference:

create a branch in SVN repository

  1. svn mkdir svn://svnhost:3690/SvnRepos/CokiQt/branch -m "create an branch"
  2. svn cp svn://svnhost:3690/SvnRepos/CokiQt/trunk svn://svnhost:3690/SvnRepos/CokiQt/branch/2009-11-22 -m "copy trunk to branch"

2009-11-12

Tango Icon


Tango is nice. It provides not only a set of fee beautiful icons, but also his own guideline for the icon artist. Not bad! You can use inkscape or gimp to create your own icon. Both of them are open source software. Tango provides also online video to show how to do it. Great!

Another good source of icons, classified in different categories:
http://www.iconarchive.com/category

2009-11-09

QTimer in QThread

Multithreaded programming is also a useful paradigm for performing time-consuming operations without freezing the user interface of an application. QThread is the easy-to-use class in Qt allow user to implement things in a sperated thread.

"As of Qt4, you can use QThread to start your own event loops. This might sound somewhat uninteresting at first, but it means you can have your own signals and slots outside the main thread."

In GUI applications, the main thread is also called the GUI thread because it's the only thread that is allowed to perform GUI-related operations. You can implement, for instance, of a algorithm executed in a blocking way, into a sperated thread. Therefore, your GUI will not be frozen during the execution of algorithm. Then connect the main thread and algorithm thread by signal and slots. Namely, you can now emit a signal in one thread and receive it in a slot in a different thread.

The following is a simple example, in which a second-timer is wrapped in a QThread and a QWidget in main thread can start and stop the timer in any time.

//-----------------------------
CookingClock.cpp in timer thread
//-----------------------------


CookingClock::CookingClock(QObject *parent )
:QThread( parent)
,iSeconds_(10)
,iSecondsAccu_(0)
{

timer_.setInterval(1000); //second timer
connect( &timer_, SIGNAL(timeout()), this, SLOT(countSeconds()));

QThread::start();
}
void CookingClock::run()
{
exec();
}
void CookingClock::countSeconds()
{
iSecondsAccu_++;
emit( secondTicked(iSeconds_ - iSecondsAccu_));

if(iSecondsAccu_>=iSeconds_)
{
emit( timeIsUp());
timer_.stop();
}
}
void CookingClock::stop()
{
if(timer_.isActive())
{
timer_.stop();
}
}
void CookingClock::start()
{
iSecondsAccu_ = 0;
timer_.start();
}



//-----------------------------
CookingClockWidget.cpp in main thread
//-----------------------------



CookingClockWidget::CookingClockWidget(QWidget *parent)
:QWidget(parent)
, clock_(0)
{
clock_ = new CookingClock_v2();
QPushButton* pButtonStart = new QPushButton("start");
QPushButton* pButtonStop = new QPushButton("stop");
connect( pButtonStart, SIGNAL(clicked()), clock_, SLOT(start()));
connect( pButtonStop, SIGNAL(clicked()), clock_, SLOT(stop()));
connect( clock_, SIGNAL(secondTicked(int)), this, SLOT(print(int)));
QHBoxLayout* pLayout = new QHBoxLayout;
pLayout->addWidget(pButtonStart);
pLayout->addWidget(pButtonStop);

setLayout(pLayout);
}
void CookingClockWidget::print( int second)
{
qDebug("second : %d", second);
}




Reference:

2009-11-03

Strip Error during 'make install'

...
arm-linux-strip: /disk1/nfs/mini2440/root_qtopia/usr/local/coki/db/createDB.sh: File format not recognized
make: [install_db] Error 1 (ignored)
...

Strip is the command in linux to remove the information for debug, e.g symbols and line number, from object files, thereby reducing file sizes and freeing disk space. It can greatly reduce the size:

259920 coki.stripped
354524 coki.notstripped

The reason of these troublesome error is obvious: 'make install' tried to strip some other files than binary executables. Actually you can just ignored these error. If you are some kind of perfectionist, see this thread for the solution.

2009-11-02

Qt embedded font

  • Which setFont() works?
For a Qt Widget, as long as no special font has been set, or after setFont(QFont()) is called, this is either a special font for the widget class, the parent's font or (if this widget is a top level widget), the default application font.

  • How to make font smooth?
To be continued..
  • How to deploy font ?
See the artical "Deploying Qt for Embedded Linux Applications" http://doc.trolltech.com/4.6/deployment.html

Reference: