PDA

View Full Version : Filling a polygon with a repeating texture



transparent
01-11-2011, 06:59 AM
Hi guys,

I'm playing with openGL for the first time on the Android platform.

I'm wanting to draw a polygon filled with a repeating texture. (It will represent 2d landscape i.e. http://www.blogcdn.com/www.joystiq.com/media/2009/08/gentlemenplatformer580.jpg)

The reason I'm using a polygon is I'm using the same shape to create a box2d physics object...

So my question is, how do I fill a polygon with a repeating texture?

Also can anybody recommend a good book on openGL?

Many thanks!

aqnuep
01-11-2011, 07:27 AM
In order to have a repeating texture over an arbitrary surface you need only two things:

- set texture wrap mode to GL_REPEAT
- set texture coordinates appropriately (so use values outside the [0,1] interval) or alternatively use the texture matrix (or equivalent shader) to scale the texture coordinates

transparent
01-11-2011, 07:35 AM
Can you recommend any articles/books which would help me understand what you just said!! Cheers :)

Groovounet
01-11-2011, 07:53 AM
http://www.opengles-book.com

I'm not sure what it really worth, I don't have it, I sound quite a beginner book, but the OpenGL samples are available for the Android platform which could be great for you.

ugluk
01-11-2011, 09:07 AM
library.nu, register, then search a little for OpenGL.