C
C#6mo ago
Louken

✅ How to read from glsl (shader) file

Hi. I am learning OpenTK and trying to make my own game. Im following learnopentk and i am stuck with reading shader files. I have the shader.vert and shader.frag files in my solution explorer, but for some reason, it tries to get the file from some other path. I tried typing in the exact path for where the file is on my computer and that worked, but it wont work on other devices, so i don't know what to do in this case. Any help is appreciated
No description
No description
No description
11 Replies
cap5lut
cap5lut6mo ago
thats not really an glsl/shader issue, its basically about the current working directory and u giving a relative path imagine a simple console app example.exe that tries to read "default.frag" in terminal i can do
cd C:\some\path
C:\path\to\your\executable\example.exe
cd C:\some\path
C:\path\to\your\executable\example.exe
and the application would look for the file C:\some\path\default.frag, if i would do
cd D:\hello\whats\going\on
C:\path\to\your\executable\example.exe
cd D:\hello\whats\going\on
C:\path\to\your\executable\example.exe
the application would look for the file D:\hello\whats\going\on\default.frag
Buddy
Buddy6mo ago
Just because the files exists in solution doesn't mean they are automatically copied. And they won't be embedded.
JenyaRostov
JenyaRostov6mo ago
right click on file in solution -> copy to output folder always
cap5lut
cap5lut6mo ago
in ur case the current working directory would be that <project-root>\bin\x64\Debug\net8.0\ path. and... is it there? did u check in explorer?
Buddy
Buddy6mo ago
The library loads them from disk, not embedded (Resources)
cap5lut
cap5lut6mo ago
the mentioned stuff wouldnt embedd it as resource nor would it try to read it from there
Louken
LoukenOP6mo ago
No the files are in the project folder. I just need to find out how I can make the program look through the project folder and not the other path
cap5lut
cap5lut6mo ago
can u right click the frag and vert shader files, click on properties and check if its actually set to copy to output dir?
Louken
LoukenOP6mo ago
I'll check Yh it was off It worked. Thanks
cap5lut
cap5lut6mo ago
glad we could help o7 if ur questen is answered please mark this thread by $close ing it ohh right, modix is acting up ... use the /close command to mark the thread as answered
Louken
LoukenOP6mo ago
alright
Want results from more Discord servers?
Add your server