Using GLEW to use OpenGL extensions under Windows

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

Yes, the OpenGL Extension Wrangler Library (GLEW) is a painless way to use OpenGL extensions on Windows. Here's how to get started on it:. 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 UsingGLEWtouseOpenGLextensionsunderWindows AskQuestion Asked 13years,8monthsago Modified 8years,7monthsago Viewed 42ktimes 23 15 I'vebeenusingOpenGLextensionsonWindowsthepainfulway.IsGLEWtheeasierwaytogo?HowdoIgetstartedwithit? openglglew Share Follow editedMay23,2017at12:33 CommunityBot 111silverbadge askedAug20,2008at3:19 AshwinNanjappaAshwinNanjappa 72.3k7676goldbadges202202silverbadges288288bronzebadges Addacomment  |  3Answers 3 Sortedby: Resettodefault Highestscore(default) Datemodified(newestfirst) Datecreated(oldestfirst) 36 Yes,theOpenGLExtensionWranglerLibrary(GLEW)isapainlesswaytouseOpenGLextensionsonWindows.Here'showtogetstartedonit: IdentifytheOpenGLextensionandtheextensionAPIsyouwishtouse.OpenGLextensionsarelistedintheOpenGLExtensionRegistry. Checkifyourgraphiccardsupportstheextensionsyouwishtouse.DownloadandinstallthelatestdriversandSDKsforyourgraphicscard. RecentversionsofNVIDIAOpenGLSDKshipwithGLEW.Ifyou'reusingthis,thenyoudon'tneedtodosomeofthefollowingsteps. DownloadGLEWandunzipit. AddtheGLEWbinpathtoyourWindowsPATHenvironmentvariable.Alternatively,youcanalsoplacetheglew32.dllinadirectorywhereWindowspicksupitsDLLs. AddtheGLEWincludepathtoyourcompiler'sincludedirectorylist. AddtheGLEWlibpathtoyourcompiler'slibrarydirectorylist. Instructyourcompilertouseglew32.libduringlinking.Ifyou'reusingVisualC++compilersthenonewaytodothisisbyaddingthefollowinglinetoyourcode: #pragmacomment(lib,"glew32.lib") Adda#includelinetoyourcode.EnsurethatthisisplacedabovetheincludesofotherGLheaderfiles.(YoumayactuallynotneedtheGLheaderfilesincludesifyouincludeglew.h.) InitializeGLEWusingglewInit()afteryou'veinitializedGLUTorGL.Ifitfails,thensomethingiswrongwithyoursetup. if(GLEW_OK!=glewInit()) { //GLEWfailed! exit(1); } Checkiftheextension(s)youwishtousearenowavailablethroughGLEW.YoudothisbycheckingabooleanvariablenamedGLEW_your_extension_namewhichisexposedbyGLEW. Example: if(!GLEW_EXT_framebuffer_object) { exit(1); } That'sit!YoucannowusetheOpenGLextensioncallsinyourcodejustasiftheyexistednaturallyforWindows. Share Follow answeredAug20,2008at3:19 AshwinNanjappaAshwinNanjappa 72.3k7676goldbadges202202silverbadges288288bronzebadges 6 3 Hello.DoesthisworkwithMinGW?Ihavebeentryingfor2daysnow,butallIgetareerrorslike:undefinedreferenceto'_imp__glewInit@0'andundefinedreferenceto'_imp____glewCreateShader' – DanielsaysReinstateMonica Aug16,2012at22:10 DantheMan:ThissolutionwaswithVisualC++.IhavenoideaifthisworkswithMingGW. – AshwinNanjappa Aug18,2012at2:37 AFAIK,#pragmacomment(lib,"glew32.lib")onlyworksonVisualC++.ForMinGWyoushouldaddthelibrariestothecompiler'scommandline(Ithinkit's-L). – ThiagoNegri Jan15,2013at10:02 @DantheMantrychangingorderoflibraries,especiallyinC::Bwhereyouhave'Project'and'Target'settingsandyoudecidewhichgetslinkedfirst.Idon'tunderstanditfullybutIjustfixedmyproblemthisway:). – kolenda Mar18,2013at22:37 WhichGLEWshouldIget,thesourceorthebinaries?I'mlost...andI'venoticedthatoneofthemhasanemptylibfolder. – Andrei May4,2014at8:57  |  Show1morecomment 6 PersonallyIwouldn'tuseanexitcommand. Iwouldthrowanexceptionsoyoucanclearanyotherinitialisationupattheendofthefunction. ie: try { //initopengl/directx //initdirectaudio //initdirectinput if(GLEW_OK!=glewInit()) { throwstd::exception("glewInitfailed"); } } catch(conststd::exception&ex) { //messagetoscreenusingex.what() //clearup } AndIagreewithOJ-ifyouwanttowritetutorialsforothers,thenthisisreallythewrongplaceforit.Therearealreadyaloadofgoodplacesforopengltutorials.Trythisoneforinstance. Share Follow answeredAug20,2008at5:08 graham.reedsgraham.reeds 15.8k1616goldbadges6868silverbadges133133bronzebadges Addacomment  |  4 Ilostsometime,butfinallyImanagedtogetGLEWworking. I'musingWindows7(x64),EclipseCDTandMinGW,andthewayisthat: DownloadMSYS(forMinGW)andrembertohaveMinGWinstalledcorrectly(PATHenviroinmentvariablesetcorrectly): http://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/msys-1.0.10/MSYS-1.0.10.exe/download?use_mirror=freefr&download= OnceMSYSinstalled,goto: http://glew.sourceforge.net/ anddownloadtheTGZpackage,whichisintendedtousewithUNIXsystems Thenopenthepackage(youcanuse7zipaswell)andfindthe"Makefile". Openitandwithatexteditor(Notepadshouldworkfine)findtherowwhichcontains"GLEW_DEST"andreplaceitwithsomethinglike"GLEW_DEST?=C:/MinGW" Nowyouarereadytogo,openMSYS(C:\MinGW\msys\1.0\msys.batinmycase)andintheshellopened,gotothefolderwherethe"Makefile"is. Thenwriteasimple:"makeinstall"andtheworkisdone(atleastformeitworked) PS:Ialsocopy-pastedglew-1.10.0-win32\glew-1.10.0\bin\Release\Win32file'sintomySystem32folder,andinEclipseCDTIaddedthelibrary"glew32"inthelinkeroptionandaddeda#includebefore#include Share Follow answeredJul29,2013at11:28 iMineLinkiMineLink 35811goldbadge33silverbadges1313bronzebadges 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?Browseotherquestionstaggedopenglgleworaskyourownquestion. TheOverflowBlog Feelingburnedout?You’renottheonlyone(Ep.440) Securityneedstoshiftleftintothesoftwaredevelopmentlifecycle FeaturedonMeta StagingGround:ReviewerMotivation,Scaling,andOpenQuestions Overhaulingourcommunity'sclosurereasonsandguidance Linked 16 UsingOpenGLextensionsOnWindows 8 glGenFramebuffersorglGenFramebuffersEXT? 7 BuildingGLEW1.7.0onWindowsusingMinGW 6 HowtowriteaninstallerthatchecksforopenGLsupport? 1 BudlingGLEWwithCygwinfail 0 WheninstallingKivyonWindows10,errormessage"fatalerrorC1083:Cannotopenincludefile:'GL/glew.h':Nosuchfileordirectory" -1 OpenglsuperbibleexamplecompliationerrorsSourcecode:drawingatrianglelibrary 0 Identifythegraphiccardisinbuiltorexternalc++ Related 16 UsingOpenGLextensionsOnWindows 0 opengl+glewinEclipse(forwindows) 5 GLEWandopenGLdeprecation 0 GLEWLoadOpenGL2EXTasOpenGL4 5 PerformanceadvantagesusingOpenGLLoaderGeneratoroverGLEW? 8 ResolvingOpenGLfunctionsusingglewinQT 1 ListopenglextensionsUSEDinruntime HotNetworkQuestions Whatdoes`tar:Cannotconnectto…:resolvefailed`mean? NcutiGatwais,accordingtoWikipedia,pronounced/ˈʃuːtiˈɡætwɑː/-whereistheNCorthographyderivedfrom? Whatpossiblepenaltiescantherebeforfailingtocomplywithrule286oftheUKhighwaycode? Atwhichpointisthemagneticfieldinacurrentcarryingloopthestrongest? Whendidhorsebackridingstart?AreDooshehcavepetroglyphsauthenticandcorrectlydated? Whataircraftisshowninthiscockpitpicture? “Officeofthedirector”or“Director’sOffice”? Whatdoes"Eatthis!"meaninGurennLagann? CanIrestwhileundertheeffectsoftheMeldintoStonespell? HowmuchdidthelivelihoodoftheRohirrimrelyonagriculture? NegativepredictionvaluesfromlinearregressioninR Doesasquatter'sexecutorhavetenantrightsafterthesquatter'sdeath? WorkingaroundMemoryLeakfromHermiteDecomposition Wordleguesser,breakingoutofloopbyraisingexception istheringofpowerserieswithcoefficientsinafieldfreeasamoduleoverthepolynomialssubring? Geometrynodes,Arccurvetomeshendpointsdontalign WhydidMordointroducethischaracterthisway? Gradingonacurveinrequireddoctoralcourse,failingasaresult Doandroidsleftontheirownhaveanyhopeofreplicating? WhywereMordo'sgroupofheroessodisastrouslyoverconfidentinconfrontingthisenemy? Arecopyrightlicensesasbindingassomeparticularrulesstatedbythecreatorofintellectualproperty? Mugglemilitarytacticsagainstmind-controllingwizards AlternativetoindividallyaddressableLEDs Howtodosimulationwhentwoatomsexistinthesamecoordinatepositioninthelattice? morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings  



請為這篇文章評分?