<?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>soledad penadés &#187; opengl</title>
	<atom:link href="http://soledadpenades.com/tag/opengl/feed/" rel="self" type="application/rss+xml" />
	<link>http://soledadpenades.com</link>
	<description>repeat 4[fd 100 rt 90]</description>
	<lastBuildDate>Sun, 29 Jan 2012 23:03:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Google I/O 2011, day 2</title>
		<link>http://soledadpenades.com/2011/05/14/google-io-2011-day-2/</link>
		<comments>http://soledadpenades.com/2011/05/14/google-io-2011-day-2/#comments</comments>
		<pubDate>Sat, 14 May 2011 04:00:57 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[google analytics]]></category>
		<category><![CDATA[googleio]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[san francisco]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=3514</guid>
		<description><![CDATA[I woke up quite late today-at 7.30. But got quickly in motion: the keynote was at 9.30h, so I didn&#8217;t have as much time for slacking as yesterday! It was funny trying to identify more fellow attendees on the way to the Moscone center. None of them got their badges out, but the backpacks and [...]]]></description>
			<content:encoded><![CDATA[<p>I woke up quite late today-at 7.30. But got quickly in motion: the keynote was at 9.30h, so I didn&#8217;t have as much time for slacking as yesterday! It was funny trying to identify more fellow attendees on the way to the Moscone center. None of them got their badges out, but the backpacks and messenger bags were extremely telling in this area of financial suitcases :-)<br />
<span id="more-3514"></span><br />
Once in, I went directly upstairs, to the 2nd level, where I knew was some extra breakfast seating&#8230; which was way more relaxed than the one on the ground floor (or &#8220;level 1&#8243; as they called it). My strategy worked, and I was able to grab a couple of strange tasting pastries. While I was having <em>the breakkie</em>, someone who looked familiar appeared, accompanied by a collaborator, both closely followed by someone else whom I couldn&#8217;t identify either. The first two sat down on a table further away from me, and the follower sat there too, but at an strategic distance, while he kept talking and looking enthusiastic and the others seemed very disinterested. Then I saw the biggest guy&#8217;s name and understood everything: it was Michael Arrington and (probably) one of his <em>pupils</em>, and the third guy was trying to convince them to talk about his website at all costs. Though it didn&#8217;t seem like working as they just replied random <q>Huh-oh&#8230; Uhm&#8230; really? OK</q> from time to time&#8211;when they weren&#8217;t looking elsewhere. A bit sad (and creepy).</p>
<p>Finally, the keynote room opened its doors, and the considerable amounts of people waiting were able to slowly get in. I also noticed there was a lot more cameras and media people than yesterday, and I couldn&#8217;t but keep asking myself whether the journalists room/area had already been there yesterday, but I couldn&#8217;t remember.</p>
<p>In the hall, this time I got a seat, and not in the middle of a lot of people, so it was great. There wasn&#8217;t any countdown as in the first keynote, but there were lots of people taking pictures anyway, this time imitating the same gesture they do with their phones, but putting the tablets they got yesterday in the air instead, which makes it a bit embarrassing or annoying, depending on the moment.</p>
<p>The <a href="http://www.google.com/events/io/2011/sessions/google-chrome-day-2-keynote-from-google-i-o.html">keynote</a> started after having been politely asked to turn off &#8220;any hotspots&#8221; several times. I hadn&#8217;t used any of those before, but it seems portable hotspots are a big thing in the States. Or at least at the I/O&#8230; Anyway, it didn&#8217;t seem to work, since I still could find <em>lots</em> of wifi networks with my phone.</p>
<p>Vic appeared on stage again and quickly handed over to Sundar Pichai, which way less enthusiastic than Vic, and that was a bit of a downer. He described various nice feats achieved by the Chrome team since the last I/O, then handed to another guy who described more particular details, then that guy left the stage, and the cycle repeated. From all of what they announced, it seemed interesting they were just going to charge 5% for in-app payments&#8230; and made me wonder whether they would do the same with the Android market at some point. Now <em>that</em> would be cool! ;-)</p>
<p>There was the Chromebook and their pricing that got everyone clapping&#8230; well, except probably me. I couldn&#8217;t stop wondering whether they had considered the privacy implications of copying everything &#8220;to the cloud&#8221;, specially when we&#8217;re talking about corporate and educational environments migrating to use Chromebooks. And what with their customer support!? If it&#8217;s as good as the support for their other projects&#8230; (and I&#8217;ll leave it there) .</p>
<p>A good thing was that those machines will be jailbreakable. That always makes hardware more attractive (and relevant, in my opinion). But I can also foresee it doesn&#8217;t guarantee anything, specially if they get the same closed binary drivers issues we&#8217;re getting with Android. Which they will probably get, since they don&#8217;t have the latest word on the hardware those computers will be using, and it&#8217;ll be completely up to the vendors to integrate open source hardware or just proprietary stuff as usual.</p>
<p>Later the guy from that Angry birds game came up on stage to explain how <em>awesome</em> the newly ported to Chrome version was, and during all the time he was on stage praising the game and trying to convince <em>me</em> to play it (since it seems like I&#8217;m the only one who has yet to play it) I couldn&#8217;t stop wondering what took them that long to port it. My point is: since it worked on mobile phones, which are underpowered in comparison with full-fledged computers, there was no reason it wouldn&#8217;t work on a normal computer. It sounded like a bad excuse. Specially since mrdoob made his <a href="http://mrdoob.com/projects/chromeexperiments/ball_pool/">Chrome ball pool</a> and <a href="http://mrdoob.com/projects/chromeexperiments/google_gravity/">Google Gravity</a> experiments a couple of years ago already, and both used Box2D, with Javascript, way before v8 and jagermonkey were as fast as they are now. I truly didn&#8217;t understand anything, but I was surrounded by a mass of hysterical people and they looked at me and wondered why I wasn&#8217;t clapping like crazy too (and at the end I didn&#8217;t).</p>
<p>Then Aaron Koblin did a short intervention presenting a sneak peek for the <a href="http://ro.me">Rome</a> project, and then explained they had used <a href="https://github.com/mrdoob/three.js">three.js</a> and <a href="http://mrdoob.com">mrdoob</a> was working on the project too, and the die-hard fans in the front rows just went WOOOW YEEES WOHOOO crazy-crazy. It seems being honest about the libraries you&#8217;re using earns you lots of good karma ;-)</p>
<p>And when they finally announced they were going to send a Chromebook to every attendee in June&#8211;when it was a physical reality and in production, I thought the ceiling was going to collapse and the entire hall was going to fall down. Yesterday&#8217;s tablet announcement effect was <em>nothing</em> compared to this!</p>
<p>I immediately moved to another floor for Chris Pruett&#8217;s talk about building &#8220;<a href="http://www.google.com/events/io/2011/sessions/building-aggressively-compatible-android-games.html">aggressively compatible games for Android</a>&#8220;. I&#8217;m not currently writing games but I&#8217;d like my apps to be <em>playful</em> and compatible with as many devices as possible, so I believe those were two valid reasons for attending the session! Some of its contents weren&#8217;t new to me, but there were some tips that I hadn&#8217;t heard of. For example, if a device doesn&#8217;t comply with the compatibility guidelines (and hence doesn&#8217;t pass the set of automated tests), Google won&#8217;t allow it to have the Google applications such as Maps, Market, etc. Which in other words means that if a phone has the Market application, it complies with a minimum set of requisites. It was also funny that Chris&#8217;s first words for the audience were &#8220;Hey folks&#8221;. Very looneytunesque, I loved it!</p>
<p>It was then time for a super very early lunch, since it was the only free time I&#8217;d had today between interesting sessions. As it happens, there was a huge amount of people already queuing, so I just joined the queue. Queueing was beginning to shape itself as the official alternative activity in the I/O!</p>
<p>I was a bit luckier with my table mates today, and we talked a bit about an assortment of things such as the food not being really Mexican, the &#8216;proper San Francisco hacking areas for coffee shop working&#8217;, etc.</p>
<p>When I finished, I tried to see if the tablet issue could be solved already, although it wasn&#8217;t 15h yet, and I had been told to go to that counter at that particular hour. As I kind of expected, they repeated me that again&#8230; so I went up for the <a href="http://www.google.com/events/io/2011/sessions/learning-to-love-javascript.html">Learning to love JavaScript</a> session, but it had already started so it was slightly packed and hard to follow without a context, therefore I decided to simply grab a coffee and take it easy while waiting outside for the next session.</p>
<p>As I waited for the <a href="http://www.google.com/events/io/2011/sessions/evading-pirates-and-stopping-vampires-using-license-verification-library-in-app-billing-and-app-engine.html">Evading pirates and stopping vampires</a> session, an unknown guy approached me and asked what I did-did I develop Android stuff or&#8230;? I showed him <a href="http://5013.es/p/7">Nerdstalgia</a> and <a href="http://5013.es/p/5">Instantanea</a>, but he didn&#8217;t seem too impressed :-) </p>
<p>Then after I sat, another unknown guy asked me if the seat nearby was free. He sat and asked me if I was an Android developer &#8230; and then told me he came from Spain, so I just told him we could speak in Spanish then!</p>
<p>So he was from the Canary Islands, where they have an slightly different accent than in Peninsular Spain, and that had confused me at first. He was also an amazing <em>connoisseur</em> of Android phones. He knew all about the processors, available memory, small differences between consecutive models&#8230; really impressive. And he also told me that I should <em>absolutely</em> stay for the next session (in that very room), because one of the Sony-Ericsson guys had told him that if he was interested in the Xperia Play, the &#8220;<a href="http://www.google.com/events/io/2011/sessions/bringing-c-and-c-games-to-android.html">Writing Android games in C++</a>&#8221; session would &#8220;interest&#8221; him. It also &#8220;interested&#8221; me, so I decided to <em>sacrifice</em> the Chrome fireside chat in exchange for an hypothetical phone with joystick controls.<br />
Multitouch is cool, but nothing beats a good old button.</p>
<p>The &#8220;anti-pirates&#8221; session clarified some concepts that were a bit blurry for me yet in regard to licensing, and Dan really insisted in us adding analytics to our applications and keeping track of various metrics in order to not only find out where are we doing wrong as developers but also what are the users doing with the app: how many times it&#8217;s launched, etc&#8230; and while I understand that it could work for a game, I&#8217;m not so sure about my current applications. I have to think about that, but for the moment it simply looks a bit too creepy, considering that Instantanea is already requiring GPS, external storage and camera permissions. If I was asked for <em>internet</em> permissions for a <em>camera</em> application, I don&#8217;t think I would allow the installation of that app. My paranoia would quickly kick in and say NO WAY.</p>
<p>On the other hand, I liked the way they proposed to convert casual pirates into customers, allowing some free play before popping up a &#8220;I have children to feed&#8221; dialog, while at the same time assuming that uberpirates will never be stoppable because they are way more determined to crack an app than we are to add complicated mechanisms to prevent that happening. I still am not totally sold on the whole licensing scheme; it usually adds more issues than solves.</p>
<p>The C++ session was half done by Dan too, and while I had read about the NDK, again there were some things I didn&#8217;t know yet, specifically the best way of dealing with OpenGL and GLSurfaceView&#8217;s quirks. And you guess what? The guy from the stand wasn&#8217;t lying. At the end of the session we were told to stay in the room for some interesting stuff, which was a card exchangeable for the phone on the <em>Gear Pickup</em> counter! Although I couldn&#8217;t but wonder whether they would just give me the phone or again make me visit the counter tomorrow :-D </p>
<p>On the way out I found Unai Landa, an old school Spanish demoscener, which as usual had forgotten my face and had to look at my badge to find out who I was :-P It has already happened twice already,  once at Euskal party in 2003 and then in the way to the pmp in Madrid in 2005, so I just thought: <q>old Unai, hasn&#8217;t changed!</q></p>
<p>And then, the deciding moment. Would they solve the mysterious tablet problem? I was slightly scared of trying, but I did so anyway&#8230;</p>
<p>And as it happens, I have written pretty much the entire post using the tablet!</p>
<p>For everything else, it&#8217;s pretty smooth, but the WordPress editor interface is a bit slow. Maybe it&#8217;s its Javascript which is slowing things down. I have to test it more before emitting a definitive opinion, but so far I like it more than the iPad form wise. It&#8217;s lighter and thinner&#8230; and has multitasking. So you can leave something updating or syncing and go to another activity more engaging than a progress bar, you know, that kind of things :-P And when you come back you don&#8217;t have to restart the download again (as it happens in <em>other tablets</em>).</p>
<p>Back to the I/O, once I picked the stuff I went to the &#8220;<a href="http://www.google.com/events/io/2011/sessions/3d-graphics-on-android-lessons-learned-from-google-body.html">Lessons learned from Google Body</a>&#8221; (for Android) session,  and again most of the stuff I already knew, but it was a good wrap up with some new insights. And then&#8230; booh, the event was finishing quietly, without any bell or whistle, which was a bit sad after all the expectation of the keynotes. It felt as if something was missing.</p>
<p>So I went to the Larva Labs stand to see what they were up to and how things were going with their stand, and turns out they were giving away copies of a cute game they had developed, <a href="https://market.android.com/details?id=com.larvalabs.gurk2">Gurk II</a>. Well, actually you had to connect the phone to their computer and then they installed the game in your phone. It is an 8-bit style game and it&#8217;s got a very peculiar interface. And the music! Everything fits into place.</p>
<p>Things were coming to an end, and we had been gently invited to leave several times so that the vacuum cleaner could go through the areas we were in, so we finally exchanged twitter id&#8217;s and waved goodbye everyone. I went back to the hotel as fast as I could so that I wouldn&#8217;t be mugged by any of those strange characters that you can find in San Francisco, and found mr.doob there, furiously working on the ROME project (he actually went as far as staying up the rest of the night, and even made and commited some last minute fixes while waiting for boarding the plane to New York, where we are now for the <a href="http://rhizome.org/sevenonseven/">Seven on Seven</a> event).</p>
<p>But before leaving San Francisco I had the opportunity to briefly meet the super cool guys from the Data Arts Team at Google, which came up with the most super awesomely geek farewell ending that one could say these days:<br />
<blockquote>See you at github!</p></blockquote>
<p>It was a pleasure to meet you guys! :-)</p>
<p>To sum up: a very intense event. Maybe a bit too intense for only two days. Yes, the sessions are recorded and published almost immediately, but what I appreciate most from this sort of events is being able to talk with the speakers and ask them the questions, get their instant feedback, and maybe ask them another question, which I can&#8217;t do if I just stay home and watch prerecorded sessions. Most of the times there were many interesting sessions happening at the same time, so deciding which one to attend felt like a little sacrifice as I mentioned before. I understand the cost of running an event such as this one is quite high so probably they worked out that two days was the optimum amount of days in economical terms, but still, the suggestion is there for them to pick (or ignore, haha).</p>
<p>In regards to the goodies: wow, that even felt indecently rich. While other events do not even give you a sandwich, Google I/O feeds you and gives you stuff to develop with, apart from providing you with knowledge, which is the main point of a tech conference, of course. And it not only encourages to develop for these platforms, but also really helps a lot. First, because acquiring hardware is always an extra expense we cannot always afford, and secondly because as they are early versions of the hardware, when the final users got those &#8220;new&#8221; devices they won&#8217;t have to wait for applications that exploit it. So it&#8217;s not as if they are frivolous goodies&#8211;they are useful, and will be <em>fed back</em> into the system, somehow, as we develop and test applications with that new hardware we&#8217;ve been given. For example, we&#8217;ve been testing every app with the Evo 4G mr.doob got at 2010 I/O, and actually found differences that were impossible to notice (or very hard to track unless you get a report from a user) if we hadn&#8217;t tested the apps in the device.<br />
is<br />
So do I recommend it? Absolutely! I am super thrilled with all the knowledge I&#8217;ve acquired and I&#8217;m so looking forward to come back to London and start applying it (and watch the sessions I couldn&#8217;t attend). Meeting so many developers was also amazing. It really gives you a strong sense of community and involvement that I think is very important for any platform to succeed.</p>
<p>I still have a sort of doubt, and it is what is really Google&#8217;s strategy. Because they are really, really promoting Android, but obviously their business is in getting everyone to use the web more and so they are promoting the Chromebooks with everything in the cloud and etc&#8230; The best explanation I can think of is that they are taking risks (albeit quite huge obviously) and betting for several things to succeed instead of just resting on their laurels. Whoever strikes first&#8230; as they say. Let&#8217;s see what happens, but right now it is definitely disconcerting, both as user and as developer.</p>
<p>NOTE: This was supposed to be finished and published on the very day that the I/O ended (Wednesday the 13rd), but we spent almost the entire Thursday traveling and I didn&#8217;t finish revising it until today (Friday). So apologies if you were waiting for this second part desperately!</p>
 <p><a href="http://soledadpenades.com/?flattrss_redirect&amp;id=3514&amp;md5=eebaed734de925aaa8b6fcb218a7ceb7" title="Flattr" target="_blank"><img src="http://soledadpenades.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2011/05/14/google-io-2011-day-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A nosy look into LiveWallpapers.apk</title>
		<link>http://soledadpenades.com/2010/09/10/a-nosy-look-into-livewallpapers-apk/</link>
		<comments>http://soledadpenades.com/2010/09/10/a-nosy-look-into-livewallpapers-apk/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 23:38:04 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[live wallpapers]]></category>
		<category><![CDATA[ndk]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[shaders]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=2910</guid>
		<description><![CDATA[It first seemed that the Galaxy wallpaper was implemented in C + OpenGL (with Java calls, of course). From our tests, using Canvas was not an option, since there were just too many particles for poor humble Canvas. And it also looked like it was using the NDK, I thought upon reading this post. Then [...]]]></description>
			<content:encoded><![CDATA[<p>It first seemed that the Galaxy wallpaper was implemented in C + OpenGL (with Java calls, of course). From our tests, using Canvas was not an option, since there were just too many particles for poor humble Canvas.</p>
<p>And it also looked like it was using the NDK, I thought upon reading this <a href="http://forum.xda-developers.com/showpost.php?p=5304616&#038;postcount=9">post</a>. </p>
<p>Then somebody at that forum suggested they are implemented with Processing, which made me kind of laugh internally. But the very same source he used (Romain Guy&#8217;s blog post about <a href="http://www.curious-creature.org/2010/01/07/nexus-one-live-wallpapers/">live wallpapers</a>) denies that and gives some details about the Android implementation:</p>
<p><span id="more-2910"></span></p>
<blockquote><p>The prototypes are written in Processing. I did port Processing to Android to run live wallpapers and performance was not on par with what we wanted, so we implemented something called RenderScript <a href="http://www.curious-creature.org/2010/01/07/nexus-one-live-wallpapers/comment-page-1/#comment-3125">#</a></p></blockquote>
<p>Digging deeper, I downloaded the <strong>/system/apps/LiveWallpaper.apk</strong> file from the phone to my computer (using the DDMS perspective from within Eclipse), uncompressed it (it&#8217;s a ZIP file in disguise) and inspected its contents to see if I could locate where was the code the guy in the first post shown. And I indeed could :-)</p>
<p>The .rs files (for &#8220;RenderScript&#8221;, I deduct) are all in <strong>res/raw</strong>. They have names such as galaxy.rs, grass.rs, nexus.rs and so on. And they look like this:</p>
<div class="syhi_block"><code><span style="color: #339933;">#pragma version(1)</span><br />
<span style="color: #339933;">#pragma stateVertex(PVBkOrtho)</span><br />
<span style="color: #339933;">#pragma stateRaster(parent)</span><br />
<span style="color: #339933;">#pragma stateFragment(PFBackground)</span><br />
<span style="color: #339933;">#pragma stateStore(PFSBackground)</span><br />
<br />
<span style="color: #339933;">#define ELLIPSE_RATIO 0.892f</span><br />
<br />
<span style="color: #339933;">#define PI 3.1415f</span><br />
<span style="color: #339933;">#define TWO_PI 6.283f</span><br />
<span style="color: #339933;">#define ELLIPSE_TWIST 0.023333333f</span><br />
<br />
<span style="color: #993333;">float</span> angle<span style="color: #339933;">;</span><br />
<br />
<span style="color: #808080; font-style: italic;">/**<br />
&nbsp;* Script initialization. Called automatically.<br />
&nbsp;*/</span><br />
<span style="color: #993333;">void</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; angle <span style="color: #339933;">=</span> <span style="color:#800080;">50.0f</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;">/**<br />
&nbsp;* Helper function to generate the stars.<br />
&nbsp;*/</span><br />
<span style="color: #993333;">float</span> randomGauss<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">float</span> x1<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">float</span> x2<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">float</span> w <span style="color: #339933;">=</span> <span style="color: #0000dd;">2</span>.<span style="color: #202020;">f</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>w <span style="color: #339933;">&gt;=</span> <span style="color:#800080;">1.0f</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x1 <span style="color: #339933;">=</span> <span style="color:#800080;">2.0f</span> <span style="color: #339933;">*</span> randf2<span style="color: #009900;">&#40;</span><span style="color:#800080;">0.0f</span><span style="color: #339933;">,</span> <span style="color:#800080;">1.0f</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color:#800080;">1.0f</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x2 <span style="color: #339933;">=</span> <span style="color:#800080;">2.0f</span> <span style="color: #339933;">*</span> randf2<span style="color: #009900;">&#40;</span><span style="color:#800080;">0.0f</span><span style="color: #339933;">,</span> <span style="color:#800080;">1.0f</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color:#800080;">1.0f</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; w <span style="color: #339933;">=</span> x1 <span style="color: #339933;">*</span> x1 <span style="color: #339933;">+</span> x2 <span style="color: #339933;">*</span> x2<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; w <span style="color: #339933;">=</span> sqrtf<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color:#800080;">2.0</span> <span style="color: #339933;">*</span> logf<span style="color: #009900;">&#40;</span>w<span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> w<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> x1 <span style="color: #339933;">*</span> w<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">float</span> gSpeed<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">12000</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #808080; font-style: italic;">/**<br />
&nbsp;* Generates the properties for a given star.<br />
&nbsp;*/</span><br />
<span style="color: #993333;">void</span> createParticle<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> Particles_s <span style="color: #339933;">*</span>part<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> idx<span style="color: #339933;">,</span> <span style="color: #993333;">float</span> scale<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">float</span> d <span style="color: #339933;">=</span> fabsf<span style="color: #009900;">&#40;</span>randomGauss<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> State<span style="color: #339933;">-&gt;</span>galaxyRadius <span style="color: #339933;">*</span> <span style="color:#800080;">0.5f</span> <span style="color: #339933;">+</span> randf<span style="color: #009900;">&#40;</span><span style="color:#800080;">64.0f</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">float</span> id <span style="color: #339933;">=</span> d <span style="color: #339933;">/</span> State<span style="color: #339933;">-&gt;</span>galaxyRadius<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">float</span> z <span style="color: #339933;">=</span> randomGauss<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color:#800080;">0.4f</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span><span style="color:#800080;">1.0f</span> <span style="color: #339933;">-</span> id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">float</span> p <span style="color: #339933;">=</span> <span style="color: #339933;">-</span>d <span style="color: #339933;">*</span> ELLIPSE_TWIST<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> r<span style="color: #339933;">,</span>g<span style="color: #339933;">,</span>b<span style="color: #339933;">,</span>a<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>d <span style="color: #339933;">&lt;</span> State<span style="color: #339933;">-&gt;</span>galaxyRadius <span style="color: #339933;">*</span> <span style="color:#800080;">0.33f</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; r <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">220</span> <span style="color: #339933;">+</span> id <span style="color: #339933;">*</span> <span style="color: #0000dd;">35</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; g <span style="color: #339933;">=</span> <span style="color: #0000dd;">220</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; b <span style="color: #339933;">=</span> <span style="color: #0000dd;">220</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; r <span style="color: #339933;">=</span> <span style="color: #0000dd;">180</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; g <span style="color: #339933;">=</span> <span style="color: #0000dd;">180</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; b <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span> clampf<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">140</span>.<span style="color: #202020;">f</span> <span style="color: #339933;">+</span> id <span style="color: #339933;">*</span> <span style="color: #0000dd;">115</span>.<span style="color: #202020;">f</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">140</span>.<span style="color: #202020;">f</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">255</span>.<span style="color: #202020;">f</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Stash point size * 10 in Alpha</span><br />
&nbsp; &nbsp; a <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>randf2<span style="color: #009900;">&#40;</span><span style="color:#800080;">1.2f</span><span style="color: #339933;">,</span> <span style="color:#800080;">2.1f</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #0000dd;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; part<span style="color: #339933;">-&gt;</span>color <span style="color: #339933;">=</span> r <span style="color: #339933;">|</span> g<span style="color: #339933;">&lt;&lt;</span><span style="color: #0000dd;">8</span> <span style="color: #339933;">|</span> b<span style="color: #339933;">&lt;&lt;</span><span style="color: #0000dd;">16</span> <span style="color: #339933;">|</span> a<span style="color: #339933;">&lt;&lt;</span><span style="color: #0000dd;">24</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>d <span style="color: #339933;">&gt;</span> State<span style="color: #339933;">-&gt;</span>galaxyRadius <span style="color: #339933;">*</span> <span style="color:#800080;">0.15f</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; z <span style="color: #339933;">*=</span> <span style="color:#800080;">0.6f</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span><span style="color:#800080;">1.0f</span> <span style="color: #339933;">-</span> id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; z <span style="color: #339933;">*=</span> <span style="color:#800080;">0.72f</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Map to the projection coordinates (viewport.x = -1.0 -&gt; 1.0)</span><br />
&nbsp; &nbsp; d <span style="color: #339933;">=</span> mapf<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color:#800080;">4.0f</span><span style="color: #339933;">,</span> State<span style="color: #339933;">-&gt;</span>galaxyRadius <span style="color: #339933;">+</span> <span style="color:#800080;">4.0f</span><span style="color: #339933;">,</span> <span style="color:#800080;">0.0f</span><span style="color: #339933;">,</span> scale<span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; part<span style="color: #339933;">-&gt;</span>position.<span style="color: #202020;">x</span> <span style="color: #339933;">=</span> randf<span style="color: #009900;">&#40;</span>TWO_PI<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; part<span style="color: #339933;">-&gt;</span>position.<span style="color: #202020;">y</span> <span style="color: #339933;">=</span> d<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; gSpeed<span style="color: #009900;">&#91;</span>idx<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> randf2<span style="color: #009900;">&#40;</span><span style="color:#800080;">0.0015f</span><span style="color: #339933;">,</span> <span style="color:#800080;">0.0025f</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span><span style="color:#800080;">0.5f</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>scale <span style="color: #339933;">/</span> d<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color:#800080;">0.8f</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; part<span style="color: #339933;">-&gt;</span>position.<span style="color: #202020;">z</span> <span style="color: #339933;">=</span> z <span style="color: #339933;">/</span> <span style="color:#800080;">5.0f</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// etc</span></code></div>
<p>It might be <em>baptised</em> as RenderScript but it no doubt smells like C from a couple of miles away: #pragma&#8217;s, #define&#8217;s, struct&#8217;s and -&gt;&#8217;s for pointing to members? You can&#8217;t help thinking it&#8217;s C, no matter how hard you try.</p>
<p>More deductions: either this RenderScript uses a gcc compiler in the very phone (not <em>that unlikely</em> since it&#8217;s a Linux system after all?) or it parses the contents of the script on loading time. Then it&#8217;s &#8220;just&#8221; a wrapper for OpenGL calls and generally cumbersome stuff such as preparing textures, vertex shaders etc (I can see something related to vertex shaders in the galaxy wallpaper, for example).</p>
<p>I&#8217;ve copy-pasted the full <a href="http://gist.github.com/574518">galaxy.rs source code</a> into a gist, just in case you want to see the whole thing but don&#8217;t have a phone and a DDMS environment handy :-)</p>
 <p><a href="http://soledadpenades.com/?flattrss_redirect&amp;id=2910&amp;md5=bb52c65d0de20134aefe093a9704bfba" title="Flattr" target="_blank"><img src="http://soledadpenades.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2010/09/10/a-nosy-look-into-livewallpapers-apk/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Messing with OpenGL ES (in Android)</title>
		<link>http://soledadpenades.com/2010/05/05/messing-with-opengl-es-in-android/</link>
		<comments>http://soledadpenades.com/2010/05/05/messing-with-opengl-es-in-android/#comments</comments>
		<pubDate>Wed, 05 May 2010 22:23:57 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[opengl es]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=2592</guid>
		<description><![CDATA[The emulator vs the physical machines gl.glLineWidth is ignored in the HTC Magic (all lines have width = 1.0), whereas it is honoured on the emulator it also seems like the emulator performs some sort of polygon clipping instead of culling triangles when at least one of the vertexes is out of the frustrum &#8212; [...]]]></description>
			<content:encoded><![CDATA[<h3>The emulator vs the physical machines</h3>
<ul>
<li><strong>gl.glLineWidth</strong> is ignored in the HTC Magic (all lines have width = 1.0), whereas it is honoured on the emulator</li>
<li>it also seems like the emulator performs some sort of <strong>polygon clipping</strong> instead of culling triangles when at least one of the vertexes is out of the frustrum &#8212; so you get different output in some cases</li>
</ul>
<h3>Drawing text with OpenGL ES&#8217; glDrawTexfOES vs the classic OpenGL orthogonal view methods</h3>
<p>There&#8217;s no need for setting an orthogonal view when using glDrawTexfOES for drawing text into the screen, since it seems to be ignoring any existing view or projection matrix and simply drawing into the screen buffer (and that&#8217;s probably why it is so fast!).</p>
<p>So no more structures like this:</p>
<div class="syhi_block"><code>gl.<span style="color: #006633;">glMatrixMode</span><span style="color: #009900;">&#40;</span>GL10.<span style="color: #006633;">GL_PROJECTION</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
gl.<span style="color: #006633;">glPushMatrix</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
gl.<span style="color: #006633;">glLoadIdentity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
gl.<span style="color: #006633;">glViewport</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, canvasWidth, canvasHeight<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
gl.<span style="color: #006633;">glOrthof</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>halfCanvasWidth, halfCanvasWidth, <span style="color: #339933;">-</span>halfCanvasHeight, halfCanvasHeight, 1.0f, 200.0f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// draw text here</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
gl.<span style="color: #006633;">glPopMatrix</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></code></div>
<p>It will get reduced to just&#8230;</p>
<div class="syhi_block"><code><span style="color: #666666; font-style: italic;">// draw text here</span></code></div>
<p>Interestingly though, <strong>if you&#8217;re using fog you&#8217;ll need to turn it off</strong> or you may not see the text. So we&#8217;ll end up with this:</p>
<div class="syhi_block"><code>gl.<span style="color: #006633;">glDisable</span><span style="color: #009900;">&#40;</span>GL10.<span style="color: #006633;">GL_FOG</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">// draw text here</span></code></div>
<h3>Modifying the buffers after they have been created</h3>
<p>In classic OpenGL immediate mode we use glBegin/glEnd liberally. But we can&#8217;t keep on going on like that with OpenGL ES: we are forced to convert our glBegin/glEnd calls to the glDrawArrays or glDrawElements style.</p>
<p>I believed that this would derive in only being able to show [boring] static geometry, but I have been messing with buffers and found out that you can for example modify the vertex buffers once they have been allocated and the data put into them. So you can not only do this:</p>
<div class="syhi_block"><code>ByteBuffer bb<span style="color: #339933;">;</span><br />
<br />
bb <span style="color: #339933;">=</span> ByteBuffer.<span style="color: #006633;">allocateDirect</span><span style="color: #009900;">&#40;</span>vertices.<span style="color: #006633;">length</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 4 bytes per value</span><br />
bb.<span style="color: #006633;">order</span><span style="color: #009900;">&#40;</span>ByteOrder.<span style="color: #006633;">nativeOrder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
mVerticesBuffer <span style="color: #339933;">=</span> bb.<span style="color: #006633;">asFloatBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
mVerticesBuffer.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>vertices<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
mVerticesBuffer.<span style="color: #006633;">position</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></code></div>
<p>but you could even do this afterwards:</p>
<div class="syhi_block"><code><span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> mVerticesBuffer.<span style="color: #006633;">limit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; mVerticesBuffer.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>i, <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">float</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Amath+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Math</span></a>.<span style="color: #006633;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Amath+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Math</span></a>.<span style="color: #006633;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></code></div>
<p>Or in other words: <strong>buffer[index] = value</strong> is <strong>buffer.put(index, value)</strong> in buffer terms.</p>
<p>I haven&#8217;t tried adding more elements (the above example doesn&#8217;t add more, just replaces the current vertex values with randomized ones). The performance doesn&#8217;t seem to plummet (FPS counter shows a decent 57-60 fps) when changing all 24 vertices in my test mesh, in <em>every frame</em>. But I haven&#8217;t tried with larger models. And I&#8217;m not sure about the possible concurrency issues that might arise either. So it&#8217;s up to you if you want to use this &#8212; it feels a bit hackish to me :D</p>
]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2010/05/05/messing-with-opengl-es-in-android/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Seen, gone.</title>
		<link>http://soledadpenades.com/2010/03/03/seen-gone/</link>
		<comments>http://soledadpenades.com/2010/03/03/seen-gone/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 23:29:51 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[opengl]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=2441</guid>
		<description><![CDATA[&#8220;Seen, gone.&#8221; is my first (serious) incursion in Android development. Yeah! As the description says: Take a picture, watch it morph into something different &#8211; yet related to its true origin. And before you can blink twice, it&#8217;s gone, destroyed by the very same hands that created it. To escape from the usual demoscene non-interactive [...]]]></description>
			<content:encoded><![CDATA[<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/rn9GIZtmm48&#038;hl=en_GB&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/rn9GIZtmm48&#038;hl=en_GB&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p>&#8220;<a href="http://5013.es/p/2">Seen, gone.</a>&#8221; is my first (serious) incursion in Android development. Yeah!</p>
<p>As the description says:</p>
<blockquote><p>Take a picture, watch it morph into something different &#8211; yet related to its true origin. And before you can blink twice, it&#8217;s gone, destroyed by the very same hands that created it.</p></blockquote>
<p>To escape from the usual demoscene non-interactive demonstrations, I decided to do something interactive but that still used <em>a bit</em> of processor power, so that I could see what could the platform do. I had already tried to do some audio stuff, but the results were a bit disastrous. I might come back to that field again; maybe I will be more inspired or I will know how to do things &#8216;the proper way&#8217; and it will end up being a more satisfying experience.</p>
<p>For this, I began using <a href="http://developer.android.com/reference/android/graphics/Canvas.html">Canvas</a> and only integer math to speed things up but the results were horrible; using Canvas for this was just too much and there weren&#8217;t available cycles for anything else. It was unacceptably jerky. I even showed the app to my <a href="http://mrdoob.com">favourite betatester</a> and he told me that he would uninstall the application <em>immediately</em>. </p>
<p>Since I was determined to improve things, I watched the <a href="http://code.google.com/events/io/2009/sessions/WritingRealTimeGamesAndroid.html">mighty session</a> by Chris Pruett at past year&#8217;s Google IO and understood why things weren&#8217;t quite working the way I expected them to do. After much cursing myself for not having watched the presentation before, I replaced Canvas with OpenGL ES &#8211;in which I still miss <em>good old immediate mode</em>, but hey&#8230; it&#8217;s way faster!&#8211; and float calculations (to my surprise, you can even afford a few float operations!), plus reorganized pretty much everything, and rewrote the rest. Core calculations could probably be optimized with native C code but I didn&#8217;t want to limit myself to non-portable code yet. Although&#8230; are there any Android devices which are not ARM based? Heh!</p>
<p>It&#8217;s been a very instructive experience; I&#8217;ve learnt a lot doing this &#8211;the Garbage Collector and I have become almost close friends, so to say&#8211; and obviously it will help me to create more Android applications in the future.</p>
<p>But in the meantime, there&#8217;s another demo waiting to be finished!</p>
<p>And yes, this app is what I wanted to finish <a href="http://soledadpenades.com/2010/03/01/breakpoint-demolog-days-26-28-busy-with-something-else/">a couple of days ago</a>, just in case you missed that post.</p>
]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2010/03/03/seen-gone/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Breakpoint demolog, day 17: building for windows (from linux)</title>
		<link>http://soledadpenades.com/2010/02/19/breakpoint-demolog-day-17-building-for-windows-from-linux/</link>
		<comments>http://soledadpenades.com/2010/02/19/breakpoint-demolog-day-17-building-for-windows-from-linux/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 00:38:46 +0000</pubDate>
		<dc:creator>sole</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[breakpoint]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[cross compiling]]></category>
		<category><![CDATA[demoscene]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[makefile]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[sdl]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[wine]]></category>

		<guid isPermaLink="false">http://soledadpenades.com/?p=2392</guid>
		<description><![CDATA[Today I decided to do something different. And I thought: Okay, I&#8217;ll try and sort out this compiling for windows issue, so that I can focus on the rest of more important things without having to worry about it any more. And guess what&#8230;? I think I managed to do it :-) Roughly, these are [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://soledadpenades.com/files/demoscene/bp2010/20100218.png" alt="Windows and Linux executables, rotating a triangle and generating a sine wave audio stream" /></p>
<p>Today I decided to do something different. And I thought: <q>Okay, I&#8217;ll try and sort out this compiling for windows issue, so that I can focus on the rest of more important things without having to worry about it any more.</q></p>
<p>And guess what&#8230;? I think I managed to do it :-)</p>
<p>Roughly, these are the steps I followed, just in case someone else wants to compile for windows with opengl and sdl support, using [ubuntu] linux:</p>
<ul>
<li>install mingw (I did it with Synaptic Package Manager so that I didn&#8217;t have to go through the ./configure and ./make hell)</li>
<li>get the dev libraries from sdl for windows/mingw &#8211;<a href="http://www.libsdl.org/release/SDL-devel-1.2.14-mingw32.tar.gz">this file</a>&#8211; or check their <a href="http://www.libsdl.org/download-1.2.php">downloads</a> page</li>
<li>uncompress the file and locate the <strong>bin</strong>, <strong>include</strong> and <strong>lib</strong> folders within, and&#8230;
<ul>
<li>copy <strong>bin/SDL.dll</strong> to the folder where your win32 .exe will go &#8212; so that the exe can pick and load the dll when executing</li>
<li>copy the <strong>include</strong> and <strong>lib</strong> folders to a folder in your project&#8217;s src folder &#8212; or anywhere you&#8217;ve got access to! For example: project/src/libs/sdl/</li>
</ul>
</li>
<li>now in your main.cpp, include SDL&#8217;s header files like this:
<div class="syhi_block"><code><span style="color: #339900;">#include &lt;SDL/SDL.h&gt;</span><br />
<span style="color: #339900;">#include &lt;SDL/SDL_opengl.h&gt;</span></code></div>
</li>
<li>And the makefile could be something like this too:
<div class="syhi_block"><code>WINDOWS_SDL = ./libs/sdl/windows<br />
<br />
windows:<br />
&nbsp; &nbsp; &nbsp; &nbsp; i586-mingw32msvc-g++ -I$(WINDOWS_SDL)/include -L$(WINDOWS_SDL) \<br />
main.cpp $(WINDOWS_SDL)/libSDL.dll.a -o ../test.exe\<br />
&nbsp;-lmingw32 -lSDLmain -lSDL -mwindows -lopengl32 -Wl,-R.</code></div>
</li>
</ul>
<p>(ugly hard line returns added by me so that you can see all parameters in one go).</p>
<p>This assumes you are invoking make from the src folder. The output will go to the parent folder. But well, the most important things that need to be highlighted are the bunch of switches you need to include in order to get the program to link: </p>
<p><strong>-I$(WINDOWS_SDL)/include</strong> &#8212; this tells the compiler where to look for additional header files. This way it can find &lt;SDL/SDL.h&gt; and you do not need to modify the file or add #define&#8217;s when building for linux.</p>
<p><strong> -L$(WINDOWS_SDL)</strong> &#8212; pretty much the same but tells the compiler to look for static libraries in the WINDOWS_SDL folder too</p>
<p><strong>$(WINDOWS_SDL)/libSDL.dll.a</strong> &#8212; links the library into our binary!</p>
<p><strong>-lmingw32 -lSDLmain -lSDL -mwindows -lopengl32 -Wl,-R.</strong> &#8212; these are magic &#8211; remove any of them and the linker will complain about missing symbols ;)</p>
<p>I still have to test this in a real windows machine; so far I have just tried with Wine. The output is a little jerky and a bit slower than the native (64 bit) counterpart, but I guess this will do much better than compiling in Virtual Box and testing with Wine :D</p>
<p>I&#8217;ll try to upload a test .exe when I test it on a real windows box myself, so that you can test it and see if it works in your computer (if you want, of course!). It&#8217;s ages since I compiled anything for win, and I truly wonder whether it will work with Vista/7&#8230; my <a href="http://soledadpenades.com/projects/demoscene/vslpx-by-xplsv/">last demo</a> for Windows was done in 2005 and XP was in full glory back then :P</p>
]]></content:encoded>
			<wfw:commentRss>http://soledadpenades.com/2010/02/19/breakpoint-demolog-day-17-building-for-windows-from-linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

