Review
That is the end of Getting started, and it covered a lot of ground. You can now open a window and a Direct3D 11 device, compile HLSL shaders, get vertex data to them through buffers and input layouts and per-draw data through constant buffers, sample textures, work with vectors and matrices, and put all of it together into a 3D scene you can fly through. Before moving on, spend some time with it: change things, break things, and see whether you can predict what happens. Once the pieces feel familiar, the Lighting chapters are next.
Every later lesson is built from the same seven programs, so if a term below does not ring a bell, the chapter it came from is worth a second look.
Glossary
Direct3D 11 : Microsoft's graphics API on Windows, part of DirectX. Where OpenGL is a specification implemented by each driver, Direct3D is a runtime from Microsoft that talks to the driver for us.COM : the Component Object Model, the interface model Direct3D's objects use. From C and rin a method is called asInterface_Method(object, ...), the object first, and objects are freed withRelease .HRESULT : the result code most Direct3D calls return; negative means failure.Feature level : the set of hardware capabilities asked for when creating the device. Our lessons ask for D3D_FEATURE_LEVEL_11_0.Device : the ID3D11Device, which creates resources (buffers, textures), shaders and state objects.Device context : the ID3D11DeviceContext, which holds the pipeline's current state, issues draws and updates resources. We use theimmediate context , which sends its work straight to the GPU. OpenGL's context does both this job and the device's.DXGI : the DirectX Graphics Infrastructure, the layer below Direct3D that owns swap chains, adapters and the DXGI_FORMAT list of pixel formats.Swap chain : the images that take turns being drawn into and shown in the window. Created together with the device byD3D11CreateDeviceAndSwapChain .Back buffer : the swap chain image we are currently drawing into, out of sight until it is presented.Present :IDXGISwapChain_Present shows the finished back buffer. A sync interval of 1 waits for the display's vertical blank.Render target view : a view of a texture that lets the pipeline draw into it, here the back buffer. Bound withOMSetRenderTargets , cleared withClearRenderTargetView .Resource view : Direct3D's way of letting one resource be used in different roles: a render target view to draw into it, a shader resource view to read it, a depth-stencil view for depth.rin : the small C-like language the lessons are written in.x&takes an address,p[0]reaches through a pointer, and procedures are declared asname: proc(...) -> type = { ... }. : builds every lesson listed inrin buildbuild.rinwith CMake, Ninja and clang-cl; each becomes an executable named after its source file. : the shared helpers:includes/win32.rin(the Win32, Direct3D 11, DXGI, D3DCompile and WIC declarations, standing in for glad and GLFW),math.rin(glm),image.rin(stb_image) andlearn/(LearnOpenGL'sshader.h,camera.h,filesystem.handmodel.h). : turns a path relative to the repository root into a full one, finding the root by walking up from the executable to the folder that holdsfilesystem_path resources.Window procedure : the callback Windows sends a window's messages to (key presses, the mouse wheel, closing); our counterpart of GLFW's callbacks.Message loop :PeekMessageA andDispatchMessageA at the top of every frame, handing waiting messages to the window procedure.Render loop : the loop that, each frame, reads input, clears, draws and presents, until the window is closed.Graphics pipeline : the chain of stages a draw call passes through on its way from vertex data to pixels in a render target.Shader : a small program that runs on the GPU as one stage of the pipeline.HLSL : the High-Level Shading Language, Direct3D's counterpart of GLSL.Shader target : the kind of shader and shader model to compile for, such asvs_5_0orps_5_0. : compiles HLSL source into bytecode, returned in an ID3DBlob; the device then turns the bytecode into a shader object.D3DCompile learn/shader.rindoes both for a file'svs_mainandps_main.Vertex : the data for one point of a shape: a position, and whatever else we attach to it, such as a colour, a normal or a texture coordinate.Input assembler : the first stage, which reads vertices out of buffers and groups them into primitives.Primitive topology : how the input assembler groups vertices, for example every three into a triangle (D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST).Vertex buffer : an ID3D11Buffer created with D3D11_BIND_VERTEX_BUFFER, holding vertex data in GPU memory; GL's vertex buffer object. Its stride and offset are given when it is bound.Usage : how a resource will be updated. D3D11_USAGE_IMMUTABLE is filled once at creation; D3D11_USAGE_DYNAMIC is rewritten by the CPU, for instance every frame.Input layout : the description of one vertex: which semantic each attribute feeds, its format and its byte offset. Created against the compiled vertex shader, which is where Direct3D checks that the two match. It takes the part of GL's attribute pointers, but holds no buffers.Index buffer : a buffer of indices into the vertex buffer, so shared vertices are stored once; GL's element buffer object. Drawn withDrawIndexed .Semantic : a name after a colon in HLSL, such asPOSITIONorTEXCOORD, that ties a shader input or output to the input layout or to the next stage.System value : a semantic the pipeline itself understands, starting withSV_.SV_Positionis the clip-space position (GLSL's gl_Position) andSV_Targetthe colour written to the render target.Vertex shader : runs once per vertex and returns, at least, its position in clip space.Rasterizer : clips primitives, divides by w, applies the viewport, and works out which pixels each triangle covers, interpolating the vertex shader's outputs across it. Configured with arasterizer state (fill mode, culling, winding).Pixel shader : runs once for every covered pixel and returns its colour; GL's fragment shader.Output merger : the last stage, which does the depth and stencil tests and blending, and writes to the render targets.Viewport : the rectangle of the render target, and the range of depth, that NDC is mapped onto. Set withRSSetViewports .Winding : whether a triangle's corners appear clockwise or counter-clockwise on screen, which decides its front. Direct3D's default front is clockwise; our lessons set FrontCounterClockwise to keep LearnOpenGL's convention.Wireframe : drawing only triangle edges, chosen with D3D11_FILL_WIREFRAME in a rasterizer state; GL'sglPolygonMode .Interpolation : the rasterizer blending each vertex shader output between a triangle's three corners, so the pixel shader receives a smoothly varying value.Constant buffer : a buffer of values shared by every vertex and pixel of a draw, declared in HLSL as acbufferand bound to a register such asb0; Direct3D's counterpart of uniforms. HLSL packs it into 16-byte registers, and the rin struct that mirrors it must match.Map : gives the CPU a pointer into a dynamic resource. With D3D11_MAP_WRITE_DISCARD it hands back fresh memory each time, so the GPU never waits for the CPU.Texture : an image the GPU can sample, made oftexels ; usually stretched over a surface to give it detail.Texture coordinates : where on a texture a vertex sits, from 0 to 1 across and down. In Direct3D (0, 0) is the image's top-left corner, so images are loaded without flipping.Sampler state : a separate object that decides how a texture is read: its filtering and its address modes. Bound to a register such ass0.Texture address mode : what happens to coordinates outside 0..1, such as D3D11_TEXTURE_ADDRESS_WRAP (repeat) or clamp; GL's texture wrapping.Texture filtering : how a colour is worked out when a pixel does not land exactly on one texel: nearest (point), linear, or anisotropic.Mipmaps : a chain of smaller copies of a texture, each half the size of the last, so distant surfaces can sample a version of a suitable size. Our textures get theirs fromGenerateMips .Shader resource view : a view that lets shaders read a texture, bound to a register such ast0withPSSetShaderResources . The registers play the part of GL's texture units.WIC : the Windows Imaging Component, Windows' own image codecs, whichimage_load uses to decode .png and .jpg files.Vector : a direction with a length, in any number of dimensions; also used for positions, colours and texture coordinates.vec2,vec3,vec4in rin,float2tofloat4in HLSL.Unit vector : a vector of length 1.Normalizing makes one by dividing a vector by its length.Dot product : the lengths of two vectors multiplied by the cosine of the angle between them; for unit vectors, just the cosine.Cross product : a vector perpendicular to two others; only defined in 3D.Matrix : a rectangular grid of numbers. A 4x4 matrix can hold any combination of translations, rotations, scales and projections, applied to a vector by multiplication.Identity matrix : the matrix that changes nothing, ones on the diagonal; the starting point for building others.Homogeneous coordinates : vectors with a fourth component, w, which lets a 4x4 matrix translate and carries the depth that perspective divides by. Points have w = 1, directions w = 0. : the lessons' vector and matrix library, our counterpart of GLM: right-handed, column vectors (\(M \cdot \bar{v}\)), and projections onto Direct3D's 0..1 depth.math.rinRow-major : storing a matrix row by row, asmat4does. HLSL expects column-major in constant buffers unless a shader says#pragma pack_matrix(row_major), which every one of ours does; thenmul(M, v)is \(M \cdot \bar{v}\).Local space : the coordinates a model is written in, relative to its own origin.World space : coordinates relative to the origin of the whole scene. Themodel matrix takes local coordinates here.View space : coordinates relative to the camera, which sits at the origin looking down -z. Theview matrix takes world coordinates here.Clip space : what the vertex shader outputs, after theprojection matrix . A point is visible when \(-w \le x, y \le w\) and \(0 \le z \le w\).Perspective division : dividing clip coordinates by w, done by the rasterizer, which gives normalized device coordinates.Normalized device coordinates (NDC): x and y from -1 to 1, and in Direct3D z from 0 (near) to 1 (far). Only what lies inside is drawn.Screen space : pixel coordinates in the render target, from the top-left corner with y growing downwards; reached from NDC by the viewport transform.Frustum : the region of view space a projection keeps: a box for anorthographic projection (m4_ortho ), a truncated pyramid for aperspective projection (m4_perspective ).Field of view : the angle between the top and bottom of a perspective frustum; narrowing it zooms in.Depth buffer : a texture the size of the render target that stores the depth of the nearest surface drawn at each pixel; the z-buffer. Created with a depth format such as DXGI_FORMAT_D24_UNORM_S8_UINT and used through adepth-stencil view .Depth test : comparing each new pixel's depth with the stored one and discarding it if it is farther. In Direct3D it is on by default whenever a depth-stencil view is bound; it is part of thedepth-stencil state .Look-at matrix : a view matrix built from the camera's position, a point it looks at and an up vector, from the camera's right, up and direction axes.m4_look_at .Euler angles : yaw, pitch and roll, three angles that describe an orientation. Our camera turns yaw and pitch into its front vector.Delta time : how long the last frame took, which movement is scaled by so that speed does not depend on the frame rate. Measured withQueryPerformanceCounter . : Win32's "is this key or mouse button held right now", our counterpart ofGetAsyncKeyState glfwGetKey . It sees the whole system, so the lessons ignore it while their window is not in front. : the fly camera every later lesson uses: W A S D, Space and Shift to move, right mouse button to look, wheel to zoom.learn/camera.rin