Pregunta

I'm at the point now where I'm ready to dive into shaders, though I've been using a module based system as my means for learning how to do graphics programming (which I've written).

Since I'm working with D3D, I'd like to just make a shaders directory in my project root, store shaders there, and access them quickly.

There are obviously multiple ways to do this, but I don't have a very clear idea of obtaining my project's root directory. Is there a predefined macro for this - or a function of some sort for accessing a project's root folder?

¿Fue útil?

Solución

Most languages have a method to get the application path, but most will wrap the GetModuleFileName() function, passing a null module handle. You can then strip the executable name from the resulting path to get the base folder.

See this question for an extensive list of methods.

Otros consejos

DWORD WINAPI [GetCurrentDirectory][1](
  __in   DWORD nBufferLength,
  __out  LPTSTR lpBuffer
);

Retrieves the current directory for the current process.

I believe this is the function you are looking for. You then append the subdirectory path that the shaders are located in respect to the full path returned that is where your program was executed from.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top