<p>It's generally referred to as a "state machine". It has, as you noticed, a bunch of switches and parameters. All of them are globally accessible to any code that has access to the current context. Your program sets them and then issues draw calls. Anything you don't change, will remain in that state until you do change it. </p>

<p>It is also a <a href="https://en.wikipedia.org/wiki/Hardware_abstraction" rel="noreferrer">Hardware Abstraction</a>. The same OpenGL routines should have roughly the same effect regardless of the hardware it's running on. If you upload 3 vertices for a triangle and then draw them, that should produce similar results on an ATI, Nvidia, or Intel GPU, for example. You don't need machine-specific instructions for each one.</p>

CC BY-SA 4.0
2018-07-26T15:59:36.137Z
2018-07-26T15:59:36.137Z
user1118321
<p>The proper term for this style is called "imperative programming." You would be correct in thinking that it is similar to C because C is classified as an imperative programming language.</p>

<p>For more about the paradigm, you can read about it here: <a href="https://en.wikipedia.org/wiki/Imperative_programming" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Imperative_programming</a></p>

CC BY-SA 4.0
2018-07-27T02:35:31.770Z
By definition, every API in C and C++ is Imperative, since those languages are Imperative. Even OOP is merely a subset of Imperative programming.
Nicol Bolas
CC BY-SA 4.0
2018-07-26T23:14:39.343Z
2018-07-26T23:14:39.343Z
Nate
<p>OpenGL is not object-oriented, but more like "switches you turn on"?</p>

<p>Like</p>

<pre><code>glEnable(...);
list_id = glGenLists(1);
glNewList(list_id, GL_COMPILE);
glBegin(GL_TRIANGLES);
...
</code></pre>

<p>It seems like one's turning on switches on some machine which is contained somewhere, but it isn't seen as an object in object-oriented sense?</p>

<p>Is there a name for this kind of programming or library paradigm?</p>

<p>I'm using it from C++, but perhaps the way it's used is "C-style"?</p>

CC BY-SA 4.0
2018-07-26T17:04:34.217Z
The code you're quoting there is really old OpenGL! If you're new to the API and just learning, do yourself a favor and learn modern-style OpenGL (at least version 3.3, core profile). The only time you should need to use display lists or glBegin is if you're maintaining or modding apps from 10+ years ago.
russ
<opengl>
What is OpenGL's paradigm?
mavavilj
# What is OpenGL's paradigm?

(Asked by: username_0 on 2018-07-26)

OpenGL is not object-oriented, but more like "switches you turn on"?

Like

```
glEnable(...);
list_id = glGenLists(1);
glNewList(list_id, GL_COMPILE);
glBegin(GL_TRIANGLES);
...

```

It seems like one's turning on switches on some machine which is contained somewhere, but it isn't seen as an object in object-oriented sense?

Is there a name for this kind of programming or library paradigm?

I'm using it from C++, but perhaps the way it's used is "C-style"?

**Tags:** opengl

> **Comments:**
> **username_1**: The code you're quoting there is really old OpenGL! If you're new to the API and just learning, do yourself a favor and learn modern-style OpenGL (at least version 3.3, core profile). The only time you should need to use display lists or glBegin is if you're maintaining or modding apps from 10+ years ago.  

---

## 2 answers

### Answer by username_2 on 2018-07-26. Score: 5

It's generally referred to as a "state machine". It has, as you noticed, a bunch of switches and parameters. All of them are globally accessible to any code that has access to the current context. Your program sets them and then issues draw calls. Anything you don't change, will remain in that state until you do change it.

It is also a [Hardware Abstraction](https://en.wikipedia.org/wiki/Hardware_abstraction). The same OpenGL routines should have roughly the same effect regardless of the hardware it's running on. If you upload 3 vertices for a triangle and then draw them, that should produce similar results on an ATI, Nvidia, or Intel GPU, for example. You don't need machine-specific instructions for each one.


---

### Answer by username_3 on 2018-07-26. Score: 0

The proper term for this style is called "imperative programming." You would be correct in thinking that it is similar to C because C is classified as an imperative programming language.

For more about the paradigm, you can read about it here: <https://en.wikipedia.org/wiki/Imperative_programming>

> **Comments:**
> **username_4**: By definition, every API in C and C++ is Imperative, since those languages are Imperative. Even OOP is merely a subset of Imperative programming.  

---

