[android-developers] Re: AlignParentBottom in RelativeLayout (wrap_content)
I just tried that, problem now is that I need my view rendered before the image, such that the image is rendered on top of the view. I cannot reference a view that is defined later in the xml, and I can't seem to find an option to render a view below a previously rendered view. So I'm back to defining the view size manually. - Mark Gjøl On Aug 3, 4:59 pm, Kostya Vasilyev kmans...@gmail.com wrote: Um, android:layout_bottom ? 03.08.2011 18:56, Mark Gjøl пишет: That won't achieve what I want. To achieve the result I want it is important for the bottom line to be placed exactly on the bottom on the image - not below it. So putting it relative to the image won't do it for me. - Mark Gjøl -- Kostya Vasilyev -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: AlignParentBottom in RelativeLayout (wrap_content)
Ah, the +. Thank you very much, that solved my problem! - Mark Gjøl On Aug 4, 9:50 am, Kostya Vasilyev kmans...@gmail.com wrote: Yes you can use forward references inside relative layouts (starting with 1.6). Make sure to use @+id the first time a particular view id is needed - view references are one thing, id definitions, quite another. -- Kostya Vasilyev 04.08.2011 11:46 пользователь Mark Gjøl bitflips...@gmail.com написал: -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] AlignParentBottom in RelativeLayout (wrap_content)
I am trying to make a RelativeLayout with an image centered in the bottom, and a line spanning the bottom. The layout should have the height of the image, and fill the width. All of this is in a linear layout with other things in it. See code below for reference. Problem is: As soon as I insert the view (with alignParentBottom) my RelativeLayout fills the entire view (minus what came before it in the LinearLayout). Is this a bug? I can force what I want by setting a specific height to the RelativeLayout (eg. 12dp) but that's not exactly what I want. Any thoughts? LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:orientation=vertical android:layout_width=match_parent android:layout_height=match_parent [...] RelativeLayout android:layout_width=match_parent android:layout_height=wrap_content View android:layout_width=match_parent android:layout_height=1px android:layout_alignParentBottom=true / ImageView android:layout_width=wrap_content android:layout_height=wrap_content android:src=@drawable/indicator_current android:layout_centerInParent=true / /RelativeLayout [...] /LinearLayout -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: AlignParentBottom in RelativeLayout (wrap_content)
On Aug 3, 4:09 pm, Kostya Vasilyev kmans...@gmail.com wrote: 03.08.2011 17:25, Mark Gjøl пишет: Yep, it seems that's how it works, even with Android 1.6, 2.0, etc. Any thoughts? Yes, build the layout some other way - such as anchor a view to the top, then add more views with layout_below - as opposed to anchoring a view at the bottom, and placing others with layout_above, as you're probably doing now. That won't achieve what I want. To achieve the result I want it is important for the bottom line to be placed exactly on the bottom on the image - not below it. So putting it relative to the image won't do it for me. - Mark Gjøl -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: XML parsing slow ... cache!
On my first implementation I used a DOM-parser for my XML (Flickr, 500 images), and it easily took about a minute to get through. I now use a SAX-parser, and it's less than a second. The speedup was tremendous, so it can definitely be worth your time, at least to test the difference! -- Mark Gjøl On Aug 16, 4:35 pm, Fabrizio Giudici fabrizio.giud...@tidalwave.it wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 8/16/10 16:02 , Davide wrote: Hi, I have seen that xml parsing is very slow. Using sax would be better, but benchmark show that sax work only 30% faster as dom. Is right? Is faster if I construct a DOM using sax? To reduce time i like to cache xml file. Caching it as xml is not a good idea because the parsing time is there again the secondo time. Should I use sqllite? Is faster? Is an idea to use an ObjectOutputStream? Can I put in asset a file maked by ObjectOutputStream or the serialized objects can be different in different mobile hardware? Davide, have you run some precise test so you are sure you've spotted the bottleneck? Just to be sure that it's really XML the problem (and not I/O). JSON could be an alternative. I've run some tests with serialization and theoretically works (I exchanged objects between Android and a JavaSE app), but it's somewhat brittle. Also, I'm not sure it's fast because introspection is not fast on Android (it might be different with 2.2). Also consider JDom / Jaxen as an alternate XML parser, might be worth while compare their performance. - -- Fabrizio Giudici - Java Architect, Project Manager Tidalwave s.a.s. - We make Java work. Everywhere. java.net/blog/fabriziogiudici -www.tidalwave.it/people fabrizio.giud...@tidalwave.it -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.14 (Darwin) Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org/ iEYEARECAAYFAkxpTMMACgkQeDweFqgUGxdHiwCgne+CB+ZbtRZxLLN0VjH9ppZK pPEAoKC5cyf8MwUAl46+pdAGugg6/nES =gE71 -END PGP SIGNATURE- -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Oops, I crashed the phone
String, I could try and make sure I'm not drawing to the screen from several places at the same time, but I don't think this is the problem. My drawing loop is strictly single threaded (fed data by several other threads, obviously), so Android would have to be maintaining multiple GL message loops at once. At any rate, I think the problem is more mechanical... My app has been on the Market for almost a year now, and hasn't had these problems until now. I recently changed a couple of things, the most noteworthy being the ability to use 256x256 textures rather than 128x128. As the crashes are completely random, I cannot be completely certain if this is the problem, but I don't seem to be getting the crashes when sticking to 128x128 textures, so maybe I'm exceeding some secret limit? For the record, aside from some 6 UI buttons at 64x64, I'm using about 9 256x256 textures and a single 1024x1024 texture. I am aware that this can be optimized to use less textures, and that may well be the fix to stop the phone from crashing. So I'm not sure the problems are the same, but maybe they're related? - Mark On Aug 16, 9:59 pm, String sterling.ud...@googlemail.com wrote: On Aug 15, 12:46 pm, Mark Gjøl bitflips...@gmail.com wrote: It's always a problem if you can crash the phone. As I'm working with OpenGL I'm guessing this is the problem, as I'm working directly with the hardware. When the phone crashes it hangs for a couple of minutes, Mark, It's not just you. One of my OpenGL apps has been plagued with this problem for a couple of months now, and I've virtually given up on it as unsolvable. I've actually unpublished the free version of this app because so many users were affected, and my fear is that the paid version will ultimately be doomed as well. The thing that makes it just so difficult is that I cannot make it happen with any regularity. I see it on either my G1 or N1 maybe once every couple of weeks, but with no discernible pattern. This makes it essentially impossible to test any proposed fix, because I just can't tell if the problem has gotten any better. You might look at the following old thread, if you haven't already:http://groups.google.com/group/android-developers/browse_frm/thread/f... There is a proposed solution in there that didn't help me, but you might have better luck. There are also a couple of issues in the bugtracker linked from that thread. My best theory is that it's some sort of race condition between the UI and OpenGL threads... I think I was able to reduce (but not eliminate) the occurrences by making my code as thread-safe as possible. Things like: - using the volatile modifier on all variables touched in onDrawFrame() - using synchronize on other functions called from within my OpenGL code - putting a semaphore in onDrawFrame() to ensure that it's only ever got one instance running at a time ...and so on. Good luck with this, and I mean that with all my heart. It's the most dispiriting programming problem I've faced in a long, long time. Please let us know if you get anywhere with it. String -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Oops, I crashed the phone
The current version of Floating Image (version 2.5.0, code 36) randomly crashes Nexus One phones. Obviously I'm looking into fixing this problem, but I though it would be prudent for me to report this. It's always a problem if you can crash the phone. As I'm working with OpenGL I'm guessing this is the problem, as I'm working directly with the hardware. When the phone crashes it hangs for a couple of minutes, being very chatty in the log, and then reboots. I will post the log after the next crash. Not sure if this will be useful or not, but I thought I ought to report it. :) - Mark -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Oops, I crashed the phone
This is what I get from adb logcat until the phone reboots: I/ActivityManager( 88): Start proc dk.nindroid.rss for activity dk.nindroid.rss/.ShowStreams: pid=6295 uid=10046 gids={3003, 1015} I/global ( 6295): Default buffer size used in BufferedOutputStream constructor. It would be better to be explicit if an 8k buffer is required. D/dalvikvm( 6295): GC_EXTERNAL_ALLOC freed 898 objects / 70704 bytes in 43ms D/dalvikvm( 6295): GC_EXTERNAL_ALLOC freed 268 objects / 13416 bytes in 34ms D/dalvikvm( 6295): GC_FOR_MALLOC freed 4184 objects / 230936 bytes in 48ms V/Floating Image( 6295): 501 files in cache. V/Floating Image( 6295): Old version: 2.5.0, current version: 2.5.0 V/Floating Image( 6295): Resuming main activity D/dalvikvm( 6295): GC_FOR_MALLOC freed 6761 objects / 426352 bytes in 39ms V/Floating Image( 6295): Begin resume... V/Floating Image( 6295): Switching to floating renderer V/Floating Image( 6295): Resume texture bank done... V/Bitmap downloader( 6295): *** Starting asynchronous downloader thread V/Orientation manager( 6295): Resume! V/Floating Image( 6295): End resume... V/Floating Image( 6295): Resetting images V/Floating Image( 6295): Not signed in to Picasa D/libEGL ( 6295): loaded /system/lib/egl/libGLES_android.so D/libEGL ( 6295): loaded /system/lib/egl/libEGL_adreno200.so D/libEGL ( 6295): loaded /system/lib/egl/libGLESv1_CM_adreno200.so D/libEGL ( 6295): loaded /system/lib/egl/libGLESv2_adreno200.so V/Display ( 6295): Display surface changed! V/dk.nindroid.rss.RiverRenderer( 6295): Orientation change received: 0 V/Display ( 6295): Fullscreen is true I/ActivityManager( 88): Displayed activity dk.nindroid.rss/.ShowStreams: 1066 ms (total 1066 ms) V/dk.nindroid.rss.RiverRenderer( 6295): Orientation change received: 2 I/CheckinService( 192): Preparing to send checkin request I/EventLogService( 192): Accumulating logs since 1281881326137 E/Tethering( 88): active iface (usb0) reported as added, ignoring D/BatteryWidget( 483): Updating Views D/dalvikvm( 6295): GC_FOR_MALLOC freed 3732 objects / 397144 bytes in 47ms V/FeedController( 6295): 4 photos found. V/Floating Image( 6295): Showing images from 1 feeds D/dalvikvm( 192): GC_FOR_MALLOC freed 1803 objects / 359704 bytes in 58ms D/NativeCrypto( 192): Freeing OpenSSL session I/CheckinTask( 192): Sending checkin request (4569 bytes) D/dalvikvm( 6295): GC_FOR_MALLOC freed 970 objects / 263552 bytes in 38ms D/dalvikvm( 6295): GC_FOR_MALLOC freed 1038 objects / 226112 bytes in 56ms D/dalvikvm( 6295): GC_FOR_MALLOC freed 515 objects / 236280 bytes in 77ms D/dalvikvm( 6295): GC_FOR_MALLOC freed 733 objects / 225640 bytes in 40ms I/CheckinTask( 192): Checkin success: https://android.clients.google.com/checkin (1 requests sent) I/CheckinService( 192): From server: Intent { act=android.server.checkin.FOTA_CANCEL } D/dalvikvm( 192): GC_FOR_MALLOC freed 4869 objects / 538856 bytes in 76ms D/NativeCrypto( 192): Freeing OpenSSL session D/dalvikvm( 6295): GC_FOR_MALLOC freed 601 objects / 244864 bytes in 43ms D/dalvikvm( 6295): GC_FOR_MALLOC freed 850 objects / 252320 bytes in 45ms D/dalvikvm( 6295): GC_FOR_MALLOC freed 733 objects / 200704 bytes in 49ms D/dalvikvm( 6295): GC_EXTERNAL_ALLOC freed 152 objects / 61448 bytes in 40ms D/dalvikvm( 6295): GC_FOR_MALLOC freed 356 objects / 238848 bytes in 77ms D/dalvikvm( 6295): GC_FOR_MALLOC freed 357 objects / 238944 bytes in 59ms D/dalvikvm( 5388): GC_EXPLICIT freed 217 objects / 11488 bytes in 90ms D/dalvikvm( 6295): GC_FOR_MALLOC freed 352 objects / 238728 bytes in 53ms D/dalvikvm( 6295): GC_FOR_MALLOC freed 352 objects / 238728 bytes in 65ms D/dalvikvm( 6295): GC_FOR_MALLOC freed 352 objects / 238728 bytes in 75ms D/dalvikvm( 6295): GC_FOR_MALLOC freed 352 objects / 238728 bytes in 76ms D/dalvikvm( 6295): GC_FOR_MALLOC freed 352 objects / 238728 bytes in 62ms V/dk.nindroid.rss.RiverRenderer( 6295): Orientation change received: 0 W/KeyCharacterMap( 6295): No keyboard for id 65540 W/KeyCharacterMap( 6295): Using default keymap: /system/usr/keychars/ qwerty.kcm.bin D/MobileDataStateTracker( 88): replacing old mInterfaceName (rmnet0) with rmnet0 for dun D/MobileDataStateTracker( 88): replacing old mInterfaceName (rmnet0) with rmnet0 for hipri D/MobileDataStateTracker( 88): supl Received state= CONNECTED, old= CONNECTED, reason= (unspecified), apnTypeList= * D/MobileDataStateTracker( 88): replacing old mInterfaceName (rmnet0) with rmnet0 for mms D/MobileDataStateTracker( 88): default Received state= CONNECTED, old= CONNECTED, reason= (unspecified), apnTypeList= * D/NetworkLocationProvider( 88): onDataConnectionStateChanged 3 W/SharedBufferStack( 88): waitForCondition(LockCondition) timed out (identity=2, status=0). CPU may be pegged. trying again. W/SharedBufferStack( 88): waitForCondition(LockCondition) timed out (identity=2, status=0). CPU may be pegged. trying again. W/SharedBufferStack( 88): waitForCondition(LockCondition) timed out (identity=2, status=0). CPU may be
[android-developers] Re: Device Seeding Program for Top Android Market Developers
Fed-ex came, and delivered. For some reason they had been trying to deliver the phone to 21, 5B instead of 215B on the same road, resulting in a two week delay I finally got it, though, and am filled with joy! Thank you Google overlords! :D On May 9, 1:15 am, TreKing treking...@gmail.com wrote: On Thu, May 6, 2010 at 2:28 AM, Lorents iva...@gmail.com wrote: @TreKing - Wow, this thread is really bugging you... Ha! The thread itself is not the problem - it's the flood of me too comments that were artificially inflating my RSS feed. I just can't help commenting on the absurdity of it all - or responding to comments directed at me =P BTW, I have had my phone a few days now and its awesome. Everyone else happy with theirs? (lol) Jerk. =P - TreKing - Chicago transit tracking app for Android-powered deviceshttp://sites.google.com/site/rezmobileapps/treking -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Device Seeding Program for Top Android Market Developers
Still haven't received anything in Denmark. I'm hoping they'll send out the next batch soon. :) On May 4, 1:14 pm, Trygve trygv...@gmail.com wrote: Received mine today in Trondheim, Norway. Thanks Google! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Device Seeding Program for Top Android Market Developers
How do you see this? What do you search for? On Apr 29, 11:45 am, David Horn pga...@gmail.com wrote: Fedex UK shows mine in transit and due for delivery tomorrow in the UK. :-) On Apr 29, 10:06 am, Benjamin Rosseaux benja...@rosseaux.com wrote: I got mine now also in Moenchengladbach, Germany. :-) On 29 Apr., 10:30, Paul stuem...@gmail.com wrote: \o/ Just got mine in Bremen, Germany. (Fedex/ Brightpoint Netherlands) On 29 Apr., 10:18, Lim Sim lim@gmail.com wrote: OK. Now you've got me excited. I'm in UK too! haha. On 29 April 2010 09:14, mscwd01 mscw...@gmail.com wrote: Yes! Thanks Google. My Nexus One arrived via FedEx today. I live in the UK and it was shipped via Brightpoint Netherlands. Thanks again! On Apr 29, 9:07 am, cannehal tomasz.l...@gmail.com wrote: Here is link to map. You can add your location (not exact of course) there when you receive your phone. http://maps.google.com/maps/ms?ie=UTFmsa=0msid= 109593402120975111968.0004855b7d8eefa5f649b On Apr 29, 10:02 am, ratson materem...@gmail.com wrote: WOW i just got confirmation from local FedEx, my N1 will arrive today or by latest tomorrow :) i have called them and told the destination address, so they could tell me the tracking number. thank you google ;) On ápr. 29, 09:40, ratson materem...@gmail.com wrote: I think this is the time when you shall really post to this forum if you have received your N1. :) someone has the time to create a gmaps mashup? :) patiently waiting for mine in Hungary On ápr. 29, 09:35, Benjamin Rosseaux benja...@rosseaux.com wrote: How long have you waited for it? On 29 Apr., 09:03, Kevin Gaudin kevin.gau...@gmail.com wrote: Nexus One received in France ! No FroYo but a french power adapter :) Sent by Brightpoint from netherland via France Express. THANK YOU GOOGLE On 29 avr, 07:36, Jompe71 jonas.ahnl...@bostream.nu wrote: -The only way to get a free phone from Apple is to go and get a drink with Gray Powell. Hmmm, last time I checked Apple didn't promise one either! What Google is up to with this seeding joke (which obviously is nothing) it's ignorance, pure and simple. Fake promises are far more worse than no promises. I'm off to IPhone! On 28 Apr, 09:37, amiuhle timouhlm...@googlemail.com wrote: On 27 Apr., 22:25, Olivier Bonal olivier.bo...@gmail.com wrote: The only way to get a free phone from Apple is to go and get a drink with Gray Powell. Haha, great one! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs cr...@googlegroups.com For more options, visit this group athttp:// groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs cr...@googlegroups.com For more options, visit this group athttp:// groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs cr...@googlegroups.com For more options, visit this group athttp:// groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs cr...@googlegroups.com For more options, visit this group athttp://
[android-developers] Re: Device Seeding Program for Top Android Market Developers
Still haven't received anything, but waiting patiently. :) I got rewarded for Floating Image that had about 10K downloads at the time, now about to surpass the big 50K. On Apr 24, 10:55 am, David Horn pga...@gmail.com wrote: Possibly PHTP over RFC 1149. ;-) On Apr 24, 8:45 am, Lim Sim lim@gmail.com wrote: Lets hope there are no lost packets. On Apr 24, 2010 4:04 AM, Bob Kerns r...@acm.org wrote: I think what you're seeing is a rocky roll-out of the new PHTP (PHone Transfer Protocol). Perhaps the longer transcontinental network latency was causing protocol timeouts? On Apr 23, 7:07 am, Kevin Gaudin kevin.gau...@gmail.com wrote: Having them SAY that they sent the devices doesn't mean they DID... if something bigger needs to... -- You received this message because you are subscribed to the Google Groups Android Developers g... -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] How do I control when to open the context menu myself?
I'm writing a program where the user's finger will often linger on the screen for more than the couple of seconds it takes for the context menu to activate. I have a class that controls when this should happen, but I seem to be unable to launch the context menu manually. As a last resort I decided to register the context menu just before running openContextMenu(View), and while this /did/ grant me a context menu, it subsequently disabled the calls to onTouchEvent when the user touches the screen, rendering the program unusable after showing the context menu. So... What is the correct way of manually opening the context menu? Why does onTouchEvent suddenly stop receiving events? Regards, - Mark Gjøl -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Bug in GL10.texSubImage2D?
Thank you for that elaborate response. Your assumptions were all correct (and I _did_ do a little too much work when I called texImage2D, I only really needed to do that once, not every time I updated the texture). I now make a Canvas, which I draw my dynamic bitmap to, and just bind that texture with texImage2D without using texSubImage2D. This works perfectly, however, I feel a slight lag (although I haven't done any performance tests on it) when I change the texture, that I didn't notice before. I am certain my textures are at most 100x100 but usually smaller on one dimension. As I don't replace the entire texture, but only a portion of it, texSubImage2D might be the faster choice - if only it worked. Also, I didn't get any GL errors (gl.getError()) when using texSubImage2D. So what's left for me is this: * Is drawing the image to a canvas using drawBitmap the fastest way to make a npot texture pot? * Is texSubImage2D broken, in which case I should report it? Regards, Mark Gjøl On Sep 21, 2:32 am, Robert Green rbgrn@gmail.com wrote: I'm a little confused by what you're doing. You're first calling texImage2D, which uploads mImg to vram as your texture. The very next call you make is texSubImage2D with an offset of 0 and 0, which uploads texture to vram, overwriting mImg. I'm assuming that: 1) mImg is 128x128 2) You first upload mImg to allocate a space as big as mImg 3) None of your textures are greater than mImg's width or height I'm going to suggest you change your code to do the following: 1) Create a bitmap of 128x128 or whatever size is appropriate for each dynamic texture, unless you have many different images you want to use. 2) Draw your texture to that bitmap 3) Upload that texture using regular texImage2D (in my tests, it's faster for full-size updates than using texSubImage2D). 4) If using one scratchpad bitmap, just erase it and reuse. Remember to .recycle() when done with it. basically, I suggest that you only upload once to vram and do any pre- processing on the client-side using a Bitmap or many Bitmaps depending on your app/game. That's how I do it. You can texImage2D the same textureId as many times as you like. Also, I recommend using GL_NICEST for perspective correction when dealing with large projected quads. It's not as fast as GL_FASTEST but for big triangles, it's the only way to guarantee they won't get really weird when cut off at near-Z. I have renderer classes that render game objects for my games. My renderers all look like this: public MyRenderer(GL10 gl) { // read geometry from disk resource reInit(gl); } public void reInit(GL10 gl) { // create VBOIds // upload VBOs // create textureIds // upload textures } public void draw(GL10 gl, GameObject obj) { // bind VBOs and TextureIds // transform for obj // draw elements } so if I wanted a dynamic texture, I'd just add in this: public void setTexture(GL10 gl, Bitmap texture) { // bind to appropriate textureId // upload whichTex } though I'd never let the main renderer hang on to bitmaps that an object render will be drawing - I would be managing that in the object renderer, so probably passing a sort of pointer or configuration, usually in the form of an int constant, like: public static final int TEXTURE_HAPPY_FACE = 0; public static final int TEXTURE_ANGRY_FACE = 1; public void setTexture(GL10 gl, int whichTex) { // bind to appropriate textureId // upload bitmap associated with whichTex if (whichTex == TEXTURE_HAPPY_FACE) { // upload happy face bitmap that we loadad probably in our constructor or somewhere before runtime. } } I know I'm not solving your exact problem, but I think if you followed this, you wouldn't have it anymore. If you want to stick with what you've got, throw some debug statements in there to print out the image size and the texture coordinates so you can make sure that it's not just a problem with those. If they look exactly right, Just make sure you're not doing something goofy like uploading an image that's bigger than the original. On Sep 20, 4:53 pm, Mark Gjøl bitflips...@gmail.com wrote: I am developing an application that dynamically changes the texture of an object. The textures I download from the internet and are of fairly random aspect ratios. I apply these textures to a 2^nth texture using GLUtils.texSubImage2D supplying the bitmap containing the texture, and only use the part of the constructed texture that holds the newly applied data. This works fine when using textures with a greater width than height. However, when using tall images, I sometimes get images that are skewed. That is, it seems as if the texture is copied to the new texture, but with the width being one off, so each line just one pixel too short. This happens consistently when using the same images, however it does not happen for all tall images. Code
[android-developers] Bug in GL10.texSubImage2D?
I am developing an application that dynamically changes the texture of an object. The textures I download from the internet and are of fairly random aspect ratios. I apply these textures to a 2^nth texture using GLUtils.texSubImage2D supplying the bitmap containing the texture, and only use the part of the constructed texture that holds the newly applied data. This works fine when using textures with a greater width than height. However, when using tall images, I sometimes get images that are skewed. That is, it seems as if the texture is copied to the new texture, but with the width being one off, so each line just one pixel too short. This happens consistently when using the same images, however it does not happen for all tall images. Code for applying the texture: public void setTexture(GL10 gl, Bitmap texture) { int height = texture.getHeight(); int width = texture.getWidth(); float heightRatio = ((float)height) / 128; float widthRatio = ((float)width) / 128; maspect = width / (float)height; int[] textures = new int[1]; gl.glGenTextures(1, textures, 0); mTextureID = textures[0]; gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE); gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_BLEND); GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, mImg, 0); GLUtils.texSubImage2D(GL10.GL_TEXTURE_2D, 0, 0, 0, texture); Buffer texBuf = ByteBuffer.allocateDirect(texture.getRowBytes () * height); texture.copyPixelsToBuffer(texBuf); ByteBuffer tbb = ByteBuffer.allocateDirect(VERTS * 2 * 4); tbb.order(ByteOrder.nativeOrder()); mTexBuffer = tbb.asFloatBuffer(); float tex[] = { 0.0f, 0.0f, 0.0f, heightRatio, widthRatio, 0.0f, widthRatio, heightRatio, }; mTexBuffer.put(tex); mTexBuffer.position(0); } Code for drawing it to screen: public void draw(GL10 gl, long offset){ if(maspect 1.25f){ szX = maspect; szY = 1; }else{ szX = 1.25f; szY = 1 / maspect * 1.25f; } gl.glTexEnvx(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_REPLACE); gl.glActiveTexture(GL10.GL_TEXTURE0); gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID); gl.glFrontFace(GL10.GL_CCW); gl.glVertexPointer(3, GL10.GL_FIXED, 0, mVertexBuffer); gl.glEnable(GL10.GL_TEXTURE_2D); gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTexBuffer); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,GL10.GL_NEAREST); gl.glTexParameterf (GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MAG_FILTER,GL10.GL_LINEAR); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,GL10.GL_CLAMP_TO_EDGE); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,GL10.GL_CLAMP_TO_EDGE); gl.glPushMatrix(); gl.glTranslatef(x, y, z); gl.glScalef(szX, szY, 1); gl.glDrawElements(GL10.GL_TRIANGLE_STRIP, 4, GL10.GL_UNSIGNED_BYTE, mIndexBuffer); gl.glPopMatrix(); } This is really bugging me, so any help would be great! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---