<p>If multi-texturing is supported, texture coordinate generation will affect the active texture unit (quote from the documentation, emphasis is mine):</p>

<blockquote>
  <p>When the ARB_multitexture extension is supported, <a href="https://www.opengl.org/sdk/docs/man2/xhtml/glTexGen.xml" rel="nofollow">glTexGen</a> sets the texture generation parameters <strong>for the currently active texture unit, selected with glActiveTexture</strong>.</p>
</blockquote>

<p>So you simply need to make sure texture coordinates generation is disabled for the color texture, but enabled for the shadow texture. As you guessed, this is done with <a href="https://www.opengl.org/sdk/docs/man2/xhtml/glActiveTexture.xml" rel="nofollow"><code>glActiveTexture()</code></a>, by writing for example:</p>

<pre><code>glActiveTexture(GL_TEXTURE0); // Assuming the color texture to be #0
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_GEN_R);
glDisable(GL_TEXTURE_GEN_Q);

glActiveTexture(GL_TEXTURE1); // Assuming the shadow texture to be #1
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_S, GL_EYE_PLANE, textureMatrix.GetRow(0));
glEnable(GL_TEXTURE_GEN_S);
// [...]
</code></pre>

<hr>

<p>This being said, you're adding to yourself a lot of trouble by sticking with fixed pipeline instead of using GLSL.</p>

CC BY-SA 3.0
2016-04-08T12:52:30.253Z
2016-04-08T12:52:30.253Z
Julien Guertault
<p>So, recently I followed this <a href="http://www.paulsprojects.net/tutorials/smt/smt.html" rel="nofollow">tutorial</a> about shadow mapping, but in the tutorial it doesn't texture the object.. When I try to add a texture, it's distorted by the <code>TexGen</code>. Also I've tried to use <code>glActiveTexture()</code> with no success(dunno exactly how <code>glActiveTexture()</code> work).</p>

<p>So can anyone help me by adding textures into above code base? From there, I can learn how to use <code>glActiveTexture()</code> and overcome that <code>TexGen</code> issue.</p>

<p>Thanks in advance.. To note, I'm not using GLSL.</p>

<opengl><texture><shadow-mapping>
How can I use multiple texturing with shadow mapping?
Bla...
# How can I use multiple texturing with shadow mapping?

(Asked by: username_0 on 2016-02-23)

So, recently I followed this [tutorial](http://www.paulsprojects.net/tutorials/smt/smt.html) about shadow mapping, but in the tutorial it doesn't texture the object.. When I try to add a texture, it's distorted by the `TexGen`. Also I've tried to use `glActiveTexture()` with no success(dunno exactly how `glActiveTexture()` work).

So can anyone help me by adding textures into above code base? From there, I can learn how to use `glActiveTexture()` and overcome that `TexGen` issue.

Thanks in advance.. To note, I'm not using GLSL.

**Tags:** opengl, texture, shadow-mapping


---

## 1 answers

### Answer by username_1 on 2016-04-08. Score: 0 | Accepted answer

If multi-texturing is supported, texture coordinate generation will affect the active texture unit (quote from the documentation, emphasis is mine):

> When the ARB\_multitexture extension is supported, [glTexGen](https://www.opengl.org/sdk/docs/man2/xhtml/glTexGen.xml) sets the texture generation parameters **for the currently active texture unit, selected with glActiveTexture**.

So you simply need to make sure texture coordinates generation is disabled for the color texture, but enabled for the shadow texture. As you guessed, this is done with [`glActiveTexture()`](https://www.opengl.org/sdk/docs/man2/xhtml/glActiveTexture.xml), by writing for example:

```
glActiveTexture(GL_TEXTURE0); // Assuming the color texture to be #0
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_GEN_R);
glDisable(GL_TEXTURE_GEN_Q);

glActiveTexture(GL_TEXTURE1); // Assuming the shadow texture to be #1
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_S, GL_EYE_PLANE, textureMatrix.GetRow(0));
glEnable(GL_TEXTURE_GEN_S);
// [...]

```

---

This being said, you're adding to yourself a lot of trouble by sticking with fixed pipeline instead of using GLSL.


---

