<p>The uniform locations are set when the program is linked and are tied to the program.</p>

<p>This means that when you create a new program then the uniform locations can change. </p>

CC BY-SA 3.0
2015-10-02T08:53:07.807Z
2015-10-02T08:53:07.807Z
ratchet freak
<p>I have a shader which has several uniform variables:</p>

<pre><code>uniform vec4 a;
uniform vec4 b;
uniform vec4 c;
</code></pre>

<p>I'm getting these handles using <code>glGetUniformLocation()</code> and storing them in the array. The game was suspended, then resumed and <a href="http://developer.android.com/reference/android/opengl/GLSurfaceView.Renderer.html" rel="noreferrer">onSurfaceCreated()</a> has been called. The question is: whether these handles will be valid or I need to re-get them using <code>glGetUniformLocation()</code> once again?</p>

CC BY-SA 3.0
2015-10-02T08:36:21.993Z
Related: [Do I need to rebind uniforms or attributes when changing shader programs?](http://computergraphics.stackexchange.com/q/305/127)
Nero
<opengl><shader><android>
Can the uniform id be changed from run to run on the same machine?
Netherwire
# Can the uniform id be changed from run to run on the same machine?

(Asked by: username_0 on 2015-10-02)

I have a shader which has several uniform variables:

```
uniform vec4 a;
uniform vec4 b;
uniform vec4 c;

```

I'm getting these handles using `glGetUniformLocation()` and storing them in the array. The game was suspended, then resumed and [onSurfaceCreated()](http://developer.android.com/reference/android/opengl/GLSurfaceView.Renderer.html) has been called. The question is: whether these handles will be valid or I need to re-get them using `glGetUniformLocation()` once again?

**Tags:** opengl, shader, android

> **Comments:**
> **username_1**: Related: [Do I need to rebind uniforms or attributes when changing shader programs?](http://computergraphics.stackexchange.com/q/305/127)  

---

## 1 answers

### Answer by username_2 on 2015-10-02. Score: 6 | Accepted answer

The uniform locations are set when the program is linked and are tied to the program.

This means that when you create a new program then the uniform locations can change.


---

