CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

Preview:

Citation preview

CHAPTER 4CHAPTER 4

Window Creation and ControlWindow Creation and Control

© 2008 Cengage Learning EMEA

LEARNING OBJECTIVESLEARNING 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 OBJECTIVESLEARNING 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 SYSTEMTHE GRAPHICS SYSTEM The term ‘graphics system’ formally

describes any computing workstation with the ability to generate two- and/or three-dimensional images.

THE GRAPHICS SYSTEMTHE GRAPHICS SYSTEM

Input Devices– Request mode.– Sample mode.– Event mode.

THE GRAPHICS SYSTEMTHE GRAPHICS SYSTEM Output Devices

Frame BufferFrame 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 ELEMENTS OF A 3D ENVIRONMENTENVIRONMENT

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 ELEMENTS OF A 3D ENVIRONMENTENVIRONMENT

THE GRAPHICS PIPELINE THE GRAPHICS PIPELINE ARCHITECTUREARCHITECTURE

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 THE GRAPHICS PIPELINE ARCHITECTUREARCHITECTURE

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 THE GRAPHICS PIPELINE ARCHITECTUREARCHITECTURE

Programmable PipelinesProgrammable 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 PipelinesProgrammable 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 PipelinesProgrammable Pipelines

The Direct3D 10 Processing The Direct3D 10 Processing PipelinePipeline

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 The Direct3D 10 Processing PipelineProcessing 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 The Direct3D 10 Processing PipelinePipeline

The Direct3D 10 Processing The Direct3D 10 Processing PipelinePipeline

The Direct3D 10 Processing The Direct3D 10 Processing PipelinePipeline

The OpenGL processing The OpenGL processing pipelinepipeline

• Evaluators and Display Lists• Primitive Assembly • Rasterizer• Pixel Processing• Fragment Processor

The OpenGL processing The OpenGL processing pipelinepipeline

The OpenGL processing The OpenGL processing pipelinepipeline

The OpenGL processing The OpenGL processing pipelinepipeline

The OpenGL processing The OpenGL processing pipelinepipeline

THE PROGRAMMING THE PROGRAMMING INTERFACEINTERFACE

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 THE PROGRAMMING INTERFACEINTERFACE

OpenGL/GLUT

THE PROGRAMMING THE PROGRAMMING INTERFACEINTERFACE

OpenGL/GLUT

THE PROGRAMMING THE PROGRAMMING INTERFACEINTERFACE

OpenGL/GLUT

THE PROGRAMMING THE PROGRAMMING INTERFACEINTERFACE

DirectX

THE PROGRAMMING THE PROGRAMMING INTERFACEINTERFACE

DirectX

WINDOW CREATION AND WINDOW CREATION AND CONTROLCONTROL

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 WINDOW CREATION AND CONTROLCONTROL

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 WINDOW CREATION AND CONTROLCONTROL

Recommended