how does glDepthRange work? - Stack Overflow

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

glDepthRange specifies a linear mapping of the normalized depth coordinates in this range to window depth coordinates. Regardless of the actual ... 2022DeveloperSurveyisopen!Takesurvey. Home Public Questions Tags Users Companies Collectives ExploreCollectives Teams StackOverflowforTeams –Startcollaboratingandsharingorganizationalknowledge. CreateafreeTeam WhyTeams? Teams CreatefreeTeam Collectives™onStackOverflow Findcentralized,trustedcontentandcollaboratearoundthetechnologiesyouusemost. Learnmore Teams Q&Aforwork Connectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch. Learnmore howdoesglDepthRangework? AskQuestion Asked 9years,4monthsago Modified 9years,4monthsago Viewed 7ktimes 5 0 Myvertexcordsare: GLfloatvertices[]= { 0.5f,0.5f,0.5f, -0.5f,0.5f,0.5f, -0.5f,-0.5f,0.5f, 0.5f,-0.5f,0.5f,//face1 0.5f,-0.5f,-0.5f, -0.5f,-0.5f,-0.5f, -0.5f,0.5f,-0.5f, 0.5f,0.5f,-0.5f,//face2 0.5f,0.5f,0.5f, 0.5f,-0.5f,0.5f, 0.5f,-0.5f,-0.5f, 0.5f,0.5f,-0.5f,//face3 -0.5f,0.5f,0.5f, -0.5f,0.5f,-0.5f, -0.5f,-0.5f,-0.5f, -0.5f,-0.5f,0.5f,//face4 0.5f,0.5f,0.5f, 0.5f,0.5f,-0.5f, -0.5f,0.5f,-0.5f, -0.5f,0.5f,0.5f,//face5 -0.5f,-0.5f,0.5f, -0.5f,-0.5f,-0.5f, 0.5f,-0.5f,-0.5f, 0.5f,-0.5f,0.5f//face6 }; now,iamchangingzcordsby: for(inti=0;i<24;i++) vertices[i*3+2]*=10 glDepthRange(0,10.0); Now,iamexpectingthatzcordswillbemappedto-0.5to0.5rangeduetoglDepthRangecallandicanseeapropercube,butitgiveso/pasthatofwhenicommentglDepthRangecallabovewithdistortedgeometry. opengldepthdepth-bufferdepth-testing Share Improvethisquestion Follow askedJan7,2013at12:22 debonairdebonair 2,39544goldbadges2525silverbadges6060bronzebadges Addacomment  |  1Answer 1 Sortedby: Resettodefault Highestscore(default) Datemodified(newestfirst) Datecreated(oldestfirst) 6 Letmeciteyouthemanpages: Afterclippinganddivisionbyw,depthcoordinatesrangefrom-1to1,correspondingtothenearandfarclippingplanes.glDepthRangespecifiesalinearmappingofthenormalizeddepthcoordinatesinthisrangetowindowdepthcoordinates.Regardlessoftheactualdepthbufferimplementation,windowcoordinatedepthvaluesaretreatedasthoughtheyrangefrom0through1(likecolorcomponents).Thus,thevaluesacceptedbyglDepthRangearebothclampedtothisrangebeforetheyareaccepted. highlightsmine Inotherwords,youcan'treallyusedepthvaluesgreaterthan1;youhavetocalculatethemproperlybyyourself,instead.ItessentiallyconcludestosettingappropriatenearandfarvaluesinyourProjectionMatrixandtranslatingZcoordinateinyourModelviewMatrix,sothatallfinalZsarebetweentheaforementioned. Pleaseleaveacommentifyouneedmoredetailedexplanation. Share Improvethisanswer Follow editedJan7,2013at12:31 answeredJan7,2013at12:25 BartekBanachewiczBartekBanachewicz 37.6k77goldbadges8989silverbadges133133bronzebadges 2 Thanksforyourreply.Igotyourexplanationaboutthematrix.Butstillididnotget"glDepthRangespecifiesalinearmappingofthenormalizeddepthcoordinatesinthisrangetowindowdepthcoordinates"whatdoesitmean?canyougiveasmallexampleshowinghowglDepthRangeworks. – debonair Jan7,2013at12:44 It'sacomplicatedwaytosaythatyourcompressedrange(setbyglDepthRange)isstretchedinto(0,1):)(lookagainattheman-windowdepthvaluesarealwaystreatedastheyare(0,1))Iguessyoumightfinditquitenon-useful,butyoushouldn'tactuallyworryaboutit. – BartekBanachewicz Jan7,2013at12:54 Addacomment  |  YourAnswer ThanksforcontributingananswertoStackOverflow!Pleasebesuretoanswerthequestion.Providedetailsandshareyourresearch!Butavoid…Askingforhelp,clarification,orrespondingtootheranswers.Makingstatementsbasedonopinion;backthemupwithreferencesorpersonalexperience.Tolearnmore,seeourtipsonwritinggreatanswers. Draftsaved Draftdiscarded Signuporlogin SignupusingGoogle SignupusingFacebook SignupusingEmailandPassword Submit Postasaguest Name Email Required,butnevershown PostYourAnswer Discard Byclicking“PostYourAnswer”,youagreetoourtermsofservice,privacypolicyandcookiepolicy Nottheansweryou'relookingfor?Browseotherquestionstaggedopengldepthdepth-bufferdepth-testingoraskyourownquestion. TheOverflowBlog Makeyouropen-sourceprojectpublicbeforeyou’reready(Ep.444) Thescienceofinterviewingdevelopers FeaturedonMeta AnnouncingthearrivalofValuedAssociate#1214:Dalmarus Improvementstositestatusandincidentcommunication RetiringOurCommunity-SpecificClosureReasonsforServerFaultandSuperUser Temporarilypausingthesitesatisfactionsurvey StagingGround:ReviewerMotivation,Scaling,andOpenQuestions Related 42 WhenshouldIuseindexedarraysofOpenGLvertices? 19 OpenGLHowManyVAOs 1 Strategieswhenvertexattributesarewithdifferentindexing 15 CUDAcubemaptextures 0 TranslatingMatrizinGLSLwon'tworkwithvariables 6 DoesitmakesensetohaveindicesandnormalsinVBOs 0 ParseOBJfiletogetvertexnormals? 0 OpenGLworldcoordinatesfrommousecoordinates HotNetworkQuestions Wouldn'tMiller'splanetbefriedbyblueshiftedradiation? Longestgeometricprogressionofprimes IntheU.S.,whyisn'tturnoutandactivismproportionaltoinfluence? GAMmodelwarningmessage:stepfailureinthetaestimation HowcanaverbalreasoningquestionbesolvedwithMathematica? Softwareforcreatinghand-writtenslidesthatarerevealedgradually Ihaveanarmadaofteleportingskyfortresses.DoIstillneedanavy? Meaningandoriginoftheword"muist" WhydoesBendersay"Pleaseinsertgirder"? Iwant8bitsforeverycharacter! Whatdoyoucalladesperateattemptunlikelytosucceed? Pleasehelpmeclarifythissentenceabout'microtones'onGroveMusic Non-committingauthenticatedencryptionschemesvscommittingauthenticatedencryptionschemes WhentochangeoilfornewgenerationMazda? SelectonlyonepointinpolygonusingQGIS WhatisRNAVtransitionandwhatisthedifferencebetweenRNAVtransitionandRNAVSTAR CovidTestRequirementforDubaiTransitFromIrelandtoIndonesia GameinJamesBondfilm"FromRussiawithlove" Whyaren'tnegativefrequenciesfoldedinreconstructionofthealiasedsignal? CanWgatebewrittenonlyusingH,T? Whatdoestheidiomaticphrase"erronthesideof"mean? WhattapeformatdidtheNintendoFamicomDataRecorderuse? Tryingtouseacaralternatorforapowersource(notforcar) AnelegantwaytowritelongequationsinLaTex? morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings  



請為這篇文章評分?