OpenGL 4.6

Function reference

Every function used in the lessons, explained one by one: what it does, what each parameter means, which values it accepts, common mistakes and a short example.

Available in

Hide functions newer than the OpenGL version you target. macOS stops at 4.1.

Function families

Context & state

Buffers

Vertex arrays

Shaders & programs

Uniforms

Drawing

Textures

Depth, blending & culling

glDepthFunc1.0Chooses the comparison that decides whether a fragment passes the depth test.glDepthMask1.0Turns writing to the depth buffer on or off (testing still happens).glBlendFunc1.0Sets how a new fragment's color is mixed with the color already in the framebuffer.glCullFace1.0Chooses which faces are discarded when face culling is enabled.glFrontFace1.0Defines which vertex order (winding) counts as a front-facing triangle.glPolygonMode1.0Draws polygons filled, as wireframe lines, or as points.glPolygonOffset1.1Pushes polygon depth values slightly, to avoid z-fighting and shadow acne.glBlendFuncSeparate1.4glBlendFunc with one pair of factors for the colour channels and another for alpha.glBlendEquation1.4Chooses how the two blended terms are combined: added (default), subtracted, or the minimum or maximum.glBlendFunci4.0glBlendFunc for one colour attachment only, when a shader writes to several at once.glColorMask1.0Turns writing to each colour channel on or off; all GL_FALSE draws depth and stencil only.glDepthRange1.0Maps the depth after projection (−1 to 1) to the values stored in the depth buffer (0 to 1 by default).glClearDepth1.0Sets the value glClear writes into the depth buffer (1.0, the far plane, by default).glPointSize1.0Sets the diameter in pixels of points drawn with GL_POINTS (when the shader does not set it).glLineWidth1.0Sets the width in pixels of lines; in the core profile only 1.0 is guaranteed to work.glMinSampleShading4.0Under MSAA, makes the fragment shader run for a share of the samples (1.0 = every sample), smoothing aliasing inside triangles too.

Stencil

Framebuffers

glGenFramebuffers3.0Reserves names for new framebuffer objects (off-screen render targets).glBindFramebuffer3.0Selects the framebuffer that draw calls render into (and/or read from).glFramebufferTexture2D3.0Attaches a 2D texture to the bound framebuffer so rendering writes into it.glCheckFramebufferStatus3.0Checks that the bound framebuffer is complete (usable for rendering).glGenRenderbuffers3.0Reserves names for renderbuffers — render-only images you never sample.glBindRenderbuffer3.0Binds a renderbuffer so glRenderbufferStorage can allocate it.glRenderbufferStorage3.0Allocates the memory of the bound renderbuffer.glFramebufferRenderbuffer3.0Attaches a renderbuffer to the bound framebuffer.glDrawBuffer1.0Chooses which color buffer of the bound framebuffer receives color output.glReadBuffer1.0Chooses which color buffer is the source for read operations.glDrawBuffers2.0Connects the fragment shader's outputs to colour attachments of the bound framebuffer (multiple render targets).glFramebufferTexture3.2Attaches a whole texture to a framebuffer; a cubemap or array texture is attached with all its layers.glFramebufferTextureLayer3.0Attaches one single layer of an array (or 3D) texture to a framebuffer.glRenderbufferStorageMultisample3.0Allocates a renderbuffer with several samples per pixel, for MSAA in your own framebuffer.glBlitFramebuffer3.0Copies a rectangle of pixels from the read framebuffer to the draw framebuffer, scaling and resolving MSAA on the way.glReadPixels1.0Copies pixels from the read framebuffer back to the CPU (or into a pixel buffer object).

Direct State Access

glCreateBuffers4.5Creates buffer objects that exist immediately — no bind needed.glNamedBufferData4.5glBufferData without binding: (re)allocates a buffer's storage by ID.glNamedBufferStorage4.5Allocates IMMUTABLE storage for a buffer — fixed size, explicit usage flags.glNamedBufferSubData4.5glBufferSubData without binding: overwrites part of a buffer by ID.glCreateVertexArrays4.5Creates VAOs that can be configured without binding them.glVertexArrayVertexBuffer4.5Plugs a vertex buffer into a numbered binding slot of a VAO.glVertexArrayAttribFormat4.5Describes the format of one attribute inside a vertex — without saying which buffer.glVertexArrayAttribBinding4.5Says which buffer binding slot an attribute reads from.glEnableVertexArrayAttrib4.5Enables an attribute of a specific VAO, without binding it.glCreateTextures4.5Creates textures of a given type immediately — no bind needed.glTextureStorage2D4.5Allocates immutable storage for a texture by ID (DSA glTexStorage2D).glTextureSubImage2D4.5Uploads pixels into a region of an existing texture by ID.glVertexArrayElementBuffer4.5Gives a VAO its index buffer (EBO), the one glDrawElements reads.glVertexArrayBindingDivisor4.5Makes a vertex buffer binding advance once per instance instead of once per vertex (instancing).glMapNamedBufferRange4.5Gives the CPU a pointer into part of a buffer's memory, by ID.glUnmapNamedBuffer4.5Ends a mapping made with glMapNamedBufferRange, so the GPU can use the buffer again.glCopyNamedBufferSubData4.5Copies bytes from one buffer to another on the GPU, by ID, without passing through the CPU.glTextureParameteri4.5Sets one integer setting of a texture (filtering, wrapping…) by its ID.glTextureParameterf4.5Sets one floating-point setting of a texture, such as anisotropic filtering or LOD bias.glTextureParameteriv4.5Sets a texture setting that takes several integers at once, such as the channel swizzle.glBindTextureUnit4.5Puts a texture on texture unit number unit, in one call (no glActiveTexture).glGenerateTextureMipmap4.5Builds every smaller mip level of a texture from its level 0, by ID.glCompressedTextureSubImage2D4.5Uploads already-compressed blocks (BC7, BC1, ASTC…) into one mip level of a texture.glCreateFramebuffers4.5Creates framebuffer objects that exist immediately, ready for glNamedFramebuffer* calls.glCreateRenderbuffers4.5Creates renderbuffer objects (images you render into but never sample) without binding.glNamedRenderbufferStorage4.5Allocates a renderbuffer's image: its format and size.glNamedFramebufferTexture4.5Attaches a texture to a framebuffer, so drawing into the framebuffer writes into the texture.glNamedFramebufferRenderbuffer4.5Attaches a renderbuffer to a framebuffer, usually as its depth-stencil buffer.glNamedFramebufferDrawBuffers4.5Lists which colour attachments the fragment shader's outputs go to (multiple render targets).glCheckNamedFramebufferStatus4.5Tells whether a framebuffer is complete (ready to draw into) and, if not, why.glClearNamedFramebufferfv4.5Clears one attachment of a framebuffer to a value of your choice, without glClearColor.glClearNamedFramebufferuiv4.5Clears an unsigned-integer colour attachment (an object-ID buffer, for example) to an integer value.

Compute

Sync & queries

Debugging

Legacy (immediate mode)