View Full Version : Filling a polygon with a repeating texture

01-11-2011, 05: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!

01-11-2011, 06: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

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

01-11-2011, 06:53 AM

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.

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