PandaConda
PandaConda

Reputation: 3506

Why would you set a shader program inside a game loop?

I'm going through an OpenGL tutorial and in the code examples the functions glGetUniformLocation and glUseProgram are called unconditionally inside of the main game loop.

It seems like it would be a waste to do this once a frame, and the program still behaves correctly after moving this logic to before the start of the game loop. Are there any reasons for keeping this logic inside the game loop?

Upvotes: 1

Views: 126

Answers (1)

Joonazan
Joonazan

Reputation: 1416

GetUniformLocation needs only be called when the shader is initialized. glUseProgram might be useful if you later store which program is used in some variable.

Upvotes: 1

Related Questions