line with a texture

Problems with Canvas, OpenGL, etc...

line with a texture

Postby GerdGerdGerd » Wed Sep 28, 2011 6:33 pm

Hello together,

how can i draw multiple lines and bind a texture of this. with canvas#drawLine i only can change the color of the line. or is there an alternative to draw an drawable from start position x, y to a end position x, y like a line?

it should looks like a rope, like these:
Image

or have someone an idea, how i can draw a rope?

Greetz
GerdGerdGerd
Junior Developer
Junior Developer
 
Posts: 19
Joined: Sun Jun 05, 2011 6:14 pm

Top

Re: line with a texture

Postby jonbonazza » Thu Sep 29, 2011 12:21 am

Since, in OpenGL, lines are not textureable, you would need to create your own API that creates a line using triangle strips, and then textures them.
jonbonazza
Master Developer
Master Developer
 
Posts: 665
Joined: Thu Jul 15, 2010 2:58 pm
Location: WV USA

Re: line with a texture

Postby Avena » Thu Sep 29, 2011 1:06 pm

Well...

Nice.. This line is texture able...

I agreed with jonbonazza ,

He have provided a good way to edit the textures..
Avena
Freshman
Freshman
 
Posts: 2
Joined: Thu Sep 29, 2011 1:01 pm

Re: line with a texture

Postby GerdGerdGerd » Thu Sep 29, 2011 9:15 pm

well, maybe line is the wrong word ... i want to draw an rope :) . so you mean i should draw rectangles with an repeatable texture? or do you have another idea?

its quite clearly, that i cant draw a texture to an single line :)
GerdGerdGerd
Junior Developer
Junior Developer
 
Posts: 19
Joined: Sun Jun 05, 2011 6:14 pm

Re: line with a texture

Postby jonbonazza » Thu Sep 29, 2011 10:26 pm

Well, in OpenGL, you can only draw primitives. A rectangle is not a primitive; it is 2 triangles. What you want to do is draw a series of vertices as triangle strips, which would ultimately create a rectangular line, then map the texture to the line.
jonbonazza
Master Developer
Master Developer
 
Posts: 665
Joined: Thu Jul 15, 2010 2:58 pm
Location: WV USA

Re: line with a texture

Postby millerni456 » Thu Oct 13, 2011 3:28 am

Since a rope is somewhat cylindrical you can do this...

Use GL_TRIANGLE_STRIP to create a cylinder sides. Texture accordingly for your rope.
Then you can use GL_TRIANGLE FAN for the endpoints of the rope.

If you make enough cylinders (segments) you can have the rope animate.
millerni456
Junior Developer
Junior Developer
 
Posts: 12
Joined: Wed Oct 05, 2011 12:39 am

Top

Re: line with a texture

Postby jonbonazza » Thu Oct 13, 2011 4:31 pm

Is this to be 2d or 3d?
jonbonazza
Master Developer
Master Developer
 
Posts: 665
Joined: Thu Jul 15, 2010 2:58 pm
Location: WV USA

Re: line with a texture

Postby roopa » Tue Oct 18, 2011 12:42 pm

I'm currently trying to draw simple meshes using different textures (using C# and OpenTK). I read a lot about TextureUnit and bindings, and that's my current implementation (not working as expected) :
roopa
Developer
Developer
 
Posts: 27
Joined: Wed Sep 14, 2011 6:46 am

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: Google Feedfetcher and 1 guest