glFramebufferTexture2D - Khronos Group

文章推薦指數: 80 %
投票人數:10人

glFramebufferTexture2D — attach a texture image to a framebuffer object. C Specification. void glFramebufferTexture2D(, GLenum target ,. GLenum attachment ,. NameglFramebufferTexture2D—attachatextureimagetoaframebufferobjectCSpecificationvoidglFramebufferTexture2D(GLenumtarget, GLenumattachment, GLenumtextarget, GLuinttexture, GLintlevel); ParameterstargetSpecifiestheframebuffertarget.Thesymbolicconstantmustbe GL_FRAMEBUFFER.attachmentSpecifiestheattachmentpointtowhichanimagefrom textureshouldbeattached.Mustbeoneofthe followingsymbolicconstants: GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT,or GL_STENCIL_ATTACHMENT.textargetSpecifiesthetexturetarget.Mustbeoneofthe followingsymbolicconstants: GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_POSITIVE_Z,or GL_TEXTURE_CUBE_MAP_NEGATIVE_Z.textureSpecifiesthetextureobjectwhoseimageistobeattached.levelSpecifiesthemipmaplevelofthetextureimagetobeattached, whichmustbe0.DescriptionglFramebufferTexture2Dattachesthe textureimagespecifiedbytextureand levelas oneofthelogicalbuffersofthecurrentlyboundframebufferobject. attachmentspecifieswhetherthetextureimage shouldbeattachedtotheframebufferobject'scolor,depth,or stencilbuffer.Atextureimagemaynotbeattachedtothedefault framebufferobjectname0.Iftextureisnot0,thevalueof GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPEforthe specifiedattachmentpointissettoGL_TEXTURE, thevalueofGL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME issettotexture,andthevalueof GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVELissetto level.Iftextureisacubemap texture,thevalueofGL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE issettotextarget;otherwiseitissettothedefaultvalue GL_TEXTURE_CUBE_MAP_POSITIVE_X.Anypreviousattachmenttothe attachmentlogicalbufferofthecurrentlyboundframebuffer objectisbroken.Iftextureis0,thecurrentimage,ifany,attachedto theattachmentlogicalbufferofthecurrentlybound framebufferobjectisdetached.Thevalueof GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPEissetto GL_NONE.Thevalueof GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAMEissetto0. GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVELand GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACEare settothedefaultvalues0andGL_TEXTURE_CUBE_MAP_POSITIVE_X, respectively.Notes Specialprecautionsneedtobetakentoavoidattachingatextureimagetothe currentlyboundframebufferwhilethetextureobjectiscurrentlyboundand potentiallysampledbythecurrentvertexorfragmentshader.Doingsocouldleadto thecreationofa"feedbackloop"betweenthewritingofpixelsbyrenderingoperations andthesimultaneousreadingofthosesamepixelswhenusedastexelsinthe currentlyboundtexture.Inthisscenario,theframebufferwillbeconsidered framebuffercomplete,butthevaluesoffragmentsrenderedwhileinthisstatewill beundefined.Thevaluesoftexturesamplesmaybeundefinedaswell. Ifatextureobjectisdeletedwhileitsimageisattachedtothecurrently boundframebuffer,thenitisasifglFramebufferTexture2D hadbeencalledwithatextureof0fortheattachment pointtowhichthisimagewasattachedinthecurrentlyboundframebufferobject. Inotherwords,thetextureimageisdetachedfromthecurrentlybound framebuffer.Notethatthetextureimageisspecificallynot detachedfromanynon-boundframebuffers.Detachingtheimagefromanynon-bound framebuffersistheresponsibilityoftheapplication. ErrorsGL_INVALID_ENUMisgeneratedif targetisnotGL_FRAMEBUFFER.GL_INVALID_ENUMisgeneratedif textargetisnotanacceptedtexturetargetand textureisnot0.GL_INVALID_ENUMisgeneratedif attachmentisnotanacceptedattachmentpoint.GL_INVALID_VALUEisgeneratedif levelisnot0and textureisnot0.GL_INVALID_OPERATIONisgeneratedif thedefaultframebufferobjectname0isbound.GL_INVALID_OPERATIONisgeneratedif textureisneither0northenameofanexisting textureobject.GL_INVALID_OPERATIONisgeneratedif textureisthenameofanexistingtwo-dimensional textureobjectbuttextargetisnot GL_TEXTURE_2Doriftextureis thenameofanexistingcubemaptextureobjectbuttextarget isGL_TEXTURE_2D.AssociatedGetsglGetFramebufferAttachmentParameterivSeeAlsoglBindFramebuffer, glBindTexture, glCheckFramebufferStatus, glDeleteFramebuffers, glDeleteTextures, glFramebufferRenderbuffer, glGenerateMipmap, glGetFramebufferAttachmentParameteriv, glTexImage2DCopyright Copyright©2008KhronosGroup. Thismaterialmaybedistributedsubjecttothetermsandconditionssetforthin theOpenPublicationLicense,v1.0,8June1999. http://opencontent.org/openpub/.



請為這篇文章評分?