<p>These aren't macros pointing to memory addresses. They're just integer preprocessor constants. Back in the days when OpenGL originated, using preprocessor constants for your numeric constants was common practice in C.</p>

<p>Nowadays it's considered better practice to define new types (single-element structs) for your constants, but it's too late to change OpenGL.</p>

CC BY-SA 3.0
2016-12-13T18:06:19.237Z
Thank you! So these C constants are just being replaced by those integer values that to me looked like memory adresses which is wrong, but what are those integers actually representing?
mbl
CC BY-SA 3.0
2016-12-13T18:14:11.060Z
@mbl They don't represent anything, they're just arbitrarily assigned values, defined in the OpenGL spec so that applications and GL drivers can communicate with each other.
Nathan Reed
CC BY-SA 3.0
2016-12-13T18:15:30.123Z
@Dan, btw, what do you mean about "single-element structs"? Nowadays I would expect to use enums in C/C++ for this.
Nathan Reed
CC BY-SA 3.0
2016-12-13T18:47:59.790Z
@NathanReed Enums are fine in C++ but in C they're implicitly convertible from integers and other enums, so they only provide the names for constants, not the type-safety. Nowadays I guess you can rely on compilers to warn you at appropriate times, even in C.
Dan Hulme
CC BY-SA 3.0
2016-12-14T21:16:31.887Z
@DanHulme: C is not a type-safe language, so that's to be expected.
Nicol Bolas
CC BY-SA 3.0
2016-12-13T08:28:47.280Z
2016-12-13T08:28:47.280Z
Dan Hulme
<p>I would just like to know why are there so many things defined as macros that point to memory addresses in OpenGL? </p>

<p>I see them all over the place. For example when I go to choose parameters for a function such as glDrawArrays(), I have to choose a mode like GL_TRIANGLES as the first parameter which is a macro like all the others. </p>

<opengl>
Why is there so many macros in OpenGL?
mbl
# Why is there so many macros in OpenGL?

(Asked by: username_0 on 2016-12-13)

I would just like to know why are there so many things defined as macros that point to memory addresses in OpenGL?

I see them all over the place. For example when I go to choose parameters for a function such as glDrawArrays(), I have to choose a mode like GL\_TRIANGLES as the first parameter which is a macro like all the others.

**Tags:** opengl


---

## 1 answers

### Answer by username_1 on 2016-12-13. Score: 9 | Accepted answer

These aren't macros pointing to memory addresses. They're just integer preprocessor constants. Back in the days when OpenGL originated, using preprocessor constants for your numeric constants was common practice in C.

Nowadays it's considered better practice to define new types (single-element structs) for your constants, but it's too late to change OpenGL.

> **Comments:**
> **username_0**: Thank you! So these C constants are just being replaced by those integer values that to me looked like memory adresses which is wrong, but what are those integers actually representing?  
> **username_2**: @username_0 They don't represent anything, they're just arbitrarily assigned values, defined in the OpenGL spec so that applications and GL drivers can communicate with each other.  
> **username_2**: @Dan, btw, what do you mean about "single-element structs"? Nowadays I would expect to use enums in C/C++ for this.  
> **username_1**: @username_2 Enums are fine in C++ but in C they're implicitly convertible from integers and other enums, so they only provide the names for constants, not the type-safety. Nowadays I guess you can rely on compilers to warn you at appropriate times, even in C.  
> **username_3**: @username_1: C is not a type-safe language, so that's to be expected.  

---

