Note for anyone following this tutorial in Visual Studio 2022, after making the configuration changes to the include and lib directories, if you still have compiler errors and red squigglies, make sure the active platform is x86 (at the top of the main window, to the left of the "Local Windows Debugger" button, click the dropdown to switch from x64 to x86. Now if you reopen the configuration properties window, you should see the Platform dropdown says "Active(Win32)" and your changes should take effect.
holly cow ! you come straight out of heaven ! I've been litteraly sitting here for 2 hours freaking out and then you show up and just solve the issue with one click
How i downloaded GLFW 3 times: Cherno: "So we need to download GLFW" me: *hits that download button* Cherno: "We could down... blah blah blah... But we're gonna download binaries" me: "Oh" *hits 64 bit binaries for windows download* Cherno: *So we are going to download 32bit binaries, we don't need 64 bit" ... Yeah
I can't believe this guy got me to do anything in opengl without using someone else's build entirely. Getting openGL running is the single biggest obstacle holding back people from learning computer graphics basics.
The thing Cherno gets right compared to other tutorials is that he focuses on teaching the basics first. While that sounds like many other tutorials it's actually not. There's 2 common and IMHO bad teaching methods others do. 1) Teach by example (Give you a block of code spanning several lines, explain some of it, but leave you to figure out the rest to understand the basics.) 2) Teach by building a complex program (Give you a much longer program, explain what each line does without really helping you understand much of it and progressively span several files and thousands of lines teaching you the basics) Both of those are ubiquitously common online and many teachers swear it's the best way to learn. But they're both garbage IMHO, you need to start small and play around with one concept at a time with the most minimal lines of code possible. You want focus on the once concept so you don't want any other distractions with too much other stuff going on including other concepts you also haven't fully understood. Cherno focuses on helping you understand the concept being taught and encourages you to play around with just that one concept to really learn it. I really wish more teachers did this and not try to throw too much in and have too much going on that you just can't figure anything out, become stressed and overwhelmed, feel abandoned, and ultimately quit. With Cherno's method you actually feel like you understand something and feel like you're having fun.
Exactly! As an absolute beginner, I'm constantly feeling overwhelmed by the gap between what's taught in tutorials and the exercises that are recommended (with no follow-up discussion of solutions)
For those using 2019 or newer versions of visual studio make sure that in the properties window you have Win32 set to active instead of x64 which is default
win32? In the project properties? Even if you've downloaded the x64 glfw binary? What if you're trying to create an x64 library/app? If you build glfw from source does it work with x64? I was thinking this morning about why it is that C++ is such an enormous pain to use compared with, say, C#, for example. I don't think it's actually the need to deal with pointers or memory management, or the incredible verbosity that's required to satisfy the type checker, or anything really to do with the language itself. That kind of thing can be a bit troublesome, sure. But I don't think any of that is actually what causes the vast majority of the hair tearing and time loss. I think the thing that causes the vast majority of the hair tearing and time loss with C++ is all about the build environment. It's related to the 500 or so spurious errors you get, associated with the giant mountain of dependencies you have, if one tiny little thing isn't exactly right. With C++, the actual thing which is causing your problem is referenced by a needle in a haystack. And the needle is probably pointing in the wrong direction. Why does that happen with C++ and not with, say, C#, for example? I think the key difference is the need to compile header files. In C#, and in Python, PHP, Ruby, Lua, etc., the manifest of what is in a library is built into the library itself and is known to the compiler (or jitter or interpreter, etc.) at compile time without needing to depend on the success of the compilation of a header. In C++, if something goes wrong with the compilation of one header, all of the headers that depend on that won't compile either, and so the compiler has no idea what's in any of the whole tree of libraries that depend directly or indirectly on that library. I think that by itself is The Thing that causes by far and away the most headaches with C++. What if we came up with a new type of library which doesn't require a header to use? What if our C++ libraries imbedded a complete manifest that is explorable by a tool similar to the C# assembly browser? If we could manage that, then if one or two calls were mismatched in some way, we'd only get errors about those one or two calls, instead of getting a cascade of errors about every call made by any part of the mountain of dependencies to anything in that library or any of the libraries in the whole tree of libraries that depend directly or indirectly on that library! I bet that notion By Itself, with No Other Changes, has the potential to reduce the hair tearing and time loss associated with using C++ by something like 90%. "But what about all the header-only libraries!?" We like them because with them at least we don't get link time errors. And they force full disclosure and don't require us to look in two places in order to know how a given function works / exactly what it does. But think about all the horde of compile time errors you get out of STL when something goes wrong in the header compilation process. Is that really better than getting one link time error? If libraries had complete manifests that were readily explorable, the linking process could be merged with the compilation process. If you had the source code for a library, the compiler/linker could potentially direct you to the line of code that caused what is today a link time error. And in header-less C++, you would never need to look in two places to know how a function works / exactly what it does. Headers have the advantage of showing you a brief manifest that you can use to navigate to the implementation code. But if an IDE could give you a way to see that browse that manifest, and use it to navigate to the implementation code for a given class or member, and even open little sub windows into it the way VS does with "Quick Actions", without needing to manually create or maintain the header itself, wouldn't that be better? Header-less C++. Difficult to come up with, maybe, but I bet it would be worth it in spades.
@@signedlongint69 It's not about hating C++ at all! I like C++ in general, in fact I choose to use it in my own projects. I was just proposing the supposition that header files from external libraries that have to be compiled into your project are more trouble than they're worth and that there is a better solution. I think maybe I need to experiment with C++20's "modules" feature.
Perhaps because they them self forgot how it was they had to learn it. In my home country we have a saying: "The cow has forgotten that they once them self was a calf" Just a thought :P
Because this guy is an industry professional (EA Games) and most others are not. Even a great developer making a tutorial that hasn't been exposed to the formalities and practices of professional software engineering won't have had as much practice. Programming really is a matter of exposure.
RPMedia, I have written computer programs, manuals and fiction, and edited novels for publishing houses, so I've got a little bit of experience in this arena. One of the things you have to be careful with when checking out a novel is that the author isn't too close to the story. Remember: more than anyone who reads the story, the writer lives in its world. Some things may seem so obvious that they're not worth mentioning. That's one of the places where an editor comes in. The same holds true for a tutorial. Sometimes, some tips and tricks are so ingrained into the tutor that they just go without saying. Here is where a reviewer earns his or her (paltry) pay. What Cherno does that makes him so good is to take you right through the process, from a first-person point of view. He's also obviously been doing this for a while, so he knows what he's doing, but, more importantly, since he takes you through the actual process, the problems he has are going to be the problems he has. Also, Cherno just plain has a knack for it. Some do.
Generally spaeaking, people suck at explaining things because they just regurgitate what they have been told and have never internalized the knowledge by meditating on the subject. I see this all the time and it's driving me fucking crazy!
So what exactly did he explain in this video, besides the things every C++ programmer should know already BEFORE getting into OpenGL programming? (or any APIs whatsoever) He didn't explain a single line of the code he used, he just copy-pasted the code from the documentation, added a bunch of other function calls he didn't explain either, and that's pretty much it :P Yeah, I agree with the rest of people in this comment thread: some people just *suck at explaining* :q What's worse, many people suck at noticing it, and they all cheer to the fact that they actually learnt nothing actually useful :P
Just a side note for those on Windows, you don't actually have to go through the process of linking all those libraries at 15:38, you can just type in "%(AdditionalDependencies)" to include all the default libraries for you. No need to Google the errors and link them manually. :)
Thanks Cherno, most C++ tutorials I have found with libraries make me feel like I'm just sort of hacking together something that works, but you have cleared a lot of that fog. Thanks.
Your videos have such a remarkable production quality. You really seem to have an innate sense of how to teach things in a simple and effective way. Thank you so much for your great work!
dude u are a gifted person. its a real inspiration. ur probly a 1 in a million (at least) person. not only being extremely knowledgeable and talented in software development, but being able to help people build their skills. its honestly amazing.
g++ k.cpp -Iincludepath -Llibpath -lglfw3 -lopengl32 -lgdi32 you put your paths after -I and -L as shown above. I for include and L for library. Note that even though it's called libglfw3.a gcc you only need to type -lglfw3 into gcc. This is for the windows 64bit version of glfw. I was stuck on this so hope this helps.
I'd just like to thank you for making the process of setting up opengl so simple, while simultaneously learning extremely important aspects of c++ development.
Yeah, you know I just hit that damn notification bell. You're one of the best teachers I've ever seen. Thank you so incredibly much for providing all of these amazing resources!
All of your videos are insanely good and I'm so excited about this tutorial series. I've bought several recommended C++ and game programming books, but they don't come close to TheCherno's videos in terms of quality. I'm finally going to really learn how to make something using OpenGL. Everything else I've read or watched on the matter has been outdated legacy crap or broken links or just obvious bad practice. Seriously, I have not been this excited about any RU-vid content (or probably anything else, for that matter) for ages. Thank you so much for doing this (FOR FREE) and keep up the excellent work!
Really excited for this series! I have come moderately far with LWJGL (Java with OpenGL), but I'd rather use C++ because it's faster if you know what you're doing. I'm glad I have found you because most tutorials on RU-vid are outdated and/or don't explain things very well.
CAPSLOCK yeah, I know. It's just that my attention span has decreased significantly because of all the modern tech. I own the OpenGL red book though, so if I ever get stuck or something I can read about it.
As a linux user I will never understand how devs on windows have the patience to work through this awful tedious setup process. Always takes me back to when I studied computer science at university. I was a hardcore windows user until then. At the first day we got a tutorial how to connect to our accounts via vpn. There were like ~3 pages of screenshots and "click here / click there" descriptions for windows and on the 4th page were a couple of lines to type into your terminal when you're on linux. When I went home I installed linux on the formerly win7 laptop and never looked back. Anyway: you did a real good job of explaining it all. Respect!
I came to learn OpenGL but I'm so happy you showed us how to fix linking issues. I've done C++ courses and they've never showed us how to debug a linking issue and you made it so clear with the simple Google search.
this is the first time i understand a subject on coding this clearly. you explanations are simple yet they cover a lot. thank you for making this video, i really appreciate it!
I had avoided this series because most tutes spend 15 mins trying to tell me what the difference in a char and an int is or an hour long talk on CALLBACKs. I should have known you would get straight to the point. Look forward to finishing this series and get up to date on what all is happening now with OpenGL. Thanks for all you do and I wish you success in your endeavors.
Nice job man! I had to pause the video a couple of times to keep up, but the reward was an intense feeling of happiness when I saw a simple white triangle appear on screen. I will definitely be checking out all your other tutorials. Take care.
@@blocksofwater4758 No, but when you get library errors like that there are basically only a few possibilities: - the .lib file that you downloaded is corrupt or still zipped or stored in a place where the compiler cannot "see" it. - the compiler is not pointed to the correct files in the project settings In one of the next tutorials I made the mistake of linking both the dynamic and static libraries, and then the project would not work until I placed rhe .dll file in the project folder. Btw, Cherno also has an excellent tutorial on the use of libraries in general. I would recommend you practice by creating a simple library of your own; maybe a simple calculator or some string manipulation functions. In my experience, the trickiest part of programming is not the programming itself, but setting up the toolchain and the compiler. More than once I got so frustrated that I left the whole thing for a while. The subject is a little boring, but it's worth spending some extra time and effort. What also helps is to compile some simple programs from the command line, rather than using the IDE. That will give you a better understanding of what is happening under the hood.
I followed this step by step with Visual Studio 2019 and got it working! This is the most success I've ever had with Visual Studio. It's so big and hard to navigate.
this helped clear up a lot of confusion for me. im looking to make minecraft shaders and, like plugins, there's almost nothing simple to start learning it. except shaders are way harder than plugins.
I've haven't had to do this for many years (since I have been working in Unity and Unreal game engines mostly) and I forgot how annoying it was. I used to do these links all the time without even thinking but I never really even understood exactly what it was all doing. All the extra info you provide along the way in this video was very helpful to me. Thanks.
For those using Eclipse CDT C/C++ IDE on Mac OS X To add include folder to Eclipse 1.) Right Click on your project -> Properties 2.) Navigate to C/C++ General -> Paths and Symbol 3.) At the top change configuration -> [All Configurations] 4.) Under the Languages click on GNU C++ 5.) On the right click on Add i.) Click on workspace if you added the include folder into your project (which you should) ii.) Click on File System if the include folder is located outside the project directory 6.) Click ok 7.) Apply Add static library after CMake and make Part 1 adding the Library 1.) Right Click on your project -> Properties 2.) Navigate to C/C++ General -> Paths and Symbol 3.) At the top change configuration -> [All Configurations] 4.) Click on Libraries 5.) Click on Add 6.) Type in the name of the library WITHOUT 'lib' as a prefix AND '.a' as a suffix. Example if the lib is called 'libglfw3.a' type glfw3. Part 2 linking the library's location 1.) Right Click on your project -> Properties 2.) Navigate to C/C++ General -> Paths and Symbol 3.) At the top change configuration -> [All Configurations] 4.) Click on Library Paths 5.) On the right click on Add i.) Click on workspace if you added libglfw3.a into your project (which you should) ii.) Click on File System if the location of libglfw3.a is located outside the project directory 6.) Click ok 7.) Apply Add OS X frameworks 1.) Right Click on your project -> Properties 2.) Navigate to C/C++ Build -> Settings 3.) At the top change configuration -> [All Configurations] 4.) Navigate to MacOS X C++ Linker -> Miscellaneous 5.) In the Linker Flags text field add -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo 6.) Apply
I'm following this video series but using Linux, which makes it a bit challenging. But I found that ChatGPT has been very useful to find out how to link the libraries and generally make the triangle appear. I just prompted "how do I draw a triangle with glfw in opengl in C++ under linux" and it gave me what to write (which is the same Yan is describing in the video), and which parameters to use on the compiler.
I'm on Linux and using clang++ and Make, so far removed from the Visual Studio configuration environment on Windows, but you totally demystified linker errors for me with your "welp, let's look for the missing library" approach... I got it up and running in a few minutes as soon as I saw you breeze through those linker errors by just asking, "what library has this function?". Thank you for all you do, Cherno! :)
Thank you, thank you, thank you! You are a godsend! I'm trying to get GLFW to work with VS Code, but the tutorials out there right now are few, far between, and often outdated. I was able to use this video to transfer the linking over into VS Code, and after 2 days of struggling with this, it's finally working! Thank you so much
Thank you Cherno for making this tutorial i look forward to learning OpenGL. Although i honestly would have preferred if you just made a tutorial for linux users on how to install and set up GLFW because i spend several hours trying to figure out how it even works or how to build and install it. Thankfully i used ChatGPT to help me and solve the problems and got the window and triangle to render on screen. Anyway looking forward to the rest of the series. Hopefully nothing else breaks along the way. lol
Really good video! You are the best teacher! I have Webgl in university but was curious to try Opengl, also, these were my first lines of c++ code, thank you!
On mac : 2 Ways **************** To build the GLFW library from source, only a few steps are required: Download and extract the GLFW source code. Open the Terminal. cd to the extracted directory. Type in cmake . hit return. A Makefile will be created for you. Type in make, hit return. After the compilation process, type in sudo make install. The libraries will be copied to /usr/local/lib/, the header files to /usr/local/include/. Note: You'll need a compiler suite installed to build software, this would usually be the XCode Command Line Tools package. For this, install and launch XCode from the Store or download the tools from the developer site. **************** Now if you're comfortable at the command line: brew install glfw when compiling with openGL and glfw, use "g++ main.cpp -lglfw" for the most minimalistic build if you don't have brew google is your best friend
just gotta say, thank you so much for doing all theese tutorials :) I found your channel just a few months ago and i have learned more about C++ than i would ever have otherwise.
its really good to create something from scratch, i learned from it, and i need to do it every time i create something, until and unless i master it .. good stuff
Welp, it took me 2 hours to setup a c++ hello world in visual studio following the official microsoft doc (would've taken 10 minutes in a folder with clang let's be real). It then took me 20 minutes to display a triangle in opengl following this tutorial. Thanks you.
You should make a tutorial about OpenGL Particle Systems :) They're so fun and satisfying to watch, and there's not really any good tutorials about it on RU-vid :) P.S Big fan, love your videos.
I get this warning: LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library. Any ideas how to resolve this? Anyone???
On Linux you don't actually have to compile. Almost every Linux distribution allows to install glfw for development use with a command as simple as apt install glfw-dev or pacman -S glfw. Don't know about Mac though.
lel, good point. I tried that first with just apt-get install glfw didn't work so was like fuck it got cmake and then used make to compile glfw, that was fucking cool to watch :D
Note for people having issues with linking. In my Visual Studio 2019 $(SolutionDir) didn't actually point to to the project directory. Replacing this macro with $(ProjectDir) resolved this issue.
when i saw the video length i thought this guy was gonna drag on forever about meaningless stuff, but no! i learnt alot from all the explanations and it was paced very well!
Me: "damn why i am getting so many linking errors", After spending 2 hours to resolve all errors Cherno: "You don't need to do that...i just wanna show you how it works" 🤯🤯🤯🤯🤯😢
If linking doesn't work and visual studio isn't recognizing your header files (AKA: you're still getting squiggly lines) try adding "yourProjectName\" before decencies. To make sure it works under properties click on edit and then paste that long directory under evaluated values into your file explorer.
My teacher: Took 6h to explain to the whole class how to draw a triangle in about 500 lines of code. (Minimal code he said) The Cherno: Draw that same triangle in only 43 lines.
Dude I feel like I was just taught how to crack a code. I never knew that about the whole Output errors thing. It was like a slap in the face lol Edit: Fixed typo Edit: :D I DREW A FLIPPING TRIANGLE :D:D:D:D:D:D:D:D
You should still be able to follow along. In order to use OpenGL with C#, you need OpenGL bindings for C#. Same can be said for GLFW, but for GLFW you need the binaries and the bindings for C#. C++ and C# are very similar, so you should be able to follow along no problem.
At around 9:18 you said you’d provide a link to a video about static libraries or whatever. Just thought you could use a notification. Just finding out about your series. Love your work dude!
For anyone struggling with making the configuration changes on the include, lib directories and getting errors. I tried some solutions on the comments but they didn't work and I checked what does the $(SolutionDir) macro represent. And I figured out that there is another file that holds the project files in it. So, instead of "$(SolutionDir)\Dependencies\GLFW\include" try "$(SolutionDir)\\Dependencies\GLFW\include" (make this for linker also).
Everything compiles and links but I am f getting: Unhandled exception at 0x00FA7F50 in OpenGL VS.exe: 0xC0000005: Access violation reading location 0x00000280. does anyone know why?
This is like the 7th time I watched this video. I also want do change to c++ but in the end I stuck with Java most of the time. Thankfully this Video/Series is just perfect