Android Tutorial Introduction to the libGDX library

Informatix

Expert
Licensed User
Longtime User
ByteBuffer is not usable by a B4A user.
 

wonder

Expert
Licensed User
Longtime User
So that would be the fastest solution...
Using FastIO for sending GetDefaultFrameBufferPixels to the specified destination. Correct?

You mentioned zipping the data. Wouldn't this slowdown the operation a lot, since it would be called 60 times per second? If not, which lib should I go with?
 

Informatix

Expert
Licensed User
Longtime User
Unless you have a communication channel beween the two devices that allows to transfer directly bytes (the file would be no longer needed).
 

wonder

Expert
Licensed User
Longtime User

wonder

Expert
Licensed User
Longtime User
Sorry to double-post, but please tell me, would this code work?
B4X:
public static byte[] GetDefaultFrameBufferPixels (int X, int Y, int Width, int Height)
{  
    final ByteBuffer pixels = BufferUtils.newByteBuffer(Width * Height * 4);
    Gdx.gl.glPixelStorei(GL20.GL_PACK_ALIGNMENT, 1);
    Gdx.gl.glReadPixels(X, Y, Width, Height, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, pixels);  
    pixels.clear();
    return pixels.array();
}
 

Informatix

Expert
Licensed User
Longtime User
Why don't you try it? It's the best way to know.
 

wonder

Expert
Licensed User
Longtime User
I thought you could want to give it a try (could be implemented as GetDefaultFrameBufferPixels2).
Not that is better than yours, but as it has less lines of code it could perform a tiny bit faster...

I know that LibGDX (B4A) is not open-source but I just wanted to contribute.
 

Informatix

Expert
Licensed User
Longtime User
No, I won't add it because it's too specific and I'm not convinced that you will get a significant boost to performance.
 

ilan

Expert
Licensed User
Longtime User
hi @Informatix (i am pointing this question to you because you wrapped the wonderful libgdx lib and only u can answer this questions)

question1:

i see a lot of tutorials in the net where you can do something like this:

vec2A = vec2B - vec2C

get a vector from calculating 2 other vectors but in b4a libgdx it is not working i am getting an "type does not match" error.
is this a limitation?

question2:

i have in my latest box2d game 2 dynamic bodies that both are connected with a distanceJoint to a separate static body

and i let them swing. (something like this)




now the problem is when they collide on a specific force one of the dynamic body loose the joint and start flying very fast all over the screen.
is this a bug? or am i doing something wrong?

if you need a sample project that demonstrate this behavior let me know.


thanks in advance, ilan
 
Last edited:

ilan

Expert
Licensed User
Longtime User
regarding to my last question post #252. question 2 in not relevant, sorry it was my mistake joint works as expected.
 

wonder

Expert
Licensed User
Longtime User
Not sure if it helps but...

Generally speaking, you can sum/subtract vectors like this:
B4X:
'Pseudocode:

'Deconstruct Vector A into XY components
- VecA_x = cos(VecA_angle) * VecA_magnitude
- VecA_y = sin(VecA_angle) * VecA_magnitude

'Deconstruct Vector B into XY components
- VecB_x = cos(VecB_angle) * VecB_magnitude
- VecB_y = sin(VecB_angle) * VecB_magnitude

'Sum/Subtract XY components
- VecC_x = VecA_x + VecB_x
- VecC_y = VecA_y + VecB_y

'Construct vector C
- VecC_angle     = atan2(vecC_y, vecC_x)
- VecC_magnitude = sqrt(vecC_x^2 + vecC_y^2)

I think there are more ways to do it, by the way...

 

ilan

Expert
Licensed User
Longtime User

wimpie3

Well-Known Member
Licensed User
Longtime User
I've noticed that when I use lgmusic.play, the first 100ms are sometimes dropped (not always, about 80% of the time). Anything I can do about this? Can this be a hardware problem?
 

rkwan

Member
Licensed User
New
Hello, I am a newbie trying to use this good example to plot 3D scatter points.
However, I find that I cannot use the ShRdr.Point() to display anthing after drawing the axis lines
while using Shrdr.Circle2() can draw the circle.

B4X:
ShRdr.Begin(ShRdr.SHAPETYPE_Line)
   
        'Draws the 3 axis
        ShRdr.Color = Color1.WHITE
        ShRdr.Line2(0, 0, 0, 1, 0, 0)
        ShRdr.Line2(0, 0, 0, 0, 1, 0)
        ShRdr.Line2(0, 0, 0, 0, 0, 1)
    ShRdr.End
    'ShRdr.Begin(ShRdr.SHAPETYPE_Filled)
    ShRdr.Begin(ShRdr.SHAPETYPE_Point)
    ShRdr.Color = Color1.RED
    'ShRdr.Circle2(0,0,0.2,16)
    ShRdr.Point(0.5, 0.5, 0.5)
    ShRdr.End

Is it because I miss some other step/s before I can call the ShRdr.Point() please?!

Thanks & Best Regards,
Robert
 

Informatix

Expert
Licensed User
Longtime User
I just tried your code and I saw nothing wrong with the Point function. There's a red point displayed at the right place. Note that a point is very small so it may be hard to notice on your device. Change the color to white or yellow to make it more obvious.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…