Texture mask, manipulate pixels, etc.

Anything libgdx related goes here!

Texture mask, manipulate pixels, etc.

Postby Kerai » Sat Dec 17, 2011 7:35 am

Hi there...

I've done something with android API, but it was a little too slow for my needs...
and I want to make it with opengl/libgdx. Yet I don't know how...
I'll show you some video of how it works (done in android api)
http://www.youtube.com/watch?v=v_USzCNkBI4

See... the terrain is just a bitmap (an alpha bitmask, and a terrain bitmap), I modify it (draw on it) to make tunnels. Ant reads pixels from it to know if it hits the ground. that bitmap is huge.

I don't know how to achieve similiar effect with opengl/libgdx on textures instead of bitmaps. I hope someone can point me in right direction...
Maybe whole idea is wrong and I should make it some other way.
Kerai
 
Posts: 63
Joined: Thu Dec 08, 2011 12:51 pm

Re: Texture mask, manipulate pixels, etc.

Postby pitbuller » Sat Dec 17, 2011 8:58 am

http://www.youtube.com/watch?v=PUK-s4kW1ug

I think Arielsan can help you with this.

Trick is use many smaller pixmaps and create textures from those only if something is modified on that region.
pitbuller
 
Posts: 134
Joined: Mon Jul 25, 2011 9:07 am

Re: Texture mask, manipulate pixels, etc.

Postby Kerai » Sat Dec 17, 2011 8:07 pm

And if I modify something on the edge of one pixmap, then I have to modify two pixmaps, and upload two...
and if it happens on the corner, I'll have to modify and upload 4, yup?
Kerai
 
Posts: 63
Joined: Thu Dec 08, 2011 12:51 pm

Re: Texture mask, manipulate pixels, etc.

Postby Kerai » Sun Dec 18, 2011 6:27 am

From what I know, Android doesn't have dedicated VRAM, so it uses applications RAM to store textures, buffers, etc... Therefore Bitmap is a bitmap and texture at once - as memory occupied by Bitmap i used both by cpu and gpu.
This means that Pixmap on Android doesn't need to be uploaded, it can be drawn as it is, the gpu just needs to know where it is and in what format...

Am I right?
Kerai
 
Posts: 63
Joined: Thu Dec 08, 2011 12:51 pm

Re: Texture mask, manipulate pixels, etc.

Postby NateS » Sun Dec 18, 2011 4:23 pm

AFAIK, while the GPU and CPU my share the same RAM, the GPU owns the memory and you do indeed need to upload textures from RAM to video memory.
NateS
 
Posts: 1980
Joined: Fri Nov 12, 2010 11:08 am

Re: Texture mask, manipulate pixels, etc.

Postby chessmani » Mon Dec 19, 2011 12:01 am

I think you can use a texture as a mask (check this) and modify it with glTexSubImage2D so that you're only transfering the modified parts. If your mask is a Pixmap, then the Texture class has a convenient draw (Pixmap pixmap, int x, int y) already.
chessmani
 
Posts: 5
Joined: Thu Dec 15, 2011 12:16 am


Return to Libgdx

Who is online

Users browsing this forum: No registered users and 1 guest

cron