<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>A blog just like many others.</title>
	<atom:link href="http://blog.bigpixel.ro/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bigpixel.ro</link>
	<description>I&#039;m an angel. I can&#039;t fly. I&#039;m not to trust. I don&#039;t lie.I&#039;m not an angel. I can fall. I&#039;m a demon. I can cry. I&#039;m just a mirror.Or just the Time.To help your soul cry.Or shine..</description>
	<lastBuildDate>Tue, 07 Sep 2010 23:30:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Interposing calloc on Linux</title>
		<link>http://blog.bigpixel.ro/2010/09/08/interposing-calloc-on-linux/</link>
		<comments>http://blog.bigpixel.ro/2010/09/08/interposing-calloc-on-linux/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 23:09:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C plus plus]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://blog.bigpixel.ro/?p=245</guid>
		<description><![CDATA[The library interpose mechanism offers a nice way to replace some of the standard library functions with our own version for a wide range of purposes (analytics, debug,etc). So how this is happening? Long story short, you have to create a shared library which will be added to the list of preloaded libraries before the [...]]]></description>
			<content:encoded><![CDATA[<p>The library interpose mechanism offers a nice way to replace some of the standard library functions with our own version for a wide range of purposes (analytics, debug,etc). So how this is happening?</p>
<p>Long story short, you have to create a shared library which will be added to the list of preloaded libraries before the application itself loads. The shared library loader will load your library and any other libraries your application depends on and your application. When symbols are resolved, any symbols will get first resolved from your shared library (if defined there) then from standard library or other shared libraries your application uses. What this means?<br />
Well, if we have a function named <span style="font-family: monospace;">malloc</span> in our preloaded shared library, when the application gets loaded by the system, all references to <span style="font-family: monospace;">malloc</span> will be resolved to one in the preloaded shared library, instead of one from standard library, so basically, the application will use our version of <span style="font-family: monospace;">malloc</span>.<br />
Of course, having it replaced would not help too much if we don&#8217;t have a way to call the old (standard library provided) version of <span style="font-family: monospace;">malloc</span> when memory needs to be allocated. Fortunatelly, libdl offers a way to do this, in the form of <span style="font-family: monospace;">RTLD_NEXT</span> parameter. If you pass this parameter to the function when looking for the address of a symbol (function), it will return (as it says) the next symbol matching the name. In our case the one provided in the standard library.</p>
<p>For example if you create a shared library with the following two functions:</p>
<pre>
void *malloc( size_t size )
{
	static void * (*func)(size_t);

	printf("Entering %s\n", __FUNCTION__);

	if (!func)
	{
		// get reference to old (libc provided) malloc
		func = (void *(*)(size_t)) dlsym(RTLD_NEXT, "malloc");
	}

	printf("malloc(%d) is called\n", (int)size);

	// call old (libc provided) malloc
	void* ret = func(size);

	return ret;
}

void free( void* pointer )
{
	static void (*func)(void *);

	printf("Entering %s\n", __FUNCTION__);

	if (!func)
	{
		// get reference of old (libc provided) free
		func = (void (*)(void *)) dlsym(RTLD_NEXT, "free");
	}

	printf("free is called\n");

	// call old (libc provided) free
	func(pointer);
}
</pre>
<p>and add the library to list of preloaded libraries, it will display a list of calls to the <span style="font-family: monospace;">malloc</span> and <span style="font-family: monospace;">free</span> functions:</p>
<pre>
$ export LD_LIBRARY_PATH=yourinterposedlibrary.so
$ ls

Entering free
free is called
Entering malloc
malloc(41) is called
Entering free
free is called
....
</pre>
<p>Using this method, most of the functions from the standard library can be replaced with our own function. However one of them seems to be particulary difficult: <span style="font-family: monospace;">calloc</span>.<br />
Why this is more difficult than the other functions? Because turns out that on Linux the <span style="font-family: monospace;">dlsym</span> function which has to be used to retrieve the libc version of <span style="font-family: monospace;">calloc</span> uses itself this function, which ends up in infinite recursion (since it gets replaced by our own version wich gets called by <span style="font-family: monospace;">dlsym</span> which in turn calls <span style="font-family: monospace;">calloc</span> which is the interposed version which in turn calls <span style="font-family: monospace;">dlsym</span> which in turn &#8230; you get the ideea.</p>
<p>In order to fix this issue, seems like we need somehow not to call libc provided <span style="font-family: monospace;">calloc</span> until we get reference to libc provided <span style="font-family: monospace;">calloc</span>. Easier to say than do .. turns out we need to preallocate some memory wich gets returned when the <span style="font-family: monospace;">dlsym</span> function is called to retrieve the address of libc provided <span style="font-family: monospace;">calloc</span>. Once that is completed, we can get rid of the hack and use directly the libc provided <span style="font-family: monospace;">calloc</span> in order to perform <span style="font-family: monospace;">calloc</span> when required, from our interposed <span style="font-family: monospace;">calloc</span> function.</p>
<p>Seems complicated or at least not so attractive path to follow. I was wondering what happens if <span style="font-family: monospace;">calloc</span> returns NULL until we actually get the libc provided one? It is anyway used in ld.so, the ones who wrote it should take care of handling this situation (maybe failling to load the application itself?). Turns out, if we return NULL for the memory which needs to be allocated by <span style="font-family: monospace;">dlsym</span> function while we are trying to get the address of libc provided <span style="font-family: monospace;">calloc</span> works just fine (at least on my computer, with my version of Linux). Now things get a lot simpler for interposing <span style="font-family: monospace;">calloc</span>:</p>
<pre>
// our temporary calloc used until we get the address of libc provided
// one in our interposed calloc
static void* temporary_calloc(size_t x, size_t y)
{
	printf("empty calloc called\n");
	return NULL;
}

extern "C" void *calloc( size_t nelements, size_t elemetnSize)
{
	static void * (*calloc_func)(size_t, size_t) = 0;

	printf("Entering %s\n", __FUNCTION__);

	if (!calloc_func)
	{
		// before trying to get the libc provided
		// calloc, set the calloc function to the temporary
		// one returning NULL.
		calloc_func = temporary_calloc;

		// dlsym will call again this calloc in which we are,
		// but seems like it handles just fine if we are
		// returning NULL
		calloc_func = (void *(*)(size_t, size_t)) dlsym(RTLD_NEXT, "calloc");
	}

	void* ret = calloc_func(nelements, elemetnSize);

	return ret;
}
</pre>
<p>Adding this to the previous shared library and interposing it, will also display when the application calls <span style="font-family: monospace;">calloc</span> proving that interpose was successfull.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bigpixel.ro/2010/09/08/interposing-calloc-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android NDK and STLPort</title>
		<link>http://blog.bigpixel.ro/2010/09/05/android-ndk-and-stlport/</link>
		<comments>http://blog.bigpixel.ro/2010/09/05/android-ndk-and-stlport/#comments</comments>
		<pubDate>Sun, 05 Sep 2010 15:57:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[C plus plus]]></category>
		<category><![CDATA[NDK]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.bigpixel.ro/?p=240</guid>
		<description><![CDATA[As you know, the Android NDK offers a way to run native code on Android platform, however the standard template library is not included in NDK. While wandering on net looking for an easy solution to have my vector and my string in my native Android code without too much hassle, I have found a [...]]]></description>
			<content:encoded><![CDATA[<p>As you know, the Android NDK offers a way to run native code on Android platform, however the standard template library is not included in NDK.<br />
While wandering on net looking for an easy solution to have my vector and my string in my native Android code without too much hassle, I have found a post which contained a link to STLPort library, configured to run with Android:</p>
<p><a title="http://www.anddev.org/viewtopic.php?p=29939" href="http://www.anddev.org/viewtopic.php?p=29939">http://www.anddev.org/viewtopic.php?p=29939</a></p>
<p>If you are looking only for using the containers and so from STL, not using iostream &amp; company (which requires building the library itself), using this should be as easy as copying the header files in your project and start using it  as most of the functionalites come from template code which is contained in the header files.  So I have added the stlport folder with the header files to my project and tried to build the project with some STL testing code. However as soon as I start building it, I get this error:</p>
<pre>obj/xxxx.o: In function `~vector':
[...]/native/stlport/stl/_alloc.h:213: undefined reference to `std::__node_alloc::_M_deallocate(void*, unsigned int)'
</pre>
<p>Checking the _alloc.h file we see there isthis comment:</p>
<pre>// Default node allocator.
// With a reasonable compiler, this should be roughly as fast as the
// original STL class-specific allocators, but with less fragmentation.
// Define _STLP_USE_SIMPLE_NODE_ALLOC to use __new_alloc instead, which
// can be implemented without out-of-line functions.
</pre>
<p>Which probably means that by defining _STLP_USE_SIMPLE_NODE_ALLOC during the build probably will fix this issue. So I have added it to CFALGS, and seems like build is just fine, no more errors thrown.</p>
<p>More test need to be performed to see if everything is ok.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bigpixel.ro/2010/09/05/android-ndk-and-stlport/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deploying OSGI bundles automatically with Maven</title>
		<link>http://blog.bigpixel.ro/2010/07/29/deploying-osgi-bundles-automatically-with-maven/</link>
		<comments>http://blog.bigpixel.ro/2010/07/29/deploying-osgi-bundles-automatically-with-maven/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 19:02:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OSGI]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://blog.bigpixel.ro/?p=233</guid>
		<description><![CDATA[Working with bundles if kind of frustrating if you have to play with couple of them. Each time you build them, they need to be deployed in the container, and doing it by hand can be a tendentious job. Instead, a much better approach would be to change the build process to make this happen [...]]]></description>
			<content:encoded><![CDATA[<p>Working with bundles if kind of frustrating if you have to play with couple of them. Each time you build them, they need to be deployed in the container, and doing it by hand can be a tendentious job.</p>
<p>Instead, a much better approach would be to change the build process to make this happen automatically. For this there are couple of approaches, from which I find as  easiest to put in practice to use the container&#8217;s auto-deploy feature. Both Felix and GlassFish (these I&#8217;ve played with), but probably the others have this feature to monitor a folder for new jar files, and when they appear in the folder, they automatically deploy them. When bundles are removed from the folder, they are un-deployed from the container. If the jar file changes, it is either updated or redeployed.</p>
<p><strong>GlassFish</strong> already supports this deployment process. The folder where is watching for new bundles is located at:</p>
<pre>    glassfishv3/glassfish/domains/domain1/autodeploy/</pre>
<p>for .war applications and</p>
<pre>    glassfishv3/glassfish/domains/domain1/autodeploy/bundles</pre>
<p>for OSGI bundles.</p>
<p>In order to have this deployment active in <strong>Felix</strong>, you will need to install an additional OSGI module, called <em>File Install</em>. Can be downloaded from Felix&#8217;s web page. You just have to put it in</p>
<pre>&lt;felix install&gt;/bundles/</pre>
<p>folder and will be deployed next time container starts.<br />
The folder where Felix will watch for bundles can be configured using the  <em>felix.fileinstall.dir</em> property from the file located at:</p>
<pre>&lt;felix install&gt;/conf/config.properties</pre>
<p>Having these said, all what remains to be done is to configure the latest step of build to copy all the bundles which need to be deployed in the target folder where it will be deployed by the OSGI container. This step depends on what IDE, build system,etc are you using.</p>
<p>For users with <em>Maven</em>, you can add for example an additional module called let&#8217;s say deploy, who&#8217;s job would be to deploy the application. You will have to add all artifacts and dependencies which need to be installed in this module&#8217;s POM file, then you can add a build step like in the file bellow in order to have these artifacts copied in the target folder:</p>
<pre>&lt;!-- usual POM stuff --&gt;
...
&lt;build&gt;
  &lt;plugins&gt;
    &lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
      &lt;executions&gt;
        &lt;execution&gt;
          &lt;id&gt;copy-bundles&lt;/id&gt;
          &lt;phase&gt;validate&lt;/phase&gt;
          &lt;goals&gt;
            &lt;goal&gt;copy&lt;/goal&gt;
          &lt;/goals&gt;
          &lt;configuration&gt;
            &lt;artifactItems&gt;
              &lt;!--  Our bundles which need to be deployed --&gt;
              &lt;artifactItem&gt;
                &lt;groupId&gt;group id of your artifact&lt;/groupId&gt;
                &lt;artifactId&gt;id of your artifact&lt;/artifactId&gt;
                &lt;version&gt;version of your artifact&lt;/version&gt;
              &lt;/artifactItem&gt;
              &lt;artifactItem&gt;
                &lt;groupId&gt;group of your artifact&lt;/groupId&gt;
                &lt;artifactId&gt;id of your artifact&lt;/artifactId&gt;
                &lt;version&gt;version of your artifact&lt;/version&gt;
              &lt;/artifactItem&gt;
                 ...
            &lt;/artifactItems&gt;
            &lt;outputDirectory&gt;target folder where container looks for OSGI bundles&lt;/outputDirectory&gt;
            &lt;overWriteSnapshots&gt;true&lt;/overWriteSnapshots&gt;
          &lt;/configuration&gt;
        &lt;/execution&gt;
      &lt;/executions&gt;
    &lt;/plugin&gt;
  &lt;/plugins&gt;
&lt;/build&gt;</pre>
<p>Of course this can be made in many ways, this is one which worked for me. Feel free to  add comments and suggestions over the process</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bigpixel.ro/2010/07/29/deploying-osgi-bundles-automatically-with-maven/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cross-platform WaitForMultipleObjects like function?</title>
		<link>http://blog.bigpixel.ro/2010/05/17/cross-platform-waitformultipleobjects-like-function/</link>
		<comments>http://blog.bigpixel.ro/2010/05/17/cross-platform-waitformultipleobjects-like-function/#comments</comments>
		<pubDate>Mon, 17 May 2010 11:14:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C plus plus]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CrossPlatform]]></category>
		<category><![CDATA[Multithreading]]></category>
		<category><![CDATA[Synchronization]]></category>
		<category><![CDATA[Wait]]></category>
		<category><![CDATA[WaitForMultipleObjects]]></category>
		<category><![CDATA[WaitForSingleObject]]></category>
		<category><![CDATA[wxWindows]]></category>

		<guid isPermaLink="false">http://blog.bigpixel.ro/2010/05/17/cross-platform-waitformultipleobjects-like-function/</guid>
		<description><![CDATA[Sometimes we need to simultaneously wait to get notified on one of many things. For example, in a thread we could wait to get notiofied about main program requesting shutdown, or another thread leting us known that data to be processed is available. While in windows this could be elegantly solved with the WaitForMultipleObjects() call, [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes we need to simultaneously wait to get notified on one of many things. For example, in a thread we could wait to get notiofied about main program requesting shutdown, or another thread leting us known that data to be processed is available. While in windows this could be elegantly solved with the <span style="font-family: monospace;">WaitForMultipleObjects()</span> call, doing it cross-platform is another story.<br />
While in windows, <span style="font-family: monospace;">WaitForMultipleObjects()</span> call can wait on many object types (Threads, Sockets, condition variables, events, etc), sometimes it is enough to be able to wait only on one type, or only a subset of these. So maybe we could implement it only to signal that something happent?</p>
<p>A crude approach would be to use threads. For each object we are waiting on, we start a thread to wait for an event or timeout, and in the function itself, after threads are spawned, we simply wait to see if either one of threads notify us about it&#8217;s object being signaled, or we timeout. One of this approaches&#8217;s flaw is that for each object we are trying to wait on, uses a thread. But if we look carefully, we notice, this entire spawning threads,listening for getting notified fits perfectly into observer pattern. The caller needs to observe if something happens with the objects we are waiting on (they got signaled or not), in a given time interval, or if not, timeouts. The objects we are waiting on should also let known their observers if something happent to them (they got signaled)</p>
<p>So, considering wxWidgets, we could use it&#8217;s <span style="font-family: monospace;">wxCondition</span> class, which gives us a platform-independent condition variable. We need to have a object on which we could wait, which can be signaled,and which can be observed. <span style="font-family: monospace;">wxCondition</span> fits the bill,except .. noobservers. So let&#8217;s extend it, to allow objserver management:</p>
<pre>class Event: public wxCondition
{
	protected:
		std::list&lt; Event* &gt; mObservers;
		wxMutex mObserverMutex;

	public:
		void addObserver(Event* e)
		{
		        wxMutexLocker observerLock(mObserverMutex);
		        mObservers.push_back(e);
		}

		void removeObserver(Event* e)
		{
		        wxMutexLocker observerLock(mObserverMutex);
		        mObservers.remove(e);
		}
}
</pre>
<p>We also need to keep track if event is signaled or not. <span style="font-family: monospace;">wxCondition</span> does not give us this ability. Also, by reading <span style="font-family: monospace;">wxCondition</span> documentation, we see <span style="font-family: monospace;">wxCondition</span> will need a <span style="font-family: monospace;">wxMutex</span> to work, so let add these:</p>
<pre>class Event: public wxCondition
{
	protected:
		...
		bool mSignaled;
		wxMutex mMutex;

	public:
		Event()
		:wxCondition(mMutex),
		mSignaled(false)
		{
		}

		bool Signaled()
		{
			return mSignaled;
		}
}
</pre>
<p>For things to work as they should work, we need to rewrite <span style="font-family: monospace;">Signal()</span> to notify it&#8217;s observers and set m<span style="font-family: monospace;">Signaled </span>member variable, and also we should rewrite <span style="font-family: monospace;">Wait()</span> and <span style="font-family: monospace;">WaitTimeout()</span> to clear it, and of course these should work with the own <span style="font-family: monospace;">mMutex</span> mutex:</p>
<pre>class Event: public wxCondition
{
	public:
		...
		void Signal()
		{
		    wxMutexLocker lock(mMutex);
		    wxMutexLocker observerLock(mObserverMutex);

		    std::list&lt; Event* &gt;::iterator it = mObservers.begin();
		    while(it != mObservers.end())
		    {
		            (*it)-&gt;Signal();
		            it++;
		    }

		    wxCondition::Signal();
		    mSignaled = true;
		}

		wxCondError Wait()
		{
		    mMutex.Lock();
		    mSignaled = false;
		    return wxCondition::Wait();
		    mMutex.Unlock();
		}

		wxCondError WaitTimeout(unsigned long timeout)
		{
		    mMutex.Lock();
		    mSignaled = false;
		    return wxCondition::WaitTimeout(timeout);
		    mMutex.Unlock();
		}
}
</pre>
<p>At this moment we have a <span style="font-family: monospace;">Event</span> class which can be observed, and while observed, if it is signaled, will also signal it&#8217;s observer. So, how can we use this to implement <span style="font-family: monospace;">WaitForMultipleObjects()</span> function?<br />
First, let&#8217;s define some constants, to be in concordance with Windows code:</p>
<pre>#define WAIT_OBJECT_0 0
#define WAIT_TIMEOUT 0x00000102L
#define WAIT_ABANDONED 0x00000080L
#define WAIT_FAILED 0xFFFFFFFF
</pre>
<p>WAIT_OBJECT_0+number of signaled object is returned when one of the objects we are waiting on gets signaled.<br />
WAIT_OBJECT_TIMEOUT is returned if none of the objects we are waiting on are signaled.</p>
<p><span style="font-family: monospace;">WaitForMultipeObject()</span> gets as parameter number of objects it should wait on, an array with the objects, a boolean stating if it should wait on all objects or not, after how many milliseconds it should timeout, and if it is aleratable or not.<br />
Since waiting on all objects to get signaled is trivial to implement (we wait on all objects one after another until either all objects get signaled or we timeout), we will skip this part of implementation.<br />
The alertable flag we are not interested in, it is used only to specify if APC-s can be run or not while we are waiting on objects. Since we are not implementing APCs, we can simply ignore this flag.</p>
<pre>int WaitForMultipleObjectsEx(unsigned long numObjs, Event** objs,
                             bool waitAll, unsigned long timeoutMillis, bool alertable)
{
</pre>
<p>Note that we are passing an array of our <span style="font-family: monospace;">Event</span> class,not <span style="font-family: monospace;">wxCondition</span>!</p>
<p>Specification also states that if timeout period is 0, we should not wait on objects get signaled, but just check if they are signaled or not, and return. So let&#8217;s check that first inside the function:</p>
<pre>	if(timeoutMillis == 0)
	{
		for(int i(0);i < numObjs;i++)
			{
				return WAIT_OBJECT_0+i;
			}
		}

		return WAIT_TIMEOUT;
	}
</pre>
<p>If we have timeout specified and different than 0, we should start waiting until either one of objects get signaled, or we spend more than specified time in function (and then we return with timeout). So, we mark when we started to wait, create a observer event, and add it as observer to all events we are waiting on:</p>
<pre>	wxLongLong startmsec(wxGetLocalTimeMillis());

	// create a observer event and subscribe it as observer to all events we are waiting on
	Event observerEvent;

	for(int i(0);i < numObjs;i++)
	{
		objs[i] -> addObserver(&#038;observerEvent);
	}
</pre>
<p>Now, if one of our observed events get signaled, the observer event also gets signaled. Now let's use the remaining time from timeout to wait until observer gets notified or timeouts on wait:</p>
<pre>	wxLongLong usedmsec = wxGetLocalTimeMillis()-startmsec;

	// how much we should sleep?
	usedmsec = timeoutMillis-usedmsec;

	wxCondError r = observerEvent.WaitTimeout(usedmsec.ToLong());
</pre>
<p>After either one of observed events get signaled, or the required timeout milliseconds pass, <span style="font-family: monospace;">WaitTimeout()</span> function returns. We now have to check the return code. If returns timeout, we also return timeout. If returns no error, it means one of objects we were waiting on got signaled, so we have to find it's index in object array and return <span style="font-family: monospace;">WAIT_OBEJCT_0</span>+&lt;index of object signaled&gt;. In both cases, before returning, we should to deregister the observer event from the list of observed objects:</p>
<pre>
	if(wxCOND_TIMEOUT == r)
	{
		// if wait returned timeout, we also return timeout
		return WAIT_TIMEOUT;
	}
	else if(wxCOND_NO_ERROR == r)
	{
		// if wait succeeded, we unregister the observer event from observed events
		// meanwhile we check to see if object got signaled or not, to find out the
		// index of the signaled object.

		bool gotSignaledObject = false;

		// we should return WAIT_OBJECT_0 + index of signaled object, so let's start
		// at WAIT_OBJECT_0
		int res = WAIT_OBJECT_0;

		for (int i(0);i < numObjs;i++)
		{
			if (!gotSignaledObject &#038;&#038; objs[i] -> Signaled())
			{
				// got the index of signaled object.
				gotSignaledObject = true;
				res += i;
			}

			objs[i] -> removeObserver(&#038;observerEvent);
		}

		return res;
	}

	return WAIT_FAILED;
}
</pre>
<p>This is all. So, let's see a simple application which test the functionality:</p>
<pre>class MyApp: public wxApp
{
	public:
		bool OnInit();
} myApp;

// the events we will wait on
Event e1, e2;

class T : public wxThread
{
	public:
		void* Entry()
		{
			printf("Thread started\n");
			usleep(10000);
			printf("Event 1 signaled\n");
			e1.Signal();
			return 0;
		}
};

bool MyApp::OnInit()
{
	Event e;
	T* t = new T();
	t-&gt;Create();
	t-&gt;Run();

	Event* evs[]={&amp;e1,&amp;e2};
	printf("Waiting \n");
	int res = WaitForMultipleObjectsEx(2, evs,false, 2000,false);
	printf("Completed %d\n", res);

	return true;
}

IMPLEMENT_APP(MyApp)
</pre>
<p><em>Note: Code provided here is for educational purposes. It cannot be used  in any projects, specially commercial, without my consent.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bigpixel.ro/2010/05/17/cross-platform-waitformultipleobjects-like-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handling / identifying multiple clients with QTcpServer</title>
		<link>http://blog.bigpixel.ro/2010/05/06/handling-identifying-multiple-clients-with-qtcpserver/</link>
		<comments>http://blog.bigpixel.ro/2010/05/06/handling-identifying-multiple-clients-with-qtcpserver/#comments</comments>
		<pubDate>Thu, 06 May 2010 09:34:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C plus plus]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Client]]></category>
		<category><![CDATA[Qt]]></category>
		<category><![CDATA[QTcpServer]]></category>
		<category><![CDATA[QTcpSocket]]></category>
		<category><![CDATA[Server]]></category>

		<guid isPermaLink="false">http://blog.bigpixel.ro/?p=203</guid>
		<description><![CDATA[There are various examples of client-server applications in the Qt documentation, some of them being able to handle more than one client. While is convenient to have an event signalled each time something happens on one of our connected client-sockets, sometimes processing takes more than just answering back. Sometimes we need to be able to [...]]]></description>
			<content:encoded><![CDATA[<p>There are various examples of client-server applications in the Qt documentation, some of them being able to handle more than one client. While is convenient to have an event signalled each time something happens on one of our connected client-sockets, sometimes processing takes more than just answering back. Sometimes we need to be able to connect our socket on which the event occurs,with some other informations related to that client, and the processing could imply informations being sent from / for other clients too.<br />
Regarding this, however seems like none of examples is showing how to identify for what client the data is coming, or more exactly how to make an association between the socket the server is receiving data on, and the corresponding client related data.</p>
<p>I have run couple of tests about what happens in various situations when client connects,disconnects,etc and found out the following:</p>
<ul>
<li> when a new connection is made to server, <em>QTcpServer</em> will emit a <em>newConnection() </em>signal, and then, for the connected client we can get back a <em>QTcpSocket</em> instance, using <em>nextPendingConnection()</em>.</li>
<li>the <em>QTcpSocket</em> contains the socket descriptor used for communication.</li>
<li>hen there is data to be read or data was written to socket, <em>QTcpServer</em> emits signals related to this, and the sender of the signal is a <em>QTcpSocket</em> instance. One could get it by converting the sender() to <em>QTcpSocket*</em>. For a given client, the instance of <em>QTcpSocket</em> will be every time the same.</li>
<li>if previous client disconnected and a new client connects, although it is possible to have the same socket descriptor used for communication, the instance of <em>QTcpSocket</em> returned by n<em>extPendingConnection()</em>, and subsequently used in signalling events, will be different one.</li>
</ul>
<p>Because for each client gets a different and very own QTcpSocket instance, and has this instance while disconnects, one simple approach would be to use this QTcpSocket instance to identiy for what client the event is happening.</p>
<p>But how can we do this?</p>
<p>First, let&#8217;s assume we have a <em>Server</em> class, which has a <em>QTcpServer</em> member variable with it&#8217;s signals (<em>newConnection()</em>) connected to a slot in <em>Server</em>.<br />
Also, let&#8217;s assume our client-related information is stored in a class <em>Client</em>.<br />
For identifying on which <em>Client</em> we get data/data was sent/ error occurred, we simply use a simple <em>QMap</em> stored as a member variable, which maps Q<em>TcpSocket*</em> to our <em>Client</em> instance.</p>
<pre>QMap&lt;QTcpSocket*, Client*&gt; mClients;</pre>
<p>When a new connection arrives on our <em>QTcpServer</em>, the <em>Server</em> slot we set up gets called. Here we retrieve the <em>QTcpSocket</em>, create our <em>Client</em> instance, connect some signals, and store it in our map for later identification:</p>
<pre>// connected to mTcpServer::onNewConnection()
// gets called each time a new connection arrives on server
void Server::NewConnection()
{
   QTcpSocket* connection = mServerNextPendingConnection();

   if(connection)
   {
       Client* client = new Client();

       // connect signals to handler slots

       // we assume Server has a slot Error(QAbstractSocket::SocketError))
       connect(connection, SIGNAL(error(QAbstractSocket::SocketError)),
          this, SLOT(error(QAbstractSocket::SocketError));

       // we assume Server has a slot readyRead()
       connect(connection, SIGNAL(readyRead()), this, SLOT(readyRead()));

       //we assume Server has a slot disconnected()
       connect(connection, SIGNAL(disconnected()), this, SLOT(disconnected()));

       //store the TcpSocket,client pair in map
       mClients[connection] = client;
   }
}</pre>
<p>When data arrives on socket, the <em>TcpSocket</em> for the given connection will notify server by calling the slot we set up in the incoming connection. Bellow is how you can retrieve on which client this happened:</p>
<pre>// gets called when data is available on one of our client QTcpSockets
void Server::readyRead()
{
    // retrieve our sender QTcpSocket
    QTcpSocket* connection = qobject_cast(sender());

    // get our Client
    Client* c = mClients[connection];

    // ...
    // do the processing you have to do with the data comming for this
    // client
    // ...
}</pre>
<p>We can retrieve the <em>Client</em> on same way for errors, or when gets disconnected, as these also get their own signal, and the sender for the signal will be the associated <em>QTcpSocket.</em></p>
<p>As a side note, when <em>disconnected()</em> slot is called, the returned <em>QTcpSocket</em> instance, although it is the same one for a given client as the one used in read and write, will have the underlying socket descriptor set to -1. This means that although we could use socket descriptor as a key in our client map when event such as there is data to be read or data was written to identify the client, on disconnect we cannot figure out for what client we need to free it&#8217;s data and resources.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bigpixel.ro/2010/05/06/handling-identifying-multiple-clients-with-qtcpserver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Selective slot activation in Qt, using signal-slot mechanism</title>
		<link>http://blog.bigpixel.ro/2010/04/29/selective-slot-activation-in-qt-using-signal-slot-mechanism-3/</link>
		<comments>http://blog.bigpixel.ro/2010/04/29/selective-slot-activation-in-qt-using-signal-slot-mechanism-3/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 10:00:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C plus plus]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Qt]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Event Handling]]></category>
		<category><![CDATA[Signals]]></category>
		<category><![CDATA[Slots]]></category>

		<guid isPermaLink="false">http://blog.bigpixel.ro/2010/04/29/selective-slot-activation-in-qt-using-signal-slot-mechanism-3/</guid>
		<description><![CDATA[Sometimes you are bound to use a unified signal-slot for passing various informations between couple of objects interacting with each other. While the information needs to be of different type, sometimes you are bound to same unified mechanism for a variety of objects, because having one signal-slot for each object type being passed around is [...]]]></description>
			<content:encoded><![CDATA[<div align="justify">
<p>Sometimes you are bound to use a unified signal-slot for passing various informations between couple of objects interacting with each other. While the information needs to be of different type, sometimes you are bound to same unified mechanism for a variety of objects, because having one signal-slot for each object type being passed around is simply not viable.</p>
<p>Example:<br />
&nbsp;&nbsp;&nbsp; In a hierarchical model-view-controller architecture, controllers on diverse layers can communicate with eachother by events. One controller can handle a event, bubble it up to it&#8217;s parent controller, or send it down to it&#8217;s child controllers. Implementing one handling method for each possible event passed around is not viable, since this means all controllers need to implement that method. Also, adding new events to the system is hard, because you have to rewrite all controllers to handle that new event type, or to pass it around.<br />
Since one event handler per event type is not viable, another approach would be to have a generic event handler mechanism, which handles all the event types, and have different event types subclass a parent Event, and in the event handler, according to event sent as parameter, to respond to given events, if their type is appropiate.</p>
<p>With Qt this could be implemented by adding to each object a event(Event*) signal and fireEvent(Event*) slot, and all interested parties register to event(Event*) signal, and get notified when fireEvent() is called. One downside of this approach is that all registered slots get called, even if they are not interested in the given event. Even worse,the slots who are not interested in event still have to check if the event is an event they are interested in, just to realize the event is not of their interest.</p>
<p>So, we need to somehow fire events, but to notify only those events who are interested in a given event type. And of course, to rely on Qt&#8217;s cool signal-slot mechanism.</p>
<p>First, we declare a base Event class, instance of which gets passed around. Later, for new events, we just extend this base class, and pass instance of the new class to signal-slot mechanism.</p>
<p>Then, we need to decide how we gonna select what event we want to react on. For example, we can filter events by class name. So, we need a mechanism which will allow us to return a type of event either from an instance of object, or statically from class. I have created a template to help with this (and also allow easy change later if I want to replace it with something else):
<pre>template &lt;class T&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; class EventHelper
        {
       &nbsp;&nbsp;&nbsp; public:
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static QString type()
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return T::staticMetaObject.className();
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static QString type(QObject *e)
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return e-&gt;metaObject()-&gt;className();
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
        };</pre>
<p>We can use this either by calling it with a class parameter like:
<pre>QString type = EventHelper&lt;AppEvent&gt;::type()
</pre>
<p>or with an instance of Event or another class extending Event, like:
<pre>QString type = EventHelper&lt;Event&gt;::type(instance of event here)
</pre>
<p>In order to route events, we create a EventRouter object. We will use this object to register various objects interested in handling events, and we will fire events using this EventRouter class. When firing events, EventRouter will take care of signaling only slots who are interested in the given event type.</p>
<p>For registering objects interested in given event type:
<pre>eventRouter.registerTarget(QString&amp; type, Target* t)
</pre>
<p>where Target is a class which has slot for handling event, like
<pre>void handleEvent(Event* e)
</pre>
<p>When signaling event, EventRouter should take care of signaling only the interested parties. But how can this be accomplished, while still using the Qt&#8217;s event / slot mechanism?<br />
One approach would be to use an intermediate object, as a relay object. For each event type we register Targets for, EventRouter holds a helper object, to which actually connects the signal and slot of the EventRouter and Target. So, the sole purpose of helper object is to relay the event to it&#8217;s Target&#8217;s:
<pre>class EventRouterHelper : public QObject
{
&nbsp;&nbsp;&nbsp; Q_OBJECT

&nbsp;&nbsp;&nbsp; public:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EventRouterHelper(QObject* parent = NULL);

&nbsp;&nbsp;&nbsp; signals:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void event(Event* e);

&nbsp;&nbsp;&nbsp; public slots:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void fireEvent(Event* e) { emit event(e);}
};
</pre>
<p>All Target&#8217;s handleEvent slots get registered to EventRouteHelper&#8217;s event() signal. This allows using Qt&#8217;s mechanism to signal event to all Targets.</p>
<p>So EventRouter&#8217;s remaining job is to wire up everything and according to the type of signaled event, to retrieve the correct EventRouterHelper object and use it to fire the event to intersted Targets:
<pre>class EventRouter : public QObject
{
&nbsp;&nbsp;&nbsp; Q_OBJECT

&nbsp;&nbsp;&nbsp; public:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EventRouter();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ~EventRouter();

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void registerTarget(const QString&amp; clazz, Target *target );
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void unregisterTarget(Target *p);

&nbsp;&nbsp;&nbsp; public slots:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void fireEvent(Event* e);

&nbsp;&nbsp;&nbsp; protected:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QMap&lt;QString, EventRouterHelper*&gt; mRoutes;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QMap&lt;Target*, EventRouterHelper*&gt; mRouteObjects;
};
</pre>
<p>When registering Target, we check if we have a helper object for this event type. If we don&#8217;t have yet, then create one, otherwise hook up the signal/slots as required:
<pre>void EventRouter::registerTarget(const QString &amp;clazz, Target *target)
{
&nbsp;&nbsp;&nbsp; EventRouterHelper *o = mRoutes[clazz];

&nbsp;&nbsp;&nbsp; // if we don't have helper object, create one
&nbsp;&nbsp;&nbsp; if (o == NULL)
&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // create an EventRouterHelper which we use to hook onto
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // the signals and events
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; o = new EventRouterHelper();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mRoutes[clazz] = o;
&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp; // now connect up all signals and slots between target and event helper
&nbsp;&nbsp;&nbsp; connect(o, SIGNAL(event(Event*)),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; target, SLOT(handleEvent(Event*)));
&nbsp;&nbsp;&nbsp; mRouteObjects[target] = o;
}
</pre>
<p>Firing event is easy, just get the helper object for the given class, then fire the event. Because all Target slots are registerted on helper object&#8217;s signal, all Targets get notified automatically:
<pre>void EventRouter::fireEvent(Event *e)
{
&nbsp;&nbsp;&nbsp; // get class of event
&nbsp;&nbsp;&nbsp; QString clazz = EventHelper&lt;Event&gt;::type(e);

&nbsp;&nbsp;&nbsp; // get helper object
&nbsp;&nbsp;&nbsp; EventRouterHelper *r = mRoutes[clazz];

&nbsp;&nbsp;&nbsp; if(r)
&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r-&gt;fireEvent(e);
&nbsp;&nbsp;&nbsp; }
}
</pre>
<p>Source of sample application can be downloaded from <a href="http://blog.bigpixel.ro/wp-content/uploads/2010/04/selectivesignaltar.gz">here</a></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.bigpixel.ro/2010/04/29/selective-slot-activation-in-qt-using-signal-slot-mechanism-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Storing pointer in QVariant</title>
		<link>http://blog.bigpixel.ro/2010/04/23/storing-pointer-in-qvariant/</link>
		<comments>http://blog.bigpixel.ro/2010/04/23/storing-pointer-in-qvariant/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 08:39:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C plus plus]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Qt]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Templates]]></category>

		<guid isPermaLink="false">http://blog.bigpixel.ro/?p=180</guid>
		<description><![CDATA[You can store many types of data into QVariant, like int, string, etc. Also you can store pointers, but only pointers to void (void*). But what happens when you want to set a property of a object to a instance of class, with setProperty, and after that, you want to retrieve that property? QVariant accepts [...]]]></description>
			<content:encoded><![CDATA[<p>You can store many types of data into QVariant, like int, string, etc. Also you can store pointers, but only pointers to void (void*).<br />
But what happens when you want to set a property of a object to a instance of class, with setProperty, and after that, you want to retrieve that property? QVariant accepts void*, so you can do something like the following, to store it into QVariant:</p>
<pre>
QVariant v = qVariantFromValue((void *) yourPointerHere);
</pre>
<p>and then something like this, in order to retrieve it back from QVariant:</p>
<pre>yourPointer = (YourClass *) v.value&lt;void *&gt;();</pre>
<p>Having this done each time you have to get the property or set the property is a bit tendentious. We can make this more friendly, using templates:</p>
<pre>
template &lt;class T&gt; class VPtr
{
public:
    static T* asPtr(QVariant v)
    {
	return  (T *) v.value&lt;void *&gt;();
    }

    static QVariant asQVariant(T* ptr)
    {
	return qVariantFromValue((void *) ptr);
    }
};
</pre>
<p>So how do you use this? Assuming you have a class MyClass, and you want to store a pointer to this class as a property of a QWidget, or any QObject, or you want to convert it to QVariant, you can do the following:</p>
<pre>
MyClass *p;
QVariant v = VPtr&lt;MyClass&gt;::asQVariant(p);

MyClass *p1 = VPtr&lt;MyClass&gt;::asPtr(v);
</pre>
<p>I think this is more developer friendly than having to write each time those conversion code sequences.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bigpixel.ro/2010/04/23/storing-pointer-in-qvariant/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Distributed flam3 rendering</title>
		<link>http://blog.bigpixel.ro/2010/04/14/disributed-flam3-rendering/</link>
		<comments>http://blog.bigpixel.ro/2010/04/14/disributed-flam3-rendering/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 12:32:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Distributed]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[fractal]]></category>

		<guid isPermaLink="false">http://blog.bigpixel.ro/?p=169</guid>
		<description><![CDATA[Flames look nice, but takes lot of time to render them, specially in high resolution and quality. One way of speeding up rendering is to distribute rendering on various computers. The main idea is to have a central server onto which one can upload various flames to be rendered. The rendering of these flames is [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Flames look nice, but takes lot of time to render them, specially in high resolution and quality.<br />
One way of speeding up rendering is to distribute rendering on various computers.<br />
The main idea is to have a central server onto which one can upload various flames to be rendered. The rendering of these flames is then distributed on various computers which run&nbsp; as render slaves, each rendering one part of the image. When all parts are completed, then either the master or one of the slaves assembles the final image from various parts.<br />
There are two issues related to this:</p>
<ul>
<li style="text-align: justify;">		flam3 cannot render only one part of the image, although large images can be rendered in stripes to overcome out of memory error. Still, as it is originally, either with stripes or not, flam3-render can render one image only, not part of the image.</li>
<li style="text-align: justify;">		somehow the file location need to be resolved. the render slaves need the information describing what to render (the .flame3 file), and they need to store somewhere the result of their rendering. This means between the server and render slaves we need a shared file system,where/from where both can read/write, or the server need to act also as a file server, allowing slaves to upload render results and download render informations.</li>
</ul>
<p style="text-align: justify;">For now, I have changed flam3 package to allow partial rendering only.<br />
In order to ease the parameter passing, I have modified the code that now settings can be passed either through environment variables, or through command line arguments. All environment variables can be set from command line using <font face="monospace">[name]=value</font> format, where <font face="monospace">[name]</font> is the name of the environment variable. Please note, command line settings have higher priority over their environment counterparts.</p>
<p>Also, couple of new options were added, for rendering only part of the flame:</p>
<ul>
<li style="text-align: justify;">
		<b>&#8211;help</b> &#8211; display the help</li>
<li style="text-align: justify;">		<b>minstrip=[number]</b> &#8211; the minumum strip number to be rendered.</li>
<li style="text-align: justify;">		<b>maxstrip=[number]</b> &#8211; the maximum strip to be rendered.</li>
<li style="text-align: justify;">		<b>strip=[number] </b>- the strip to be rendered.</li>
</ul>
<p style="text-align: justify;">Please note:</p>
<ul>
<li style="text-align: justify;">
		for all this parameters, you will have to set nstrips value. Also, the value of these parameters should between 0 and <font face="monospace">nstrips</font>.</li>
<li style="text-align: justify;">		Also, if <font face="monospace">minstrip</font> and <font face="monospace">maxstrip</font> is provided, then render is between <font face="monospace">minstrip</font> inclusive and <font face="monospace">maxstrip</font>-1 inclusive. (<font face="monospace">minstrip</font>=0 and <font face="monospace">maxstrip</font>=1 will render strip 0, <font face="monospace">minstrip</font>=1 <font face="monospace">maxstrip</font>=1 will render no strips)</li>
<li style="text-align: justify;">		providing <font face="monospace">strip=[number]</font> will render only the given strip.</li>
</ul>
<p style="text-align: justify;">Sources can be downloaded from here: <a href="http://blog.bigpixel.ro/wp-content/uploads/2010/04/flam3tar.gz">flam3.tar.gz</a></p>
<p style="text-align: justify;">
Next step would be the server and render slaves.</p>
<div class="zemanta-pixie" style="text-align: justify;">	<img alt="" class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=1a59ef85-c440-886b-9eda-a1dc240471d8" /><br />
	&nbsp;</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.bigpixel.ro/2010/04/14/disributed-flam3-rendering/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Android full screen applications</title>
		<link>http://blog.bigpixel.ro/2010/04/10/android-full-screen-applications/</link>
		<comments>http://blog.bigpixel.ro/2010/04/10/android-full-screen-applications/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 22:19:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[NDK]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Full screen]]></category>

		<guid isPermaLink="false">http://blog.bigpixel.ro/?p=167</guid>
		<description><![CDATA[If you want to have your application full-screen, to have removed even the window title &#38; everything else, you have to add the following to your activity creation code: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // make window full screen requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); .. do your usual initialization stuff }]]></description>
			<content:encoded><![CDATA[<p>If you want to have your application full-screen, to have removed even the window title &amp; everything else, you have to add the following to your activity creation code:</p>
<pre>
protected void onCreate(Bundle savedInstanceState)
{

    	super.onCreate(savedInstanceState);

    	// make window full screen
    	requestWindowFeature(Window.FEATURE_NO_TITLE);
    	getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    			WindowManager.LayoutParams.FLAG_FULLSCREEN);

 .. do your usual initialization stuff
 }
</pre>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=ba247945-840e-85e1-8ebe-b4281c4a8741" /></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.bigpixel.ro/2010/04/10/android-full-screen-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NDK Resource loading and OpenGL on Nexus One</title>
		<link>http://blog.bigpixel.ro/2010/04/09/resource-loading-and-opengl-on-nexus-one/</link>
		<comments>http://blog.bigpixel.ro/2010/04/09/resource-loading-and-opengl-on-nexus-one/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 09:26:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[NDK]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.bigpixel.ro/?p=155</guid>
		<description><![CDATA[Here are the oinformations repored by the same application when running on Nexus One: Version: OpenGL ES-CM 1.1Vendor: QualcommRenderer: AdrenoOpengl extensions: GL_AMD_compressed_3DC_texture GL_AMD_compressed_ATC_texture GL_ARB_texture_env_combine GL_ARB_texture_env_dot3 GL_ARB_texture_mirrored_repeat GL_ARB_vertex_buffer_object GL_ATI_compressed_texture_atitc GL_ATI_texture_compression_atitc GL_EXT_blend_equation_separate GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_stencil_wrap GL_OES_EGL_image GL_OES_blend_equation_separate GL_OES_blend_func_separate GL_OES_blend_subtract GL_OES_compressed_ETC1_RGB8_texture GL_OES_compressed_paletted_texture GL_OES_draw_texture GL_OES_extended_matrix_palette GL_OES_framebuffer_object GL_OES_matrix_palette GL_OES_point_size_array GL_OES_point_sprite GL_OES_read_format GL_OES_stencil_wrap GL_OES_texture_cube_map GL_OES_texture_env_crossbar GL_OES_texture_mirrored_repeat Unfortunately resource loading as [...]]]></description>
			<content:encoded><![CDATA[<p>Here are the oinformations repored by the same application when running on Nexus One:</p>
<p><b>Version:</b> OpenGL ES-CM 1.1<br /><b>Vendor:</b> Qualcomm<br /><b>Renderer:</b> Adreno<br /><b>Opengl extensions: <br /></b>
<ul>
<li>GL_AMD_compressed_3DC_texture </li>
<li>GL_AMD_compressed_ATC_texture </li>
<li>GL_ARB_texture_env_combine </li>
<li>GL_ARB_texture_env_dot3 </li>
<li>GL_ARB_texture_mirrored_repeat </li>
<li>GL_ARB_vertex_buffer_object </li>
<li>GL_ATI_compressed_texture_atitc </li>
<li>GL_ATI_texture_compression_atitc </li>
<li>GL_EXT_blend_equation_separate </li>
<li>GL_EXT_blend_func_separate </li>
<li>GL_EXT_blend_minmax </li>
<li>GL_EXT_blend_subtract </li>
<li>GL_EXT_stencil_wrap </li>
<li>GL_OES_EGL_image </li>
<li>GL_OES_blend_equation_separate </li>
<li>GL_OES_blend_func_separate </li>
<li>GL_OES_blend_subtract </li>
<li>GL_OES_compressed_ETC1_RGB8_texture </li>
<li>GL_OES_compressed_paletted_texture </li>
<li>GL_OES_draw_texture </li>
<li>GL_OES_extended_matrix_palette </li>
<li>GL_OES_framebuffer_object </li>
<li>GL_OES_matrix_palette </li>
<li>GL_OES_point_size_array </li>
<li>GL_OES_point_sprite </li>
<li>GL_OES_read_format </li>
<li>GL_OES_stencil_wrap </li>
<li>GL_OES_texture_cube_map </li>
<li>GL_OES_texture_env_crossbar </li>
<li>GL_OES_texture_mirrored_repeat </li>
</ul>
<p>Unfortunately resource loading as shared library seems to not work, it requires some more investigations why this happens (Theoretically it should work, maybe there are some differences related to shared library path..)</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=de17bf77-3f85-8782-8bb5-942af24597e3" /></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.bigpixel.ro/2010/04/09/resource-loading-and-opengl-on-nexus-one/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
