0

I've read some articles describing what the OpenGL state machine is, but my question is, why is it called a state machine? In my understanding, a state machine features:

  1. State transition: given a source state and input, it transitions to a target state.
  2. Output: a transition (or state if it's a Moore machine) yields an output.

But none of these characteristics does an OpenGL "state machine" really possesses. For 1, although the state transitioning exists, but it's completely free to jump from any state to any other state, giving any input (GL call) - there's no rule for it which makes the transitioning meaningless. For 2, it doesn't generate outputs like text or pixel right from the state machine itself.

In that sense, wouldn't it be better called "state set"?

Dietrich Epp
  • 205,541
  • 37
  • 345
  • 415
Connor Li
  • 9
  • 3
  • Thanks @DietrichEpp, that in part clears my confusions, but I'd like to get more detailed answers specific to my points above. – Connor Li Mar 08 '23 at 04:12
  • To be honest, I was writing out an answer, but I think that the answer linked is more than satisfactory and it covers everything that I was going to write. It is simply not true that state machines must produce output. State machines which produce output are called “transducers”. – Dietrich Epp Mar 08 '23 at 04:22
  • 1
    I think the key part of the answer is that “OpenGL is a state machine” is not some useful formal property of OpenGL. It’s too vague for that. It’s just a reminder to keep track of OpenGL’s state—OpenGL has a ton of state, and it’s easy to accidentally put OpenGL in the wrong state, or make mistakes when you’re trying to reason about what state it’s in. You could model certain parts of OpenGL as a finite state machine but that formalism is probably not very useful. – Dietrich Epp Mar 08 '23 at 04:32

0 Answers0