Well, looks like your problem is already solved. But I thought I’d mention my response anyways.
As PixelClear mentioned, your triangles.vert file may be in the wrong directory. Or you don’t have the file.
Another cause could be that you’re trying to run the .exe file you built outside of Visual Studio, which causes differences in path searching. I don’t have VS 2017. I have VS 2015, but I assume that how paths work when running in or outside either version are the same. In VS 2015, you build/run the current project in the solution. It’s also known as the startup project. I guess it’s called “start up” because when you click Debug->Start Debugging or Debug->Start Without Debugging, it starts up the build from your project that you’re interested in running (assuming it’s an .exe. If you’re building a .lib static library or a .dll dynamic library in your startup project, it wouldn’t make sense to run it). I also guess it’s called “start up” because it’s the first project that’s built in a VS solution, which can matter depending on if a project depends on other projects in the same solution.
Anyways, assuming that this is your startup project (you right click on your project and click “Set as Startup Project”), in Windows, when you run your project from Visual Studio, it seems that it runs a command from command prompt relative to your project’s current directory, not where your built .exe file is. So far, what I know is that if a command is run from command prompt like this, the .exe by default searches for files to load (if it needs to) from that directory where the command was run, if you didn’t specify an absolute directory in your program. Interestingly, I don’t even think cmd searches for files in the same directory as the .exe itself (even if you use relative “.” notation in Windows .cpp programs)
So for example, if I had a solution open and my project folder was here:
and my Debug .exe was built here:
If I ran my project from Visual Studio, the command prompt command could look something like this:
C:\Users<My Name>\Desktop\Scripts\learnogl2\modern_ogl\diffuse_cube>C:\Users<My Name>\Desktop\Scripts\learnogl2\Debug\diffuse_cube.exe
or maybe even this, given the directories I put here, if Visual Studio is more for relative directories:
Nonetheless, in either case, given this command, diffuse_cube.exe will look only in my modern_ogl\diffuse_cube folder, and not in its own directory, to look for any relative files if it needs to load them.
The above would all work fine, if I put my extra files in my project folder, but if I only ran my .exe from my its own current directory (either via Windows Explorer or cmd), I’d get an error somewhere if I didn’t move any files to that directory at that time. The cmd command of interest would be:
As a post-note, I remember replying to you in some “Starting OpenGL” post. I checked on some of your past posts (sorry, that sounds a little creepy, was just wondering what you were doing to make your solution), and apparently, you’re using the “OpenGL Programming Guide 9th Edition” book. I think that’s a bit too much too start off with. Are you sure you want to do that? I’ve looked at some sample pages from the 9th edition book in Amazon, and I think it’s pretty advanced for someone starting off, in my opinion.
I think it’s cool to be able to work with the latest versions of OpenGL, but as I’ve posted to you back in the “Starting OpenGL” post, sooner or later you’ll find yourself needing to analyze the specification, regardless of how many books/tutorials are there. And the 4.5 core specification is huge, at 805 pages. (note this even doesn’t count the GLSL) While the 3.3 core spec, the one used by the LearnOpenGL tutorial I mentioned a while back, is at around 425 pages. Still a lot, but more manageable, in my opinion. In my experience, as someone still relatively new to OpenGL and wanting to understand the specification more, having less pages to analyze is a good thing. Less features, but more room to think about how certain functions work. I’m thinking it could be a good idea for you too to just stick to the LearnOpenGL tutorials at 3.3 core and then, when you feel very comfortable with it, use a newer version. 3.3 core and 4.5 core both use shaders, so it’d be a friendly transition.
OpenGL 3.3 core is already powerful as it is. Games-wise, a lot of amazing games in my opinion have already been made before that spec was released in 2010, like Dead Space 2 and Mirror’s Edge (yes, they probably used DirectX instead for PC, but this is just to put it in perspective with OpenGL). I’m not sure if you’re using OpenGL for visualization or games, but if it’s for games, I think 3.3 core can produce some pretty nice results, even with less features than 4.5.
Lastly, as 4.5 is a newer version (4.5 core says it came out this June 2017, 4 months ago), only newer graphics cards support it. Some people on this forum may not be able to run your code if their graphics card can’t support that version. My laptop for example can’t run your code, even if it’s logically correct (you used glNamedBufferStorage in the code you posted, which automatically means a graphics card must support at least 4.5 to work with it). My graphics card can only run to 4.0. I think you’d be able to get more people to try to run your code and maybe even give an answer to your question if you stuck to a lower OpenGL version. And you can reach a wider product audience if you use a lower OpenGL versions, if you’re making a product, as there are probably still a lot of people that can only run lower versions. Again, you’d get less OpenGL functionality, but in my opinion, you can already do a lot with something like 3.3 core, and I think you’ll satisfy a lot of people already, given the graphics you can make with it. But this and my thoughts on released games is more opinionated, just to admit it. I don’t know what you need, graphics-wise, and I don’t know how many people right now can run 4.5/4.6 code.
Anyways, hope that helps. Looks like if you can run your code, you already have 4.5. But if you’re planning to sell your product or something to customers, thought it’d be nice to mention the OpenGL Extensions Viewer here. It’s a Windows app that can check what version of OpenGL you have. Could help if someone using your product has trouble making it work.
By the way, what are you using OpenGL for? Just curious. I wrote some stuff about product audience. I’ve never done something like that before, like to sell it, but since you mentioned your LinkedIn a while back, I’m assuming you’re a programmer, career-wise, and intend to make a product. If it’s just for curiosity’s sake, then well, as a side-note, you’re lucky you have 4.5. I’ll get to upgrade to it one day, haha.