View Full Version : Using a texture over multiple places

07-23-2013, 03:05 AM
I want to be able to project a (consistent) texture over multiple faces. At the moment, if I bind a texture and draw multiple faces, each face will own its own texture. This works fine for low poly simple maps, but imagine if I have, say, a pillar. Obviously a pillar has many, many faces.

If anyone could provide a tutorial, or some information on the topic, I would be greatly appreciative.


07-23-2013, 05:11 AM
Not sure if I understand you right but this sounds like you need to specify the right texture-coordinates for each vertex you render. The texture-coordinate indicates where on the texture the renderer should be when the vertex is drawn. So
glTexCoords2f(0,0); glVertex(...)
glTexCoords2f(0.5, 0); glVertex(...)
will draw a line that gets textured with the left half of the lowest pixel-line of the texture - roughly spoken.
If you have for example 4 quads in line where the texture should be spanned over you will have to map the 5 different x-coordinates of the vertices used to draw them to 5 x-texture-coordinates.

P0----P1----P2----P3----P4----P5 Point
0.0---0.2---0.4---0.6---0.8---1.0 TexCoord

07-23-2013, 05:58 PM
OH, so if I work out how many faces there are using the same texture, I can stretch it across something like this:

F1 F2 F3
v1 v2 v1 v2
| | | |
0.0 0.3 0.6 0.9

Something like that?

07-23-2013, 08:22 PM
The v's are confusing as v1=v1 and v2=v2. But your above sentence is correct.

| | |
| | |
| | |

will Stretch the texture across the two quads, where the numbers denote the texture-coords and the places where the numbers are (and the lines intersect) denote the different Vertices.
The 0.5,X.0 texcoord tells GL that it should have reached in the x-middle of the texture at that vertex as a texture is always of the width and height of 1 (logically).
The middle-point on the line between the Vertices with the tex-coords (0.5,0.0) and (0.5,1.0) will be in the middle of the texture as ((0.5,0.0)+(0.5,1.0))/2 = (0.5, 0.5).