chapter 4 window creation and control © 2008 cengage learning emea

34
CHAPTER 4 CHAPTER 4 Window Creation and Control Window Creation and Control © 2008 Cengage Learning EM

Upload: naomi-hawkins

Post on 27-Dec-2015

226 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

CHAPTER 4CHAPTER 4

Window Creation and ControlWindow Creation and Control

© 2008 Cengage Learning EMEA

Page 2: CHAPTER 4 Window 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

Page 3: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

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

Page 4: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

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.

Page 5: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

THE GRAPHICS SYSTEMTHE GRAPHICS SYSTEM

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

Page 6: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

THE GRAPHICS SYSTEMTHE GRAPHICS SYSTEM Output Devices

Page 7: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

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

Page 8: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

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.

Page 9: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

ELEMENTS OF A 3D ELEMENTS OF A 3D ENVIRONMENTENVIRONMENT

Page 10: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

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.

Page 11: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

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

Page 12: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

THE GRAPHICS PIPELINE THE GRAPHICS PIPELINE ARCHITECTUREARCHITECTURE

Page 13: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

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.

Page 14: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

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.

Page 15: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

Programmable PipelinesProgrammable Pipelines

Page 16: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

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).

Page 17: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

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

Page 18: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

The Direct3D 10 Processing The Direct3D 10 Processing PipelinePipeline

Page 19: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

The Direct3D 10 Processing The Direct3D 10 Processing PipelinePipeline

Page 20: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

The Direct3D 10 Processing The Direct3D 10 Processing PipelinePipeline

Page 21: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

The OpenGL processing The OpenGL processing pipelinepipeline

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

Page 22: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

The OpenGL processing The OpenGL processing pipelinepipeline

Page 23: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

The OpenGL processing The OpenGL processing pipelinepipeline

Page 24: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

The OpenGL processing The OpenGL processing pipelinepipeline

Page 25: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

The OpenGL processing The OpenGL processing pipelinepipeline

Page 26: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

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.

Page 27: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

THE PROGRAMMING THE PROGRAMMING INTERFACEINTERFACE

OpenGL/GLUT

Page 28: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

THE PROGRAMMING THE PROGRAMMING INTERFACEINTERFACE

OpenGL/GLUT

Page 29: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

THE PROGRAMMING THE PROGRAMMING INTERFACEINTERFACE

OpenGL/GLUT

Page 30: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

THE PROGRAMMING THE PROGRAMMING INTERFACEINTERFACE

DirectX

Page 31: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

THE PROGRAMMING THE PROGRAMMING INTERFACEINTERFACE

DirectX

Page 32: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

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].

Page 33: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

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].

Page 34: CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA

WINDOW CREATION AND WINDOW CREATION AND CONTROLCONTROL