Drop Shadow 2D OpenGL - Game Development

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

Hi, I want to create a simple drop shadow effect for the OpenGL GUI I am working on. Basically I want a drop shadow behind my rectangles. Search: AdvancedForumSearch Forums Programming WebDevelopment Computers Tutorials Snippets DevBlogs Jobs Lounge Login Join! Today'sTopics Dream.In.Code>ProgrammingHelp >GameDevelopment DropShadow2DOpenGL Page1of1 NewTopic/Question Reply 6Replies-17009Views-LastPost:21August2010-09:09PM RateTopic: #1 Tom9729   Segmentationfault Reputation:181 Posts: 2,642 Joined: 30-December07 DropShadow2DOpenGL Posted19August2010-08:48PM Hi, IwanttocreateasimpledropshadoweffectfortheOpenGLGUIIamworkingon.BasicallyIwantadropshadowbehindmyrectangles. EverythingIfindseemstosuggestthatIcouldjustdrawablackboxanduseaGaussianfilteronit. I'dliketodothisontheGPUifpossiblebutI'veneverdoneanythingwithshadersbeforesoIjustwanttoseeifanyoneelsethinksthiswillworkbeforeIspendalotoftimeonit. Thanks IsThisAGoodQuestion/Topic? 0 Backtotop MultiQuote Quote+Reply RepliesTo:DropShadow2DOpenGL #2 stayscrisp   フカユ Reputation:1040 Posts: 4,326 Joined: 14-February08 Re:DropShadow2DOpenGL Posted20August2010-04:19AM Yesthisisdefinitelypossiblewithshaders.Youcouldpossiblyuse2passes,onetodrawthedropshadowandthenonetodrawthemodelitself. InfactIfoundawaytodotoonshadingwhichstartsoffbydrawingaslightlylargercopyofthemeshfortheoutline,thiscouldprobablybeadaptedandsimplifiedtodrawashadow.Wouldyouwantittodynamicallyadjustforthelightdirection/source? I'lltrytodigoutsomeinfoonthattoonshaderifyourinterested?wouldyoubeusingGLSL? WasThisPostHelpful? 1 Backtotop MultiQuote Quote+Reply #3 Tom9729   Segmentationfault Reputation:181 Posts: 2,642 Joined: 30-December07 Re:DropShadow2DOpenGL Posted20August2010-04:47AM Nolightsources,justgoingforasimpleeffectlikethis. IwasthinkingaboutusingCg,butGLSLwouldbefineaswell. WasThisPostHelpful? 0 Backtotop MultiQuote Quote+Reply #4 stayscrisp   フカユ Reputation:1040 Posts: 4,326 Joined: 14-February08 Re:DropShadow2DOpenGL Posted20August2010-10:37AM Ahright.WellwhatIsuggestedmightbeoverkillthen.ThisisdefinitelypossibleIjustdon'tknowhowtodoitotherthanwhatIalreadyposted. WasThisPostHelpful? 0 Backtotop MultiQuote Quote+Reply #5 Tom9729   Segmentationfault Reputation:181 Posts: 2,642 Joined: 30-December07 Re:DropShadow2DOpenGL Posted21August2010-08:42PM Woot,gotitworking(withoutshaders). Mysolutionwastodrawtherectangleseveraltimesandplaywiththedimensionsandopacity. CodeusesmygraphicslibrarybutisfairlyselfexplanatoryIthink... if(shadowRadius>0.0) { push(); constintredraw=10; constfloatposX=rect.getX(); constfloatposY=rect.getY(); constfloatwidth=rect.getWidth(); constfloatheight=rect.getHeight(); constfloatdestAlpha=0.1; for(inti=0;i #include #include #include #include LGraphicsg; LImageimg; LFontfnt; voiddisplay() { g.begin(); //Writesometextwithfontfntat(10,20),wrapafter100pixels. g.drawString(fnt,15,20,55,"HedgehogHodgepodge"); //Drawanimageimginabox,eg.at(100,100)andmakeit256x256. //Alsogiveitaborder-radiusof20pxanda5pxdropshadow... g.drawImage(img,LRectangle(100,100,128,128),20,5); //RoughequivalentsofglPushMatrix()andglTranslatef(). g.push(); g.translate(30,150); g.color(LColor(0.5,0.5,0,1)); g.fillRect(LRectangle(0,0,10,10)); g.pop(); g.color(LColor(0.6,0.8,0.1,1)); g.fillRect(LRectangle(40,200,40,40),15,5); g.end(); } intmain(intargc,char**argv) { dgInit(argc,argv); dgWindowOpen("Test",800,600,60,false); dgWindowSetDisplayFunc(display); g.bounds(LRectangle(20,100,400,300)); img.load("logo.png"); fnt.load("fragileb.ttf",12); glClearColor(0.6,0.9,0.9,1.0); dgWindowMainLoop(); return0; } ThisposthasbeeneditedbyTom9729:21August2010-09:09PM WasThisPostHelpful? 0 Backtotop MultiQuote Quote+Reply #7 stayscrisp   フカユ Reputation:1040 Posts: 4,326 Joined: 14-February08 Re:DropShadow2DOpenGL Posted21August2010-09:09PM Nicework,itsgoodwhenaplancomestogether WasThisPostHelpful? 0 Backtotop MultiQuote Quote+Reply ←PreviousTopic GameDevelopment NextTopic→ Page1of1 RelatedTopicsbeta2D,OpenGL,C++(where?)-LookingForOpenGL2DTutorialsForC++OnlyUseOpenGL?-Ehm...ReadTheThread,TopicIsABitBlurry2dOpenGLGameIdeaForCreatingSpriteSheets-IsItGood?HowDoYouDoIt?AreYouA"ContentProvider"?-HowDoYouFeelAboutHTML5?VideoGames-VideoGame2dGame-HowToDevelop2dGameInOpenglUsingGlutLibraries?2dGame-HowToDevelop2dGameInOpenglUsingGlutLibraries?OpenGL2VsOpenGL3/4For2DGraphics(GUI)?GameDevelopmentTools/Resources GeneralDiscussion CaffeineLounge CornerCubicle StudentCampus SoftwareDevelopment IndustryNews IntroduceYourself Nightmare.In.Code ProgrammingHelp CandC++ VB.NET Java C# Python PHP MobileDevelopment ASP.NET .NETFramework Ruby GameDevelopment Assembly Databases ColdFusion VB6 OtherLanguages 52WeeksOfCode WebDevelopment WebDevelopment HTML&CSS JavaScript GraphicDesign Flash&ActionScript Blogging SEO&Advertising WebServers&Hosting SiteCheck Follow&Share Tutorials Programming WebDevelopment ReferenceSheets CodeSnippets CSnippets C++Snippets JavaSnippets VisualBasicSnippets C#Snippets VB.NETSnippets ASP.NETSnippets PHPSnippets PythonSnippets RubySnippets ColdFusionSnippets SQLSnippets AssemblySnippets FunctionalProgrammingSnippets PerlSnippets HTML/CSSSnippets JavascriptSnippets Flash/ActionScriptSnippets ASPSnippets Linux,Unix,andBashSnippets OtherLanguagesSnippets Regex DICChatroom JoinourIRCChat ByeByeAds FAQ|TeamBlog|Feedback/Support|Advertising|TermsofUse|PrivacyPolicy|AboutUs Copyright2001-2022MediaGroup1LLC,AllRightsReservedAMediaGroup1LLCProduction-Version6.0.2.1.36Server:secure3



請為這篇文章評分?