opengl-tutorials/ogl

Cannot run tutorial 2 code in Playground

Closed this issue ยท 17 comments

I copied code from tutorial02.cpp to playground.cpp and shaders dir under playground dir.

However, I got

Impossible to open SimpleVertextShader.vertexshader. Are you in the right directory? Don't forget to read the FAQ!

I am using Windows.

You should copy the shader to the playground folder as well, that means both SimpleVertexShader.vertexshader and SimpleFragmentShader.fragmentshader.

got it! I will fix that and update with new translation!

Still have this issue.
I'm using windows 10 and VS2017.

Seems no one has run into this issue...
I've been searching the Internet for a while and cannot find a solution.

For people stumbing on this later :
The .exe must be started from the SOURCE folder, so that it can find the required files ! (shaders, textures, models)
This is thorougly explained in the FAQ.
Either :

  • Copy-paste the .exe from the build dir to the source dir, and start it (the CMakeList already does this)
  • Copy-paste the resources in the build dir
  • cd in the source dir, but start ../../your_build_dir/tutorialXX.exe
  • Or just start it from the IDE, it's been configured to Just Work !

Hey, I had the same issue and just got it working for me. I think the main issue was fighting with visual studio more than the actual code. I was attempting to follow along with the other code inside the 'playground' and got stuck here for quite a while.

The problem I ran into was that visual studio doesn't copy files that you make inside of it into the working directory. If you make a 'shaders' filter and then add two files inside of it these files won't be exported into the working directory so when you try to open them using your program they don't exsist.

I did the following to keep up with the tutorials. I'm not sure if this is really a best practice or anything, but it worked for me.

  1. Copy the two shaders from the file '.../ogl-master/tutorial02_red_triangle'
  2. Paste them into '.../ogl-master/playground'
  3. In Visual Studio Make a 'shaders' filter inside the 'playground' project
  4. Drag the two filters from the 'playground' folder into the 'shaders' filter.

I have this issue too. I'm using clion.

I just moved the SimpleFragmentShader.fragmentshader and the SimpleVertexSahder.vertexShader to the cmake-build-debug dir.
(Btw. im using Clion + Windows 10)

Hello, I keep running into the same issue even though I copy paste the Tutorial_02 code, the SimpleVertexShader.vertexshader and SimpleFragmentShader.fragmentshader into the Playground folder. Even with the code that's on the Tutorial_02 unedited folder, it keeps saying "Impossible to open SimpleVertexShader.vertexshader. Are you in the right directory?"
I'm using Xcode on a 2011 Mac.

when using xcode it doesnt create the shader file inside the playground directory by default, you need to specify when you create the shader file that it will be inside the playground directory.

Hey, I had the same issue and just got it working for me. I think the main issue was fighting with visual studio more than the actual code. I was attempting to follow along with the other code inside the 'playground' and got stuck here for quite a while.

The problem I ran into was that visual studio doesn't copy files that you make inside of it into the working directory. If you make a 'shaders' filter and then add two files inside of it these files won't be exported into the working directory so when you try to open them using your program they don't exsist.

I did the following to keep up with the tutorials. I'm not sure if this is really a best practice or anything, but it worked for me.

  1. Copy the two shaders from the file '.../ogl-master/tutorial02_red_triangle'
  2. Paste them into '.../ogl-master/playground'
  3. In Visual Studio Make a 'shaders' filter inside the 'playground' project
  4. Drag the two filters from the 'playground' folder into the 'shaders' filter.

Only your answer works for me. Thanks. Hope others get here via google see this.

Hey, I had the same issue and just got it working for me. I think the main issue was fighting with visual studio more than the actual code. I was attempting to follow along with the other code inside the 'playground' and got stuck here for quite a while.

The problem I ran into was that visual studio doesn't copy files that you make inside of it into the working directory. If you make a 'shaders' filter and then add two files inside of it these files won't be exported into the working directory so when you try to open them using your program they don't exsist.

I did the following to keep up with the tutorials. I'm not sure if this is really a best practice or anything, but it worked for me.

1. Copy the two shaders from the file '.../ogl-master/tutorial02_red_triangle'

2. Paste them into '.../ogl-master/playground'

3. In Visual Studio Make a 'shaders' filter inside the 'playground' project

4. Drag the two filters from the 'playground' folder into the 'shaders' filter.

This worked for me thanks! For people in the future, on line 4, "filters" should be "files". Drag the two shader files you copied into the playground folder into the shaders filter in Visual Studio.

Hey, I had the same issue and just got it working for me. I think the main issue was fighting with visual studio more than the actual code. I was attempting to follow along with the other code inside the 'playground' and got stuck here for quite a while.

The problem I ran into was that visual studio doesn't copy files that you make inside of it into the working directory. If you make a 'shaders' filter and then add two files inside of it these files won't be exported into the working directory so when you try to open them using your program they don't exsist.

I did the following to keep up with the tutorials. I'm not sure if this is really a best practice or anything, but it worked for me.

  1. Copy the two shaders from the file '.../ogl-master/tutorial02_red_triangle'
  2. Paste them into '.../ogl-master/playground'
  3. In Visual Studio Make a 'shaders' filter inside the 'playground' project
  4. Drag the two filters from the 'playground' folder into the 'shaders' filter.

Yep, this is totally working fine with me! I keep feeling stupid when I thought filters as folders..

Hey! have windows 10 and visual studio 19. I did everithing as @RobertAron said and itdi change a bit but its still not working. I got this in comand window

slika

slika

In CLion, change the run/debug configuration : Set at working directory the playground directory path.
image

In CLion, change the run/debug configuration : Set at working directory the playground directory path.

thank you!

Using absolute paths worked for me: Right click 'File Inspector' -> 'Relative to Project' -> Location 'Absolute Path'

But this not a good solution. Why will relative path not work? All flies are inside the project I am running i.e. playground/shaders/SimpleVertexShader.vertexshader.