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
glUniform*Set a uniform of the program in use; the end of the name says how many values and of what type.glProgramUniform*The glUniform family with the program as first argument: no glUseProgram needed (GL 4.1).glGen*Reserve names (GLuint numbers) for new objects; the object itself appears at the first bind.glCreate*Create objects that exist immediately, ready for DSA calls; shaders and programs are created this way too.glDelete*Free objects and their GPU memory; 0 and unknown names are ignored.glBind*Make an object the current one for a target or slot, so the following calls act on it or draws use it.glGet*Read state, limits or results back from OpenGL; the suffix says the type of what comes back.glGetQueryObject*Read a query's availability or result; pick the suffix by the size of the result.glTexSubImage*Overwrite part of an existing texture; the number is the texture's dimensions, Texture instead of Tex means DSA.
Context & state
glViewport1.0Sets which rectangle of the window the rendered image is mapped to.glClearColor1.0Chooses the color glClear will fill the color buffer with.glClear1.0Resets the chosen buffers of the current framebuffer (color, depth, stencil).glEnable1.0Switches on a fixed-function feature such as depth testing, blending or face culling.glDisable1.0Switches off a feature previously turned on with glEnable.glGetString1.0Returns text describing the driver: version, GPU name, vendor, GLSL version.glGetIntegerv1.0Reads an integer piece of state or a hardware limit.glGetError1.0Returns (and clears) the oldest error flag recorded by previous calls.
Buffers
glGenBuffers1.5Reserves names (IDs) for new buffer objects.glBindBuffer1.5Makes a buffer the current one for a given target, so later buffer calls act on it.glBufferData1.5Allocates GPU memory for the bound buffer and optionally copies data into it.glBufferSubData1.5Overwrites part of an already allocated buffer.glMapBuffer1.5Returns a CPU pointer through which you can read or write a whole buffer.glMapBufferRange3.0Maps part of a buffer, with flags that say exactly what may happen to its old contents.glUnmapBuffer1.5Ends a mapping and gives the buffer back to OpenGL.glCopyBufferSubData3.1Copies bytes from one buffer to another on the GPU.glGetBufferSubData1.5Copies bytes from a GPU buffer back into CPU memory.glDeleteBuffers1.5Destroys buffer objects and frees their GPU memory.glBindBufferBase3.0Connects a whole buffer to a numbered binding point that shaders read from.glBindBufferRange3.0Connects only a slice of a buffer to a numbered binding point.glBufferStorage4.4Allocates immutable storage for the bound buffer: fixed size, with flags that say exactly how the CPU will use it.glFlushMappedBufferRange3.0Tells OpenGL which bytes of a mapped buffer you wrote, when the mapping is not coherent.
Vertex arrays
glGenVertexArrays3.0Reserves names (IDs) for new vertex array objects (VAOs).glBindVertexArray3.0Makes a VAO current: it records vertex setup calls and is used by draw calls.glDeleteVertexArrays3.0Destroys VAOs. The buffers they reference are NOT deleted.glVertexAttribPointer2.0Describes how one vertex attribute is laid out inside the currently bound GL_ARRAY_BUFFER.glEnableVertexAttribArray2.0Turns on reading a vertex attribute from its buffer.glVertexAttribDivisor3.3Makes an attribute advance per instance instead of per vertex (for instancing).glVertexAttribIPointer3.0glVertexAttribPointer for integer attributes: the values reach the shader as ints, not converted to float.glBindVertexBuffer4.3Puts a buffer on a binding point of the bound VAO; the attribute formats are described separately.
Shaders & programs
glGetAttribLocation2.0Asks a linked program which location the linker gave a vertex input; -1 if it does not exist.glCreateShader2.0Creates an empty shader object of a given stage.glShaderSource2.0Gives a shader object its GLSL source code.glCompileShader2.0Compiles the GLSL source stored in a shader object.glGetShaderiv2.0Queries a property of a shader — mainly whether it compiled.glGetShaderInfoLog2.0Reads the compiler's error and warning messages for a shader.glDeleteShader2.0Deletes a shader object (once linked, the program no longer needs it).glCreateProgram2.0Creates an empty program object, which will link shaders into one pipeline.glAttachShader2.0Adds a compiled shader to a program before linking.glLinkProgram2.0Links the attached shaders into an executable program.glGetProgramiv2.0Queries a property of a program — mainly whether it linked.glGetProgramInfoLog2.0Reads the linker's error and warning messages for a program.glUseProgram2.0Selects the shader program used by the next draw calls.glDeleteProgram2.0Deletes a program object.
Uniforms
glGetUniformLocation2.0Looks up the location (slot number) of a uniform variable by its GLSL name.glUniform1i2.0Sets an int, bool or sampler uniform — e.g. tells a sampler which texture unit to read.glUniform1f2.0Sets a float uniform.glUniform3fv2.0Sets a vec3 uniform (or an array of them) from a pointer.glUniform4f2.0Sets a vec4 uniform from four separate floats.glUniformMatrix3fv2.0Sets a mat3 uniform — most often the normal matrix.glUniformMatrix4fv2.0Sets a mat4 uniform — how model, view and projection matrices reach the shader.glGetUniformBlockIndex3.1Finds the index of a named uniform block inside a program.glUniformBlockBinding3.1Connects a uniform block of a program to a numbered binding point.glUniform2f2.0Sets a vec2 uniform of the program in use from two floats, such as the screen resolution.glProgramUniform1f4.1Sets a float uniform of any program, without making it the program in use.
Drawing
glDrawArrays1.1Draws primitives by reading vertices in order from the bound VAO.glDrawElements1.1Draws primitives using an index buffer to choose which vertices to use.glDrawArraysInstanced3.1Draws the same vertices many times in a single call.glDrawElementsInstanced3.1Indexed version of instanced drawing — the usual way to draw many copies of a model.glDrawArraysInstancedBaseInstance4.2Instanced glDrawArrays whose per-instance attributes start at element baseinstance instead of 0.glDrawArraysIndirect4.0glDrawArrays whose counts are read from a GPU buffer, so a shader can decide how much to draw.glMultiDrawElementsIndirect4.3Runs many indexed draws, each described by a command in a GPU buffer, in one call.glMultiDrawElementsIndirectCount4.6glMultiDrawElementsIndirect where the number of draws is also read from a GPU buffer.glPatchParameteri4.0Sets how many vertices make one patch, the primitive that tessellation shaders work on.
Textures
glGenTextures1.1Reserves names (IDs) for new texture objects.glBindTexture1.1Binds a texture to a target of the ACTIVE texture unit.glActiveTexture1.3Chooses which texture unit the next glBindTexture affects.glTexImage2D1.0Allocates a 2D texture image and optionally uploads pixels into it.glTexStorage2D4.2Allocates immutable storage for all mip levels of a 2D texture at once.glTexParameteri1.0Sets how the bound texture is sampled: filtering, wrapping, comparison.glTexParameterfv1.0Sets a texture parameter that takes floats — mainly the border color.glGenerateMipmap3.0Builds all the smaller mipmap levels from level 0 of the bound texture.glPixelStorei1.0Tells OpenGL how pixel rows are laid out in your memory, for uploads (unpack) and readbacks (pack).glTexSubImage2D1.1Overwrites a rectangle of an existing texture's pixels, without reallocating it.glTexImage3D1.2Allocates (and optionally fills) a texture with depth: a 3D volume or an array of 2D layers.glDeleteTextures1.1Frees textures and their GPU memory; the names can be reused.
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
glStencilFunc1.0Sets the stencil test: which fragments may be drawn, by comparing a reference value with the stencil buffer.glStencilOp1.0Says what happens to the stored stencil value in each of the three outcomes of the stencil and depth tests.glStencilMask1.0Chooses which bits of the stencil buffer can be written; 0x00 makes it read-only.glStencilOpSeparate2.0glStencilOp with separate actions for front-facing and back-facing triangles.glClearStencil1.0Sets the value glClear writes into the stencil buffer.
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
glFenceSync3.2Drops a marker into the command stream that becomes signalled when the GPU has executed everything before it.glClientWaitSync3.2Makes the CPU wait (up to a timeout) until a fence is signalled, or just checks it with timeout 0.glDeleteSync3.2Frees a fence created by glFenceSync.glFinish1.0Blocks the CPU until the GPU has completely executed every command issued so far.glGenQueries1.5Reserves names for query objects, which ask the GPU to measure something (time, visible samples).glBeginQuery1.5Starts measuring: everything drawn until glEndQuery is counted (or timed) by query id.glEndQuery1.5Stops the active query of that target; its result will be available a little later.glQueryCounter3.3Records the GPU clock at the moment the GPU reaches this point in the command stream.glGetQueryObjectuiv1.5Reads a query's state or result as a 32-bit number; mostly used to ask whether the result is ready yet.glGetQueryObjectui64v3.3Reads a query result as a 64-bit number: the form to use for GPU times in nanoseconds.glBeginConditionalRender3.0Skips the following draws on the GPU if an occlusion query found no visible samples, with no CPU readback.glEndConditionalRender3.0Ends the block started by glBeginConditionalRender; later draws run normally.
Debugging
glDebugMessageCallback4.3Registers a function the driver calls with a readable message whenever something goes wrong.glDebugMessageControl4.3Filters which debug messages reach the callback.glObjectLabel4.3Gives an OpenGL object a human-readable name for debug messages and tools.glPushDebugGroup4.3Opens a named section of commands, shown as a collapsible group in RenderDoc and similar tools.glPopDebugGroup4.3Closes the section opened by the last glPushDebugGroup.
Legacy (immediate mode)
glBegin1.0Starts sending vertices one by one from the CPU (immediate mode).glEnd1.0Finishes a glBegin block and draws the vertices sent inside it.glVertex3f1.0Emits one vertex position inside a glBegin/glEnd block.glColor3f1.0Sets the current color used by the following glVertex calls.glVertex2f1.0glVertex3f for 2D: emits a vertex at (x, y) with z = 0.glEnableClientState1.1Turned on one of the fixed vertex arrays (positions, colours, normals…) of old OpenGL.glVertexPointer1.1Described the fixed position array of old OpenGL; the ancestor of glVertexAttribPointer.glMatrixMode1.0Chose which built-in matrix stack (model-view or projection) the old matrix calls changed.glVertex*The old immediate-mode calls that sent one vertex at a time between glBegin and glEnd.glTranslate*Old calls that multiplied OpenGL's built-in current matrix by a translation (and glRotate, glScale by a rotation or scale).glRotate*Old call that rotated the built-in current matrix by angle degrees around the axis (x, y, z).glLight*Old fixed-function lighting: set up to 8 built-in lights (GL_LIGHT0…), computed per vertex by the driver.