Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Android / Can anyone help me with this?

Author
Message
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 17th Dec 2011 14:24 Edited at: 17th Dec 2011 14:26
What could the problem be that it shows up like this on the android device?
Iam completely stuck?
I have tryed all kind of solutions

Attachments

Login to view attachments
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 17th Dec 2011 16:54
you mean dark or what?

please make your issue more clear

Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 17th Dec 2011 20:31 Edited at: 17th Dec 2011 20:59
Quote: "you mean dark or what?

please make your issue more clear "

Where did the rest go on android

Are sitting now an crushing buggs with the player

The android player only supports 63 frames on an sprite.
Iam checking waths wrong compared to the pc version with the last column rendered.

pc version sprite frame is 207.
Android player frame is 63.
Going to check some more!

It detects the column height to 312 on pc.
on android so do it detect 31865 .


I have found that float values is totally screwed upp in the player
This kills my project so far

Attachments

Login to view attachments
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 17th Dec 2011 21:55
So its not diaplaying?... Hmm memory issue?

Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 17th Dec 2011 22:40 Edited at: 17th Dec 2011 22:42
Quote: "So its not diaplaying?... Hmm memory issue?"

Seams more to be something extremely wrong with floats?

Its the float values that gets screwed up somehow?

I even tryed to use types but it dosent help.

this works on my pc but fails on android?
Something when mixing floats and integer maybe?
But almost all float calculations gets wrong?
if player.Y>newY# then TextureX = ( (newX#*(TextureScale-1)) - (newX*(TextureScale-1)) ) + (TextureScale/2)+1
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 17th Dec 2011 23:41
Have you tested it on an other device? If you send it to me, I can test on my galaxy note...
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 18th Dec 2011 00:05
Quote: "Have you tested it on an other device? If you send it to me, I can test on my galaxy note... "


Then do i nead to do some mobile controls again as i removed them!

Check the raycasting thread tomorow as iam in an really bad mood currently and will take a break for the rest of the night.

Iam on my way to kill the project after reading this!

http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

Whenever you do small float calculations on android so will you get various results.

There is even some differrence depending on wath cpu the device have

so if i dont rewrite it all to maybe use larger numbers so will it fail on most devices?
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 18th Dec 2011 09:25
Quote: "Then do i nead to do some mobile controls again as i removed them!

Check the raycasting thread tomorow as iam in an really bad mood currently and will take a break for the rest of the night.

Iam on my way to kill the project after reading this!

http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

Whenever you do small float calculations on android so will you get various results.

There is even some differrence depending on wath cpu the device have

so if i dont rewrite it all to maybe use larger numbers so will it fail on most devices?"


That sounds realy bad, would be a shame for a amazing project like this to fail.
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 18th Dec 2011 10:19
I suspect part of this problem is AppGameKit using single float types. The tiny differences between different FPUs are reduced using doubles. I haven't used a small float for about a hundred years!

-- Jim
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 18th Dec 2011 23:36
Quote: "I suspect part of this problem is AppGameKit using single float types. The tiny differences between different FPUs are reduced using doubles. I haven't used a small float for about a hundred years!"

Iam forced to use small floats in my raycaster so the project is dead until i can solve it
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 19th Dec 2011 08:37 Edited at: 19th Dec 2011 08:43
Couple of things:

if player.Y>newY# then TextureX = ( (newX#*(TextureScale-1)) - (newX*(TextureScale-1)) ) + (TextureScale/2)+1

Do you really mean to change the X value in response to Y?

Have you got any direct equality tests? For example if x#=0.0?
Floating point cannot be used like this. It may be 0.00000000000001 or something. You need a function with a small delta range which you know will be precise enough - something like this in Pascal;

function FloatEquals(const A,B,Delta):boolean;
begin
result := false;
if abs(abs(A) - abs(B))<Delta then result:=true;
end;

Delphi has this as a standard function CompareValue() which returns -1 for smaller, 0 for = and 1 for greater.

-- Jim
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 19th Dec 2011 16:50
Quote: "if player.Y>newY# then TextureX = ( (newX#*(TextureScale-1)) - (newX*(TextureScale-1)) ) + (TextureScale/2)+1

Do you really mean to change the X value in response to Y?"

This is that i compare the position of the player and the ray

I whas forced to switch how i did the math depending on whath position the player have compared to the ray hit cordinate.

I do this to get smoother texturing as it gets pixelated in some angles if i dont.

Math is not my strong point

Quote: "Have you got any direct equality tests? For example if x#=0.0?
Floating point cannot be used like this. It may be 0.00000000000001 or something. You need a function with a small delta range which you know will be precise enough - something like this in Pascal;

function FloatEquals(const A,B,Delta):boolean;
begin
result := false;
if abs(abs(A) - abs(B))<Delta then result:=true;
end;"


I havent bin thinking about it like that
I know wath you mean i belive?

Limit the length of the float value?
Or only use it if its high enough?

If android returns longer floats so could it be the problem?

I will try some math later today but iam really bad with math.
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 19th Dec 2011 23:01
As far as I know all the platforms conform to IEEE floating point, even if it is emulated in software on Android devices.

The important point to remember is that floating point accuracy is measured in significant figures rather than decimal points. For example 0.0000000014567 and 13753000.0 both have 5 significant figures and can be represented (in base 10) as 1.4567 x 10^-9 and 1.3753 x 10^7 but 13753000.000000014567 has 20 significant figures so would not be accurately represented in floating point. But I would expect this to behave similarly on PC and Android.

