EasyCoder

Member
  • Content count

    53
  • Joined

  • Last visited

Community Reputation

116 Neutral

About EasyCoder

  • Rank
    Member
  1. I have spent on this problem now over a week, took the whole class apart, modified, changed parameters, removed bits which I thought could cause the problem... No improvement. Re-sampled all sounds to the lowest sampling rate possible... No improvement either.   I am getting really fed up with this problem and starting to think I might dump the whole unreliable SoundPool and replace it with some other way of playing sounds...   Does anybody have any suggestions as to what is the best and most reliable way of playing sounds in Android? (not music - short sound effects).
  2.   It happens immediately after start of the app, when I attempt to play the first sound.
  3. In my Android game, I am playing short sound effects using AudioManager and SoundPool.   While this works fine on Samsung Galaxy Tab 10.1, when I ported the game to Samsung Galaxy SIII, I am experiencing strange lock-ups of the screen and crashes of the application with re-booting of the phone, when I am trying to play the sound from the SoundPool.   It behaves quite erratically and one of 4 things happen (in no particular order):   (1) Application starts as normal and all sounds play normally.   (2) Application crashes completely and mobile reboots.   (3) Application freezes shortly (3-5 seconds) upon trying to play the sound, then continues normally, but sounds don't work.   (4) Application starts as normal, but none of the sounds plays. *   * There is a strange twist to the 4th case. None of the sounds plays, but when I activate game background music (which plays via MediaPlayer, not via AudioManager/SoundPool) this somehow 'flushes down' the stuck sound effects which should play at the beginning of the game, and now they all catch-up and play at once. This 'flushing down' somehow returns everything back to normal and from this point on all the sound effects from the SoundPool play normally, as they should.   The error which I am getting is:   AudioTrack: obtainBuffer timed out (is the CPU pegged?) "CPU pegged" what the hell does it even mean ???   Note that the problems happen at the point in the game when I am attempting to play the sounds from the soundpool by SoundPool.play, not when I am loading them by SoundPool.load.   I tried just about everything and now I am at the end of my wits. Did anybody have the same problem? Any help is highly appreciated.    
  4. glRotatef behaves strange

    Cool - so then this topic can be closed [img]http://public.gamedev.net//public/style_emoticons/default/rolleyes.gif[/img]
  5. glRotatef behaves strange

    [quote name='dpadam450' timestamp='1343321133' post='4963362'] Use glOrtho instead of gluPerspective. If you hold your hand 45 degrees like the image and put it far left of your head and them move it towards the right, you will see the same thing. On the left your hand is facing you, on the right it is facing away from you and distorted because you are looking down the side of the hand and cant see the front anymore. [/quote] Yes, your explanation makes perfect sense to me. And gluOrtho2D works like a charm ! [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Now all 15 objects rotate exactly at the same angle. Thanks for your help & suggestion. Only one more question: can you swap back and forth between gluOrtho2D and gluPerspective within the onDrawFrame ? This is for a game which I am developing, and the engine is already finished and working fine in gluPerspective, so I am not very keen to change it to gluOrtho2D. I just want to do that rotation effect in gluOrtho2D, then get rid of the objects and swap back to gluPerspective. Is this possible ?
  6. glRotatef behaves strange

    [quote name='Brother Bob' timestamp='1343295254' post='4963229'] If those quads are rotated 45 degrees about the Y-axis, then the only reason I can see for that behaviour is normal perspective effects. Objects to the left will be viewed more from the right that centered objects and thus appear, due to perspective, slightly narrower. Think of a cube; the further to the right on the screen the cube is, the more of its left side you can see. They are not rotated, but perspective shifted. [/quote] I see. Is there any way to change the perspective, so they all appear the same ?
  7. glRotatef behaves strange

    [attachment=10267:glRotatef-y.jpg] So this is how it looks like, when I use the above code. I am using GL_MODELVIEW in glMatrixMode and [i]fovy [/i](field of view angle in y direction) in gluPerspective is set to 45.0f. Could it have anything to do with [i]fovy[/i], as it is also in y direction ? [img]http://public.gamedev.net//public/style_emoticons/default/unsure.png[/img]
  8. glRotatef behaves strange

    [quote name='Brother Bob' timestamp='1343221346' post='4962919'] It sounds very much like you [i]are[/i] accumulating rotations for each object. Show how you're doing the transformations, because it sounds like you're not resetting the rotations between the objects, but rather keep accumulating rotations. [/quote] This is how the code looks like: while (column <= 15) { gl.glLoadIdentity(); gl.glPushMatrix(); gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); gl.glEnable(GL10.GL_BLEND); gl.glTranslatef(column, row, -5.0f); gl.glRotatef(45.0f, 0.0f, 1.0f, 0.0f); gl.glScalef(0.25f, 0.25f, 0.0f); object.draw(gl, bitmap_index); gl.glPopMatrix(); } The 15 objects are identical 2D squares with the same bitmap mapped on them.
  9. glRotatef behaves strange

    [quote name='Brother Bob' timestamp='1343221346' post='4962919'] It is happening on all axes. You say you're rotating about the Y-axis, so if you're not rotating about the X or Z-axes, then of course you're not going to accumulate any rotation on those axes either. [/quote] No, you did not get me - [b][i]it is not happening[/i][/b] on all the axes - that is the weird thing. Of course I meant it is not happening when I rotate around those two axes, i.e. when I use: gl.glRotatef(45.0f, 1.0f, 0.0f, 0.0f) or gl.glRotatef(45.0f, 0.0f, 0.0f, 1.0f) All 15 objects rotate at the same angle, no accumulation there. And the code is the very same - that is what confuses me.
  10. glRotatef behaves strange

    [quote name='EasyCoder' timestamp='1343146057' post='4962638'] [quote name='dpadam450' timestamp='1343145700' post='4962635'] You have to reset the rotation or "the modelview matrix". each rotation adds up if you dont call glLoadIdentity(). [/quote] I of course use glLoadIdentity as well as glPushMatrix & glPopMatrix. [/quote] Yes, after some experimenting I found that the rotations really ad up. I started with glRotatef(45.0f, 0.0f, 1.0f, 0.0f) and I got objects on the right side of the screen rotated the most and on left side the least (just what would you expect if the rotations gradually add up) Just to confirm that, I then tried gl.glRotatef(675.0f, 0.0f, 1.0f, 0.0f) (as I have 15 objects => 15 * 45 = 675) and lo and behold, now it was opposite - i.e. objects on the left side of the screen were rotated the most and on right side the least !!! So that is clear. Now there are just 2 questions remaining: 1) Why is this not happening with [i][b]x[/b][/i] or [i][b]z[/b][/i] axis, only with [b][i]y[/i][/b] ?!? [img]http://public.gamedev.net//public/style_emoticons/default/blink.png[/img] 2) How to avoid this adding-up of rotation ?
  11. glRotatef behaves strange

    [quote name='dpadam450' timestamp='1343145700' post='4962635'] You have to reset the rotation or "the modelview matrix". each rotation adds up if you dont call glLoadIdentity(). [/quote] I of course use glLoadIdentity as well as glPushMatrix & glPopMatrix.
  12. I have several 2D objects (simple squares with bitmaps on them) which I need to rotate on y axis (i.e. from left to right) all at the same angle. However, when I use glRotatef command, the objects on the right side of the screen are rotated the most, and progressively towards the left side of the screen, they rotate less and less. If I have let say 15 objects side-by-side, the difference in rotation between the leftmost and rightmost object is quite substantial and clearly visible. I assume this is something to do with the perspective, but cannot figure out what I am doing wrong. Just for interest, if I rotate the same objects on x axis (i.e. from forward to backward) the angle is the same for all of them ! Anybody knows how to achieve rotation at the same angle for all the objects on y axis ? Thanks in advance for any suggestions.
  13. [quote name='Murdocki' timestamp='1330443042' post='4917402'] your texture wrap mode is probably set to clamping, you'll need to set that to repeat. look at glTexParameterf.[/quote] I have tried all combinations of GL_CLAMP_TO_EDGE and GL_REPEAT for S and T coordinates without any change. But thanks for pointing me in this direction, because I have looked on the tutorial where I took some of the code from, again and found this comment by someone: [b][size=3][i]I was trying to implement a similar functionality using glDrawArrays. However, I’m unable to get it running on Android. I’m trying port an existing iPhone application to Android. The same openGL code works fine on iPhone.[/i][/size][/b] I am also using glDrawArrays, so I suspect this will be the root of my problem. I will try replacing glDrawArrays with glDrawElements and see if that makes any difference.
  14. I am returning to this problem after long time as I still haven't quite cracked it. I already thought I have figured it out. When I gradually increase roll variable, texture nicely rolls over the object (square) as desired. [b]float[] texCoords = { 0.0f, 1.0f + roll, [/b] [b]// A - left-bottom 1.0f, 1.0f + roll, [/b] [b]// B - right-bottom 0.0f, 0.0f + roll, [/b] [b]// C - left-top 1.0f, 0.0f + roll [/b] [b]// D - right-top };[/b] However, only in the emulator (on Eclipse). If I run the same code on the actual device, the texture does not roll continuously over the square (what I am trying to achieve), but scrolls of the square gradually completely until it disappears. For better understanding, instead of desired effect: from this: 000XX000 00X00X00 0X0000X0 X000000X to this: 00X00X00 0X0000X0 X000000X 000XX000 [b]I get:[/b] 00X00X00 0X0000X0 X000000X X000000X then: 0X0000X0 X000000X X000000X X000000X then: X000000X X000000X X000000X X000000X Basically, I get scrolling, instead of rolling [img]http://public.gamedev.net//public/style_emoticons/default/sad.png[/img] I suspect it is something in the way how I am wrapping the texture over the square, but I cannot figure out what parameter I have to change to get the desired rolling effect. Anybody has tried this already before and knows how to achieve the rolling of the texture over the square ? What I am trying to achieve is that the topmost line of pixels will be removed, all lines will be shifted 1 pixel up, and the topmost line of pixels will be added at the very bottom, etc, etc... until the texture ends up in original state, and then the whole process starts again. Thanks for any help.
  15. [quote name='Fiallen' timestamp='1328277164' post='4909154']The method to load a bitmap takes the context which is readily available in the Activity.[/quote] Of course !!! [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Sometime you are looking for a solution and cannot see that which is right under your nose. It is because I program in Android / Java environment only a couple of months and still cannot get used to some of its quirks. I am now loading the level-dependent bitmaps via functions in Activity, but I am calling these from my main game loop which is in onDrawFrame. I did not use your approach of writing the dedicated class for handling the bitmaps (though it may be neater solution) as my game is now 99% finished and this would mean substantial rewriting of everything and further delays with finishing the game. Application still struggles at the startup, going as low as 1% of the available memory (as in above log), but then recovers and increases to some 74% - that with 95% of all bitmaps required for the game already in. I am a bit concerned about this startup struggling, but I have run it yesterday about 50 times on the actual device and it did not go OOM a single time, so I guess this is some inherent feature of Android. Thank you for all your help and patience Fiallen ! [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]