Piotr Chojnacki
Piotr Chojnacki

Reputation: 6857

When it is good to compile shaders?

I'm trying to move into the 'modern' OpenGL. I think I understand so far the concept of shaders and I know how to compile them, but I'm not sure about when it is good to do it.

Is it ok to have a function that would compile all shaders at the application start up, store them in some kind of manager, which would serve currently needed shader?

Or maybe should I just compile them when they are needed and the next time they're needed just use the one I've already created?

And I assume that creating a shader program every frame is not a good idea.

I'd appreciate any hints about it how to organise it in a good way.

Upvotes: 4

Views: 242

Answers (1)

datenwolf
datenwolf

Reputation: 162164

Is it ok to have a function that would compile all shaders at the application start up, store them in some kind of manager, which would serve currently needed shader?

Yes. This is one of those one-time initialization things that could be regarded as OpenGL "initialization".

Upvotes: 2

Related Questions