ptg
OpenGL
Shading
Language
Third Edition
Randi J. Rost
Bill Licea-Kane
With contributions by
Dan Ginsburg,
John M. Kessenich,
Barthold Lichtenbelt,
Hugh Malan, and
Mike Weiblen
Upper Saddle River, NJ • Boston • Indianapolis • San Francisco
New York • Toronto • Montreal • London • Munich • Paris • Madrid
Capetown • Sydney • Tokyo • Singapore • Mexico City
®
From the Library of STEPHEN EISEMAN
ptg
Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in this book, and the publisher was
aware of a trademark claim, the designations have been printed with initial capital letters or
in all capitals.
The authors and publisher have taken care in the preparation of this book, but make no
expressed or implied warranty of any kind and assume no responsibility for errors or
omissions. No liability is assumed for incidental or consequential damages in connection
with or arising out of the use of the information or programs contained herein.
The publisher offers excellent discounts on this book when ordered in quantity for bulk
purchases or special sales, which may include electronic versions and/or custom covers and
content particular to your business, training goals, marketing focus, and branding interests.
For more information, please contact:
U.S. Corporate and Government Sales
(800) 382-3419
corpsales@pearsontechgroup.com
For sales outside the United States, please contact:
International Sales
international@pearsoned.com
Visit us on the Web: informit.com/aw
Library of Congress Cataloging-in-Publication Data
Rost, Randi J., 1960-
OpenGL shading language / Randi J. Rost, Bill Licea-Kane ; with contributions by
Dan Ginsburg ... [et al.]. — 3rd ed.
p. cm.
Includes bibliographical references and index.
ISBN 978-0-321-63763-5 (pbk. : alk. paper) 1. Computer graphics. I. Licea-Kane, Bill.
II. Title.
T385.R665 2009
006.6'86—dc22
2009019529
Copyright © 2010 Pearson Education, Inc.
Chapter 3 © 2003 John M. Kessenich
Portions of Chapter 4 © 2003 Barthold Lichtenbelt
All rights reserved. Printed in the United States of America. This publication is protected by
copyright, and permission must be obtained from the publisher prior to any prohibited
reproduction, storage in a retrieval system, or transmission in any form or by any means,
electronic, mechanical, photocopying, recording, or likewise. For information regarding
permissions, write to:
Pearson Education, Inc
Rights and Contracts Department
501 Boylston Street, Suite 900
Boston, MA 02116
Fax (617) 671-3447
ISBN-13: 978-0-321-63763-5
ISBN-10: 0-321-63763-1
Text printed in the United States on recycled paper at Edwards Brothers in Ann Arbor, Michigan.
First printing, July 2009
From the Library of STEPHEN EISEMAN
ptg
To Baby Cakes, Baby Doll, Love Bug, and
Little Zooka—thanks for your love and support
To Mom and Pop—my first and best teachers
From the Library of STEPHEN EISEMAN
ptg
This page intentionally left blank
From the Library of STEPHEN EISEMAN
ptg
ix
0.Contents
Foreword to the Second Edition . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxi
Foreword to the First Edition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxix
About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxv
About the Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxvii
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxxix
Chapter 1. Review of OpenGL Basics . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 OpenGL History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 OpenGL Evolution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Execution Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4 The Framebuffer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.5 State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.6 Processing Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.7 Drawing Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.7.1 Geometry Specification . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.7.2 Per-Vertex Operations . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.7.3 Primitive Assembly. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.7.4 Primitive Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.7.5 Rasterization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.7.6 Fragment Processing. . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.7.7 Per-Fragment Operations . . . . . . . . . . . . . . . . . . . . . . . . 18
1.7.8 Framebuffer Operations . . . . . . . . . . . . . . . . . . . . . . . . . 18
1.8 Drawing Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.8.1 Pixel Unpacking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
From the Library of STEPHEN EISEMAN
- 1
- 2
- 3
- 4
- 5
- 6
前往页