OpenGL Programming Guide for Mac OS X - Apple (2011).pdf
(
5141 KB
)
Pobierz
OpenGL Programming Guide for Mac OS X
OpenGL Programming Guide for Mac OS X
Graphics&Animation:3DDrawing
2011-06-06
AppleInc.
©2004,2011AppleInc.
Allrightsreserved.
PROVIDED“ASIS,”ANDYOU,THEREADER,ARE
ASSUMINGTHEENTIRERISKASTOITSQUALITY
ANDACCURACY.
INNOEVENTWILLAPPLEBELIABLEFORDIRECT,
INDIRECT,SPECIAL,INCIDENTAL,OR
CONSEQUENTIALDAMAGESRESULTINGFROMANY
DEFECTORINACCURACYINTHISDOCUMENT,even
ifadvisedofthepossibilityofsuchdamages.
THEWARRANTYANDREMEDIESSETFORTHABOVE
AREEXCLUSIVEANDINLIEUOFALLOTHERS,ORAL
ORWRITTEN,EXPRESSORIMPLIED.NoApple
dealer,agent,oremployeeisauthorizedtomake
anymodification,extension,oradditiontothis
warranty.
Somestatesdonotallowtheexclusionorlimitation
ofimpliedwarrantiesorliabilityforincidentalor
consequentialdamages,sotheabovelimitationor
exclusionmaynotapplytoyou.Thiswarrantygives
youspecificlegalrights,andyoumayalsohave
otherrightswhichvaryfromstatetostate.
Nopartofthispublicationmaybereproduced,
storedinaretrievalsystem,ortransmitted,in
anyformorbyanymeans,mechanical,
electronic,photocopying,recording,or
otherwise,withoutpriorwrittenpermissionof
AppleInc.,withthefollowingexceptions:Any
personisherebyauthorizedtostore
documentationonasinglecomputerfor
personaluseonlyandtoprintcopiesof
documentationforpersonaluseprovidedthat
thedocumentationcontainsApple’scopyright
notice.
TheApplelogoisatrademarkofAppleInc.
Nolicenses,expressorimplied,aregranted
withrespecttoanyofthetechnologydescribed
inthisdocument.Appleretainsallintellectual
propertyrightsassociatedwiththetechnology
describedinthisdocument.Thisdocumentis
intendedtoassistapplicationdevelopersto
developapplicationsonlyforApple-labeled
computers.
AppleInc.
1InfiniteLoop
Cupertino,CA95014
408-996-1010
.MacisaregisteredservicemarkofAppleInc.
Apple,theApplelogo,Carbon,Cocoa,iChat,
Instruments,iPhoto,Logic,Mac,MacOS,
Macintosh,Objective-C,Pages,Quartz,and
XcodearetrademarksofAppleInc.,registered
intheUnitedStatesandothercountries.
OpenCLisatrademarkofAppleInc.
DECisatrademarkofDigitalEquipment
Corporation.
IOSisatrademarkorregisteredtrademarkof
CiscointheU.S.andothercountriesandisused
underlicense.
OpenGLisaregisteredtrademarkofSilicon
Graphics,Inc.
UNIXisaregisteredtrademarkofTheOpen
Group
XWindowSystemisatrademarkofthe
MassachusettsInstituteofTechnology.
EventhoughApplehasreviewedthisdocument,
APPLEMAKESNOWARRANTYORREPRESENTATION,
EITHEREXPRESSORIMPLIED,WITHRESPECTTO
THISDOCUMENT,ITSQUALITY,ACCURACY,
MERCHANTABILITY,ORFITNESSFORAPARTICULAR
PURPOSE.ASARESULT,THISDOCUMENTIS
Contents
Introduction
About OpenGL for Mac OS X 13
AtaGlance 13
OpenGLIsaC-based,Platform-NeutralAPI 14
DifferentRenderingDestinationsRequireDifferentSetupCommands 14
OpenGLonMacsExistsinaHeterogenousEnvironment 14
OpenGLHelpsApplicationsHarnessthePowerofGraphicsProcessors 14
ConcurrencyinOpenGLApplicationsRequiresAdditionalEffort 15
PerformanceTuningAllowsYourApplicationtoProvideanExceptionalUserExperience 15
HowtoUseThisDocument 15
Prerequisites 16
SeeAlso 16
Chapter1
OpenGLontheMacPlatform 19
OpenGLConcepts 19
OpenGLImplementsaClient-ServerModel 20
OpenGLCommandsCanBeExecutedAsynchronously 20
OpenGLCommandsAreExecutedInOrder 21
OpenGLCopiesClientDataatCall-Time 21
OpenGLReliesonPlatform-SpecificLibrariesForCriticalFunctionality 21
OpenGLinMacOSX 21
AccessingOpenGLWithinYourApplication 23
OpenGLAPIsSpecifictoMacOSX 23
Apple-ImplementedOpenGLLibraries 24
Terminology 25
Renderer 25
RendererandBufferAttributes 25
PixelFormatObjects 25
OpenGLProfiles 26
RenderingContexts 26
DrawableObjects 26
VirtualScreens 27
OfflineRenderer 31
RunninganOpenGLPrograminMacOSX 31
MakingGreatOpenGLApplicationsontheMacintosh 32
Chapter2
DrawingtoaWindoworView 35
GeneralApproach 35
DrawingtoaCocoaView 36
DrawingtoanNSOpenGLViewClass:ATutorial 37
2011-06-06 | © 2004, 2011 Apple Inc. All Rights Reserved.
3
CONTENTS
DrawingOpenGLContenttoaCustomView 39
Chapter3
DrawingtotheFullScreen 43
CreatingaFull-ScreenApplication 43
Chapter4
DrawingOffscreen 45
RenderingtoaFramebufferObject 45
UsingaFramebufferObjectasaTexture 46
UsingaFramebufferObjectasanImage 49
RenderingtoaPixelBuffer 51
SettingUpaPixelBufferforOffscreenDrawing 51
UsingaPixelBufferasaTextureSource 52
RenderingtoaPixelBufferonaRemoteSystem 53
Chapter5
ChoosingRendererandBufferAttributes 55
OpenGLProfiles(MacOSXv10.7) 55
BufferSizeAttributeSelectionTips 56
EnsuringThatBackBufferContentsRemaintheSame 56
EnsuringaValidPixelFormatObject 57
EnsuringaSpecificTypeofRenderer 58
EnsuringaSingleRendererforaDisplay 58
AllowingOfflineRenderers 59
OpenCL 60
DeprecatedAttributes 60
Chapter6
WorkingwithRenderingContexts 63
UpdatetheRenderingContextWhentheRendererorGeometryChanges 63
TrackingRendererChanges 64
UpdatingaRenderingContextforaCustomCocoaView 64
ContextParametersAltertheContext’sBehavior 66
SwapIntervalAllowsanApplicationtoSynchronizeUpdatestotheScreenRefresh 66
SurfaceOpacitySpecifiesHowtheOpenGLSurfaceBlendswithSurfacesBehindIt 66
SurfaceDrawingOrderSpecifiesthePositionoftheOpenGLSurfaceRelativetotheWindow
67
DeterminingWhetherVertexandFragmentProcessingHappensontheGPU 67
ControllingtheBackBufferSize 68
SharingRenderingContextResources 69
Chapter7
DeterminingtheOpenGLCapabilitiesSupportedbytheRenderer 73
DetectingFunctionality 73
GuidelinesforCodeThatChecksforFunctionality 76
4
2011-06-06 | © 2004, 2011 Apple Inc. All Rights Reserved.
CONTENTS
OpenGLRendererImplementation-DependentValues 77
Chapter8
OpenGLApplicationDesignStrategies 79
VisualizingOpenGL 79
DesigningaHigh-PerformanceOpenGLApplication 81
UpdateOpenGLContentOnlyWhenYourDataChanges 83
SynchronizewiththeScreenRefreshRate 85
AvoidSynchronizingandFlushingOperations 85
UsingglFlushEffectively 86
AvoidQueryingOpenGLState 86
UseFencesforFiner-GrainedSynchronization 87
AllowOpenGLtoManageYourResources 88
UseDoubleBufferingtoAvoidResourceConflicts 88
BeMindfulofOpenGLStateVariables 90
ReplaceStateChangeswithOpenGLObjects 90
UseOptimalDataTypesandFormats 90
UseOpenGLMacros 91
Chapter9
BestPracticesforWorkingwithVertexData 93
UnderstandHowVertexDataFlowsThroughOpenGL 93
TechniquesforHandlingVertexData 95
VertexBuffers 96
UsingVertexBuffers 96
BufferUsageHints 98
FlushBufferRangeExtension 100
VertexArrayRangeExtension 100
VertexArrayObject 102
Chapter10
BestPracticesforWorkingwithTextureData 105
UsingExtensionstoImproveTexturePerformance 106
PixelBufferObjects 107
AppleClientStorage 110
AppleTextureRangeandRectangleTexture 110
CombiningClientStoragewithTextureRanges 112
OptimalDataFormatsandTypes 113
WorkingwithNon–Power-of-TwoTextures 113
CreatingTexturesfromImageData 115
CreatingaTexturefromaCocoaView 116
CreatingaTexturefromaQuartzImageSource 118
GettingDecompressedRawPixelDatafromaSourceImage 119
DownloadingTextureData 119
DoubleBufferingTextureData 120
2011-06-06 | © 2004, 2011 Apple Inc. All Rights Reserved.
5
Plik z chomika:
piotrbard
Inne pliki z tego folderu:
Objective-C_for_Absolute_Beginners.pdf
(14232 KB)
Blocks Programming Topics - Apple (2011).pdf
(239 KB)
Wrox Professional iPhone and iPad Database Application Programming.pdf
(71970 KB)
Apress - Pro Core Data for iOS.pdf
(7871 KB)
AppleScript Language Guide.pdf
(2230 KB)
Inne foldery tego chomika:
AppleMagazine
Filmy
iATKOS ML2 10.8.2 (Build 12C54)
iMagazine
Inne
Zgłoś jeśli
naruszono regulamin