Using Modern OpenGL in C++
HTML-код
- Опубликовано: 11 сен 2024
- Patreon ► / thecherno
Twitter ► / thecherno
Instagram ► / thecherno
Discord ► thecherno.com/...
Series Playlist ► thecherno.com/...
GLEW ► glew.sourceforg...
In this video we're going to be loading all of the OpenGL functions that are accessible to us from our GPU drivers, using a library called GLEW. This will allow us to use the modern functionality of OpenGL in our application.
Thank you to the following Patreon supporters:
- Samuel Egger
- Dominic Pace
- Kevin Gregory Agwaze
- Sébastien Bervoets
- Tobias Humig
Gear I use:
-----------------
BEST laptop for programming! ► geni.us/pakTES
My FAVOURITE keyboard for programming! ► geni.us/zNhB
FAVOURITE monitors for programming! ► geni.us/Ig6KBq
MAIN Camera ► geni.us/t6xyDRO
MAIN Lens ► geni.us/xGoDWT
Second Camera ► geni.us/CYUQ
Microphone ► geni.us/wqO6g7K
Cherno: "Watch this video linked up there"
Top right corner: *crickets chirping*
How do I add the preprocessor definition if I am using g++ to compile my program?
@@neillunavat while compiling at the -D flag in the g++ command to add a preprocessor definition
or simply do #define SOMETHING_IDK
I went to college for computer programing and we had a course for OpenGL. Not once did our teacher tell us what GLEW was for, he just said download it from the college's server and add it to our project. You simply explaining what it does and its purpose has helped me better understand it. You actually saying its name and thus learning the W stands for wrangler has helped me understand this better.
My college professor didn't even tell me to download GLEW. He just said to complete assignment lol
@@sohailape i have question, if i were to open a new project, i would need to do all the linking again right ?
@@4tehath yes
@@DagreenApple thank you sir
yep, that's college/uni alright lol
Just one VS tip. You don't need c/p piece of code if you move it up or down. Just select piece of code, keep ALT and UP or DOWN key, and move that peace through code.
THANK YOU. Yall need to listen up to this guy
Keyboard shortcuts ftw
Thank you!
Haha, how did i not know that.... Been using VS for many years. Thanks for that one, mate!
@@arne1881 The keyboard shortcuts I use: alt tab, alt backspace, ctrl backspace, alt up and down, shift click, click + shift click (mark places without carot, shift click), ctrl a, ctrl c, ctrl v, windows e, windows d, windows p, (windows tab is a thing), ctrl w, ctrl q, windows key 1-x where x is the amount of things on your taskbar whether open or not), ctrl / (comments depending on editor), shift home, shift end, shift page up, shift page down, ctrl delete, and probably more
I was using this tip on ATOM Text Editor, but instead of ALT it used the ctrl + up/down. When tried it on VS thought it doesn't exists as a feature lel
I love how you can just get a coffee cup and chill watching these videos while typing the fun stuff out... Love the energy. I know am like 7 years late to this, but keep it going man! Love the content! So much to learn from you!
For those wondering, at 12:39 is the VisualAssist extension feature for searching methods, that can also be seen in Cherno's "My Top 5 Visual Assist Features" video at 6:04. In visual studio I think the closest you can get is the ctrl+T.
谢了哥们
After following this tutorial series almost all the way to the end, I decided to make my own project from scratch again, using the tutorials as a basis for the new project. I got so many linker errors and couldn't figure out what they were from searching on the Internet. Then I re-watched this and remembered that I had to define the GLEW_STATIC. I missed that when I side-by-side compared the two projects to each other. So if you're making a new project, don't forget this define!
OMYGOD this is exactly what i did wrong! thank you so much.
wtf right when iread this comment the video got to that part
what if i define it and the linker still acts as if I hadn't. Like, it gives the same error?
Ohh ya , Now I learned through the hard way 🤣
@@anastasiapedan7496 l am facing the same problem bro
Do you have the entire EA Orchestra making music for your series?
69th like lol
yeah I think so
How do I add the preprocessor definition if I am using g++ to compile my program?
@@neillunavat A preprocessor definition can also be added by using #define. For example, you can do on the start of the file (before #include ) #define GLEW_STATIC
is this a joke? im not being sarcastic or anything im genuinely wondering if this is a joke or not
Great video, as always. I just can tell you again and again how much I like all the in depth stuff like showing how to reverse engineer libraries etc.
And I just want to mention you forgot to link the glew homepage for all the lazy guys inside your description :D
but I can't download and install it for you, sorry me
I have always wanted to learn OpenGL and C++. After many crappy videos I found your channel and this sires on OpenGL, and the way you explain things is amazing! Keep up the fantastic work!
Hi, Luke. Did you learn OpenGl? Maybe made some projects?
@@user-ps6yl7kl3e нет
doing this on linux, watching you fix the windows link madness, while i fix the linux link madness
Love these videos so far. If you take these into depth and really cover it all (Cameras, Lighting, 3D), etc, etc then it will hands down be the best series on the topic out there, and that's saying a lot because there are some REALLY good tutorial series on this subject, so keep up the great work! Also ignore my comment on the last video, I thought I was writing it from this one, and I see this one was only uploaded a day ago, so it's quite clear you're still working on these :)
Your keyboard sounds so nice. :D
It's just the laptop's keyboard.
It's Dell XPS 13/15.
Learning this with VS Code, GCC on Linux! I appreciate your style of teaching. (By the way, I used to use windows and man VS sets up projects weirdly.)
same im wondering if we need to do this too or is this video just for Windows OS users.
@@vectoralphaSec This video has some Windows/visual studio specific things, but on Linux you will still likely be using GLEW for OpenGL development, and this video explains what GLEW is and why it is used. It also discusses linking and aspects of compiling that are useful on any platform, but demonstrated here on Windows.
Thank you Yan. These videos are wonderful. As a point for those running on Mac hardware (in Windows) when choosing the linking folders, be sure to use the x64 folder instead of the Win32.
I really love how you explain the errors and solutions, thank you for that. It's really informative.
Pretty neat that you focus on not just putting all the stuff like a cook repice and take your time to explain most of the stuff that probably a non-cpp programmer doesn't really know :)
*When you read way too many tutorials before and you see someone including opengl stuff after glfw
Dude, I already know where this is going.
I have watch many of your video's , and clearly you are the best to explain the errors and how to fix them. I enjoy your channel, have learnt so much from you. thank you.
First, you speak very fast, which is very good!
Second, you show/explain things very clearly, which is VERY very good!
Third, maybe I missed this, but why would you build a 32-bit application in this day and age? Memory limits, memory fragmentation, and lack of registers are major hindrances in 32-bit.
Awesome, very little dead air, excellent pace keep on rocking
This is a very good series on OpenGL. Learnt alot of important points.
@11:10 Q:"The order really does not matter...".
TIP: The order really matters if you want to succesfully cross-link for multiple operating systems without headaches. For example in the Linux OS for latest versions of gcc-ld linkers, clang, object linking will fail if the function symbols dependency graph will not match the exact ordering, which is fine because the architecture imply a better time performance at the link time. Let's no go further and talk about circular dependencies....
this video makes me feel like I am stupid.
"what I was doing until now?"
T-T
well am sure you are smarter now :)
@@jeffreytawiah2752 i'm not :(
Loved the in depth look on opengl. Learned a lot of things i had no idea about. Keep going and i'll definetely support you on patreon.
That is really cool
Very thorough! Really enjoying your speaking and video style.
I am learning Linux and OpenGL. I found a guide to set up OpenGL. It then had some code to cut and paste. The instructions showed how to compile the code. I then run the program and a white square appeared. Job done.
God, that was a verbal attack on my brain
Lmao you're not alone
@@lodostic1015 I'm here with u
11:50 I had 230+ errors at this stage which had me a little worried, but they were all resolved on the next step.
Got to say your videos are too awesome. You are explaining every single bit of details. Thank you.
Crazy.
Thanks amd for giving me functions to use! Hahaha
17:22 If you want to switch the gpu that your exe performs on to NVDIA just right-click on your desktop -> NVIDIA control panel -> Manage 3d settings -> program settings. From there you can chose the program and the preferred graphics processor. I know, absolutely nobody asked but pls comment if that helped
Great videos. Im learning a lot. I love all the guitars too, well taken care of. I'm a programming guitar player as well. Subscribed.
oh crap, i can't stop staring those guitars!
This video is hilariously balls-to-the-wall through the roof. I prefer that and appreciate it, mind you, but still...holy crap. I'd also like to mention that I've never met a single soul who's idea of doing something "just for fun" was creating linker errors. No one. Ever.
...but I still consider that to be a positive bonus...
Why the background music is so epic. I feel like I'm about to get into combat against my GPU
Awesome video as allways, and nice explaination keep it up love your videos.
It took me a lot of time to discover these notions by myself, and I did not go that deep so this video got me a lot more knowledge! Thanks Cherno!
This tutorial is amazing and you are really good at teaching !! great job sir !
I had a ton of errors in the actual glew.h file even tho I hadn't touched it so I took a break, got some air and came back only to find that now the thing is completely fine. Patience is key.
Thank you man, your series are the best
For Linux users to compile the program with glew you can use "g++ ProgramName.cpp -lglfw -lGLEW -lGL -o ProgramName" as most Linux distributions already have glew and glfw installed.
I LOVE THIS
Thanks for your help, bro. The video is very useful and I really enjoyed when I was watchining it!
So in depth. Awesome that you show errors. Awesome video
Excellent tutorial, thanks Cherno!
9:08 i found this out this hard way
quick comment on GLAD: i like it more than GLEW since i can just copy/paste the two source files directly into my project and there's no library or dll to ever worry about.
of course, you never have to touch GLEW once you've done what you need to do, so the difference is, at most, a few minutes of effort.
Not really, glew is quite buggy, glad is comparatively uch less buggy
yeah, since posting this comment I've not even touched GLEW once. i'm just so satisfied with GLAD's whole custom environment thing it's got going on.
i have a GLAD setup that's just OGL 3.3 without any extensions, OGL 4.5 with no extensions, and OGL 4.5 with literally ALL of the extensions.
that level of customization will never be matched by GLEW. i advise never using it again.
Can you give me a quick description on how to set up GLAD for Visual Studio / C++?
Can't really find anything online except for the generator that needs a ton of parameters...
You get the zip file from the generator, and then add the contents of it to your porject, and then compile
Hans Müller it's pretty easy. Just set the version of opengl you want on the generator site (can't remember the url). Then ignore pretty much everything else. I think the only other options are for extensions, which are an advanced feature of opengl.
After you get your download from the site, it should give you a file index with a couple of source files and a zip file which just contains the source files again.
Put the three source files in your project with the rest of your source and simply #include "glad.h" and you can use opengl as normal.
Glfw should have instructions on how to use GLAD on it's website.
Thank you for your work. I learned something and am better today than yesterday!
That end music crept up on my left shoulder and I actually got scared and flinched. xD help
Better explanations about OpenGL of RUclips! Plz continue with dat great series.
This dude is running OpenGL version 4.4 while I'm over here with 2.1
Well, good thing I'm building my own PC!
you sure thats not GLEW_VERSION? Cuz im running opengl 4.6, but my glew version is 2.1. Either way, good luck on your PC!
I Have OpenGL 1.1 LOL
Great video. - What is your resolution on your laptop? - Even when watching your video at 1080p the text/code still looks blurred.
He says GLEW but it's not really cross platform. You need to download all of the platform specific versions and depending on where you're building the application, you'll need to add in some code to link to the right library.
To *really* go cross platform. use GLAD for modern openGL and CMake for complete project management and building.
Following along, but on Linux and using just Make for compiling, so kind of flying by the seat of my pants. Man is this a pain in the arse to set up. I hope this is the last library linking adventure. xD
Cmake in Linux
target_link_libraries(projectName -lglut -lglfw -lGLEW -lGL -lGLU)
Dude, I spent like three hours trying to make gcc link everything correctly. Wish I saw your comment earlier...
Dude, how did you learn all this stuff? Of course great video, thanks
My anniversary is coming up soon.. ;)
The first day I started watching TheCherno game programming episodes.. August 9, 2014.
These OpenGL videos are just as magical!
Seriously, you make the things with C++ that feel SO complicated feel WAY easier, like it was built for actual humans to use!
Otherwise, I feel lost learning game dev/programming sometimes.. you don't even know what's what. GLEW.. GLFW.. OpenGL.. etc., and how everything fits together.
So First 3 Episodes are just about Setting up Visual Studio for OpenGL
You helped me so much!! many thanks!
How do you know all of this stuff? Did you go to school or simply everything from documentation?
"I'm not even talking about modern ones, I'm just talking about anything newer than like 1997" PLEASE GAHAHA
Looks, good, but it would be nice if the videos would be numbered ;)
Thank you for the quality content!
Hey, The Cherno can you please make a tutorial for DirectX/Direct3D.
PLEASE!
can't find a good tutorial anywhere else and you are the best youtuber that does this kind of stuff
THANK YOU!
Oh man, that comment about linking statically whenever you can surely raised some hackles somewhere, lol.
this guy deserves 2 million subs
I have always wondered, where did you learn c++ and OpenGL? and what resource, other than your videos, is really good for learning this stuff?
Hi! I just discovered your channel, looking for resources for learning OpenGL (currently in College Computer Graphics). I tutor Computer Science and some Math at my campus, and I also employ the learn by example/mistakes and DIY technique. I feel like making the mistakes and then correcting them or problem solving to correct them on the spot creates better programmers.
Anyway, I love this series so far. It's so far, superior to the Lynda tutorial. I'll stick around on this channel. Thanks! =]
"1.0 was kind of a bit weird, we don't talk about that." 1:33
What resources did you learn this from?
Is it just experience or is their a specific book I should check out?
Experience.
i got nervous when i didn't get that linker error lol
For anyone who might getting an unresolved symbol error from the linker, make sure your preprocessor line is written like this "GLEW_STATIC;_MBCS;%(PreprocessorDefinitions)" somehow I got mine messed up when entering the text.
Please make opencl tutorials. Opencl is hard to find tutorials. I want to learn parallel computing as well as cross platform.
It's OpenGL with a G and not with a C
@@WasiMaster open compute language
@ oh I misunderstood
"we don't talk about OpenGL 1.0 around here"
00:00 - Previous Episode
00:23 - Intro
02:18 - How to use "Modern" OpenGL
04:30 - GLEW
09:08 - Setting it up
I kinda rage quitted, so idk
Greatly appreciate for making this video! I just have a small question: when I attempt to compile, I get a warning that "cannot open or find PDB files". How can I solve that?
If I add GLEW and GLFW by source code, should I also shove them in a 'Dependecies' folder? I mean it doesn't really really matter but I want to know how you do it.
I wish more people would talk about development on Linux. I had to do a bit more work. For one I ended up having to use a makefile rather than adding dependencies through the IDE. I also had to do some manual linking sudo ln -s /usr/lib64/libGLEW.so.2.1 /usr/lib/libGLEW.so.2.1 because when I compiled my libraries some of the links were not linked to my /user/lib.
Thats my only complaint other than that great vid.
I have use Netbeans on linux, to do this in the past, it is almost the same, it uses a makefile internally.
I also use g++ and makefile here on windows, it gets painful but you learn a lot. Just google a lot
This is for windows lol.
Yeah what you do is compile glew via `cd glew-2.1.0 && cmake -G "MSYS Makefiles" ./build/cmake && make -j4` which you won't need the -G probably. This will generate a makefile with cmake and then you can either make install or push the bin and lib and include directories into your project build path.
Thank you! This helped!
i feel ya man. Im on mac and using mac but not Xcode can be a bit of a struggle to find resources sometimes. Thank god for homebrew. the other piece I had to add to get mine running was -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo . but got there in the end
@@robertoprince6804 Sure, but when you really want to share code and a project a proper cmake build configuration is worthwhile. That way everyone on the team isn't monkeying about with different IDE settings, you just type make on the CMD/terminal and it makes. No IDE needed.
Well produced video.
What is the name of the Colour Theme you are using for Visual Studio? I want to get it for VS Code in Linux, but could not find anything similar :?
this is hard af idek what else to say
@@abdulwahabjag thx alot bro i actually didn't give up it is just that it was kinda confusing but i kept trying again and again and it worked it is a very happy moment when your code works after trying very hard and thank you again :)
@@abdulwahabjag yes I will gl to you too on what ever you're working on rn I hope u will be successful
Awesome video, I learned a lot, thanks for it :3
BTW What the hell is that outro song? I can't find it anywhere.
Where those marvelous sounds are coming from ? I really need to find them ! Please share us
I absolutely love your videos, please don't stop. If you do you will make about 200,000 people very sad
lol 'We don't talk about that..."
:D I finished the tutorial XD
SOMEONE HELP!
I did everything you did up until 14:10 but I still have the "LNK2019: unresolved external symbol glewInit referenced in function main" error. I defined "GLEW_STATIC" in preprocessor definitions and made sure the configuration was on "all configurations". I do have the platform on x64 however but I don't think that's the problem as I tried it on Win32 and it still didn't work, and in your previous video you said it didn't matter.
Hope someone can help me.
Thanks :)
l am facing the same problem bro
8 months too late but use x64 instead of Win32 when linking glew
Make sure to include glew32s.lib in the additional dependencies. I got stuck for around half an hr on this
Plot twist, they are not both static libraries. One is an import library. (though it seems a bit large for an import library)
My brain melted, I just learned macros yesterday, I am bad at C++, It is literally nerdy looking code. C# is kinda more concise and clean ya know!
yeah cuz c++ is low level and c# is high level
this background music! TA-DAAAAAA !!!
Great stuff. Thank you.
Amazing video thanks a lot !!
Hi chreno,you r the god of the cpp
vcpkg could save all this hardwork of linking manually
Great video! Can you explain in the future what LNK4098 and LNK4099 warnings are? I keep getting them the first time I build something - on subsequent buildings, they just don't show up and everything looks fine
I believe you are referring to a warning that just says you don't have the file used for debugging which for glew you don't. This shouldn't cause any long-term issues and just mean if you debug you cant inspect glew functions. I could be thinking of something else. If you get those, do a cleaan and rebuild of project.
@@learnsoftwareengineering6975 I have got this warning (4098), and once I used glewInit() I got an error saying that it was an unresolved external symbol or something.
if you get "glew32.dll was not found" error you must copy the file glew32.dll from your GLEW/bin folder, and then copy it into your solution's debug folder. :) idk what i did wrong, but i'm assuming it will happen to somebody else
did you ensure that in properties window you were set to all configurations and not just active/debbug/release?
Cherno Thanks for the video series.
Any resource on VTK ?
oh my god. i Leaaaaaaaarned so much . thank you
My macOS supports till OGL 3.3 but It's getting only 2.1. How to force to use the this version?
i used glad does that mean i need to change this series or not ?
i have these error unresolved external symbol glewInit referenced in function main how can i solve it
IDK what compiler/IDE you are using but you have to link the libraries to resolve the errors.
can we have a seris of openGL tutes on linux? Setting it up on linux is uneasy...