mirror of https://github.com/snes9xgit/snes9x.git
Win32: fix relative includes for cg shader passes
This commit is contained in:
parent
ae201d0bf5
commit
d81c0a68d3
|
@ -286,8 +286,6 @@ void CD3DCG::checkForCgError(const char *situation)
|
|||
}
|
||||
}
|
||||
|
||||
#define IS_SLASH(x) ((x) == TEXT('\\') || (x) == TEXT('/'))
|
||||
|
||||
bool CD3DCG::LoadShader(const TCHAR *shaderFile)
|
||||
{
|
||||
CCGShader cgShader;
|
||||
|
@ -301,13 +299,8 @@ bool CD3DCG::LoadShader(const TCHAR *shaderFile)
|
|||
if (shaderFile == NULL || *shaderFile==TEXT('\0'))
|
||||
return true;
|
||||
|
||||
lstrcpy(shaderPath,shaderFile);
|
||||
for(int i=lstrlen(shaderPath); i>=0; i--){
|
||||
if(IS_SLASH(shaderPath[i])){
|
||||
shaderPath[i]=TEXT('\0');
|
||||
break;
|
||||
}
|
||||
}
|
||||
lstrcpy(shaderPath, shaderFile);
|
||||
ReduceToPath(shaderPath);
|
||||
|
||||
SetCurrentDirectory(shaderPath);
|
||||
if(!cgShader.LoadShader(_tToChar(shaderFile)))
|
||||
|
@ -345,6 +338,10 @@ bool CD3DCG::LoadShader(const TCHAR *shaderFile)
|
|||
if(!fileContents)
|
||||
return false;
|
||||
|
||||
// individual shader might include files, these should be relative to shader
|
||||
ReduceToPath(tempPath);
|
||||
SetCurrentDirectory(tempPath);
|
||||
|
||||
pass.cgVertexProgram = cgCreateProgram( cgContext, CG_SOURCE, fileContents,
|
||||
vertexProfile, "main_vertex", vertexOptions);
|
||||
|
||||
|
@ -355,6 +352,9 @@ bool CD3DCG::LoadShader(const TCHAR *shaderFile)
|
|||
|
||||
checkForCgError("Compiling fragment program");
|
||||
|
||||
// set path back for next pass
|
||||
SetCurrentDirectory(shaderPath);
|
||||
|
||||
delete [] fileContents;
|
||||
if(!pass.cgVertexProgram || !pass.cgFragmentProgram) {
|
||||
return false;
|
||||
|
|
|
@ -287,8 +287,6 @@ void CGLCG::checkForCgError(const char *situation)
|
|||
}
|
||||
}
|
||||
|
||||
#define IS_SLASH(x) ((x) == TEXT('\\') || (x) == TEXT('/'))
|
||||
|
||||
bool CGLCG::LoadShader(const TCHAR *shaderFile)
|
||||
{
|
||||
CCGShader cgShader;
|
||||
|
@ -314,13 +312,8 @@ bool CGLCG::LoadShader(const TCHAR *shaderFile)
|
|||
if (shaderFile == NULL || *shaderFile==TEXT('\0'))
|
||||
return true;
|
||||
|
||||
lstrcpy(shaderPath,shaderFile);
|
||||
for(int i=lstrlen(shaderPath); i>=0; i--){
|
||||
if(IS_SLASH(shaderPath[i])){
|
||||
shaderPath[i]=TEXT('\0');
|
||||
break;
|
||||
}
|
||||
}
|
||||
lstrcpy(shaderPath, shaderFile);
|
||||
ReduceToPath(shaderPath);
|
||||
|
||||
SetCurrentDirectory(shaderPath);
|
||||
if(!cgShader.LoadShader(_tToChar(shaderFile)))
|
||||
|
@ -357,6 +350,10 @@ bool CGLCG::LoadShader(const TCHAR *shaderFile)
|
|||
if(!fileContents)
|
||||
return false;
|
||||
|
||||
// individual shader might include files, these should be relative to shader
|
||||
ReduceToPath(tempPath);
|
||||
SetCurrentDirectory(tempPath);
|
||||
|
||||
pass.cgVertexProgram = cgCreateProgram( cgContext, CG_SOURCE, fileContents,
|
||||
vertexProfile, "main_vertex", NULL);
|
||||
|
||||
|
@ -367,6 +364,9 @@ bool CGLCG::LoadShader(const TCHAR *shaderFile)
|
|||
|
||||
checkForCgError("Compiling fragment program");
|
||||
|
||||
// set path back for next pass
|
||||
SetCurrentDirectory(shaderPath);
|
||||
|
||||
delete [] fileContents;
|
||||
if(!pass.cgVertexProgram || !pass.cgFragmentProgram) {
|
||||
return false;
|
||||
|
|
|
@ -451,6 +451,16 @@ char *ReadShaderFileContents(const TCHAR *filename)
|
|||
|
||||
}
|
||||
|
||||
void ReduceToPath(TCHAR *filename)
|
||||
{
|
||||
for (int i = lstrlen(filename); i >= 0; i--) {
|
||||
if (IS_SLASH(filename[i])) {
|
||||
filename[i] = TEXT('\0');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: abstract the following functions in some way - only necessary for directdraw
|
||||
|
||||
/* DirectDraw only begin */
|
||||
|
|
|
@ -189,6 +189,8 @@
|
|||
#define IsHiRes(x) ((x.Height > SNES_HEIGHT_EXTENDED || x.Width == 512))
|
||||
#define CurrentScale (IsHiRes(Src) ? GUI.ScaleHiRes : GUI.Scale)
|
||||
|
||||
#define IS_SLASH(x) ((x) == TEXT('\\') || (x) == TEXT('/'))
|
||||
|
||||
void WinRefreshDisplay(void);
|
||||
void S9xSetWinPixelFormat ();
|
||||
void SwitchToGDI();
|
||||
|
@ -209,5 +211,6 @@ void WinSetCustomDisplaySurface(void *screen, int ppl, int width, int height, in
|
|||
template<typename screenPtrType>
|
||||
void WinDisplayStringInBuffer (const char *string, int linesFromBottom, int pixelsFromLeft, bool allowWrap);
|
||||
char *ReadShaderFileContents(const TCHAR *filename);
|
||||
void ReduceToPath(TCHAR *filename);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue