CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA
LEARNING OBJECTIVES In this chapter you will learn about: – –The graphics system – –Input devices – –Output devices – –The frame buffer – –The elements of a 3D environment – –The graphics pipeline architecture – –Vertex processing – –Clipping and culling – –Rasterization and fragment processing – –Programmable pipelines – –The Direct3D 10 processing pipeline – –The input-assembler stage – –The vertex-shader stage – –The geometry-shader stage
LEARNING OBJECTIVES In this chapter you will learn about: – –The stream-output stage – –The pixel-shader stage – –The output-merger stage – –The OpenGL processing pipeline – –Evaluators and display lists – –The primitive assembly and rasterizer – –Pixel processing – –The fragment processor – –The OpenGL, GLUT, and DirectX programming interface – –Window creation and control – –Setting up a window and the main message loop – –Initializing Direct3D and generating output – –Setting up a window (GLUT), the main message loop and initializing OpenGL
THE GRAPHICS SYSTEM The term ‘graphics system’ formally describes any computing workstation with the ability to generate two- and/or three- dimensional images.
THE GRAPHICS SYSTEM Input Devices – –Request mode. – –Sample mode. – –Event mode.
THE GRAPHICS SYSTEM Output Devices
Frame Buffer The frame buffer, typically used to store the color information of individual pixels, is one of the most important components of any graphics system. – –accumulation buffer – –color indices – –overlay planes – –auxiliary buffers – –front and back buffer
ELEMENTS OF A 3D ENVIRONMENT Any three-dimensional environment, at its most basic level, consists of at least a viewer, one light source and a number of objects.
ELEMENTS OF A 3D ENVIRONMENT
THE GRAPHICS PIPELINE ARCHITECTURE A pipeline is a series of data processing units arranged in a chain-like manner with the output of the one unit read as the input of the next.
THE GRAPHICS PIPELINE ARCHITECTURE The graphics pipeline, also sometimes referred to as the rendering pipeline, implements the processing stages of the rendering process. These stages include: – –vertex processing – –clipping and culling – –Rasterization – –fragment processing
THE GRAPHICS PIPELINE ARCHITECTURE
Programmable Pipelines Today’s graphics cards all have pipelines built into their graphics processing units. The operations that could be performed by earlier graphics cards were standardized by the device manufacturer with only a number of parameters and properties available for modification. Modern graphics cards allow for not only the modification of a large number of parameters, but also for complete control over the vertex and fragment processors.
Programmable Pipelines These programmable vertex and fragment processors enable the real-time rendering of various advanced techniques only previously achievable using large rendering farms or not even possible in real-time at all.
Programmable Pipelines
The Direct3D 10 Processing Pipeline Each stage of the Direct3D 10 processing pipeline is configurable using the standard Direct3D application programming interface. The vertex shader, geometry shader, and pixel shader are programmable using either Microsoft’s proprietary High Level Shader Language (HLSL) or NVIDIA’s C for Graphics (Cg).
The Direct3D 10 Processing Pipeline The input-assembler stage The vertex-shader stage The geometry-shader stage The stream-output stage The pixel-shader stage The output-merger stage
The Direct3D 10 Processing Pipeline
The OpenGL processing pipeline Evaluators and Display Lists Primitive Assembly Rasterizer Pixel Processing Fragment Processor
The OpenGL processing pipeline
THE PROGRAMMING INTERFACE A programming interface refers to any API, such as OpenGL or DirectX, that provides an application programmer with a way to programmatically control low-level hardware subsystems (such as audio devices and graphics hardware). Direct3D and OpenGL programming interfaces facilitate interaction with the underlying graphics system, serving as software interfaces to graphics hardware.
THE PROGRAMMING INTERFACE OpenGL/GLUT
THE PROGRAMMING INTERFACE OpenGL/GLUT
THE PROGRAMMING INTERFACE OpenGL/GLUT
THE PROGRAMMING INTERFACE DirectX
THE PROGRAMMING INTERFACE DirectX
WINDOW CREATION AND CONTROL Setting up a Window and the Main Message Loop – –[see the source code “Window_Setup (win32)” on the book’s website for a detailed example].
WINDOW CREATION AND CONTROL Initializing Direct3D/OpenGL and Generating Output – –[see the source code “Initialization (Direct3D)” and “Initialization (OpenGL- GLUT)” on the book’s website for detailed examples].
WINDOW CREATION AND CONTROL