It could be something to do with power of 2 textures, Android converts it's images to power of two size with black border padding whereas the PC does not (unless using mipmaps) if you use SetGenerateMipmaps(1) in the PC version does it display the same problem?
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 19th Dec 2011 23:56
Paul - that could well be the answer. Cliff said earlier:

"It detects the column height to 312 on pc.
on android so do it detect 31865 ."


Looks like that is really 31.865 - which, rounded up would be 312.

-- Jim
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 20th Dec 2011 00:19
Quote: "It could be something to do with power of 2 textures, Android converts it's images to power of two size with black border padding whereas the PC does not (unless using mipmaps) if you use SetGenerateMipmaps(1) in the PC version does it display the same problem? "

Pc version looks the same

Quote: "Paul - that could well be the answer. Cliff said earlier:

"It detects the column height to 312 on pc.
on android so do it detect 31865 ."

Looks like that is really 31.865 - which, rounded up would be 312."

Jim hit the nail on the head

I dont understand much of wath you guys are typing when it comes to math but i understand the last thing jim wrote
So its something with how it rounds up floats on android compared to pc.

Could it it be how its written in the core of android compared to windows?
I know that you can write the float calculations in the core in many ways?

But the big question is how i workaround it?
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 20th Dec 2011 15:48
Quote: "Pc version looks the same"


If by same you mean it shows the same problem, then you should be able to fix it by making all your images power of 2 in size, or figuring out which command doesn't like the non-power of 2 images and I'll fix it.
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 20th Dec 2011 16:42
Quote: "If by same you mean it shows the same problem, then you should be able to fix it by making all your images power of 2 in size, or figuring out which command doesn't like the non-power of 2 images and I'll fix it. "

No !
Sorry i whas tired
I mean it looks as it should even if i use that command.

The problem seams to be how android and pc rounds up floats?

Android rounds it up pretty weird sometimes?

I will take a look and see if i can go around this somehow?
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 20th Dec 2011 17:46 Edited at: 20th Dec 2011 17:47
Thanks to your help paul and jim
That have explaine a few new ideas about floats

I think i have managed to narrow the problem down to this

After reading your posts about rounding floats.

So did i start to go thru the code and belive i found the problem!

It seams to be when i use floats to get an integer number that messes things up.
I have always done it like this before and it have worked but seams to be an issue on android.

i do this a couple of times in the raycaster.

newX = player.x +(cos(StartAngle#) * move# )
newY = player.y + (Sin(StartAngle#) * move# )

And when i add the ceil command so does android and pc show exactly the same distorted grafix.
They look exactly the same!
newX = ceil(player.x +(cos(StartAngle#) * move# ))
newY = ceil(player.y + (Sin(StartAngle#) * move# ))
Both android and pc looks the same now!

newX = ceil(player.x +(cos(StartAngle#) * move# ))
newY = ceil(player.y + (Sin(StartAngle#) * move# ))

I will see if i find an command that does the right rounding on both android and windows.

Attachments

Login to view attachments
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 20th Dec 2011 18:06 Edited at: 20th Dec 2011 18:08
With the trunc command so do the pc version look exactly the same
trunc=Returns the integer part of a float value with no rounding either way.
as the android error
Iam getting closer!
Round dosent work anyhow.

Attachments

Login to view attachments
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 20th Dec 2011 22:23 Edited at: 20th Dec 2011 22:24
Thanks again paul and jimhawkings for all the help

I think iam starting to get somewhere now?

I wrote an function that seam to work partially.
Nead to finetune it some more.
As some textures are scrambled on some walls still.

It seams like android screws up the math when you do float calculations to get an integer value.

If you could help me improve the function so would you make me extremely happy

This is the first prototype of my android fix.

function AndroidFix(CheckVal#)
// 1.( 0-9 ) = 1
TempInteger = trunc(CheckVal#)
// up to nearest integer
if TempInteger+0.51<CheckVal# then Result#=ceil(CheckVal#)
// down to nearest integer
if TempInteger+0.51>CheckVal# then Result#=floor(CheckVal#)
endfunction Result#

Attachments

Login to view attachments
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 20th Dec 2011 22:54 Edited at: 20th Dec 2011 22:56
No nead anymore

It looks the same on android and pc now


Maybe something tgc could add as an agk command as its really simple and we know its an problem!




Thanks for all the help and its why we love the forums

I have random wall texturing on the walls thats why they have differrent textures on android and pc.

Attachments

Login to view attachments
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 20th Dec 2011 23:05
Awsome, glad to see the project back in action!
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 20th Dec 2011 23:21
Quote: "Awsome, glad to see the project back in action! "

Its thanks to jimhawkings and paul that gave me the idea
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 21st Dec 2011 01:34
Nicely done, I investigated the Round() function on android and it did indeed contain a bug (it would always round down). I've fixed it and uploaded a new version of the player to the android market.
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 21st Dec 2011 03:18
@Paul AWESOME... will download now!

JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 21st Dec 2011 10:28
Glad to help!

It's worth everybody noting that there may be differences in floating point results on different platforms and compilers. One reason is that some will internally promote the resolution before performing the calculations and others may not. For example, Delphi internally promotes singles and doubles to extended, does the operation, then adjusts the output. The Android may or may not do this.

It may be necessary to check the order of calculations and break things down into smaller steps to avoid overflow with potentially very big multiplies and divides.

-- Jim
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 21st Dec 2011 16:57
Quote: "Nicely done, I investigated the Round() function on android and it did indeed contain a bug (it would always round down). I've fixed it and uploaded a new version of the player to the android market. "

Will download now
Nice to be able to help

Login to post a reply

Server time is: 2024-04-20 02:48:32
Your offset time is: 2024-04-20 02:48:32