@@ -149,13 +149,35 @@ void ShaderObject::updateObjectContent(map<int,shared_ptr<PatchObject>> &patchOb
149149 string fileExtension = ofToUpper (currentScriptFile.getExtension ());
150150 if (fileExtension == " FRAG" ) {
151151 filepath = copyFileToPatchFolder (this ->patchFolderPath ,currentScriptFile.getAbsolutePath ());
152+ string fsName = currentScriptFile.getFileName ();
153+ string vsName = currentScriptFile.getEnclosingDirectory ()+currentScriptFile.getFileName ().substr (0 ,fsName.find_last_of (' .' ))+" .vert" ;
154+ ofFile newVertGLSLFile (vsName);
155+ if (newVertGLSLFile.exists ()){
156+ copyFileToPatchFolder (this ->patchFolderPath ,newVertGLSLFile.getAbsolutePath ());
157+ }else {
158+ ofFile vertToRead (ofToDataPath (" scripts/empty.vert" ));
159+ ofFile patchFolderNewFrag (filepath);
160+ string pf_fsName = patchFolderNewFrag.getFileName ();
161+ string pf_vsName = patchFolderNewFrag.getEnclosingDirectory ()+patchFolderNewFrag.getFileName ().substr (0 ,pf_fsName.find_last_of (' .' ))+" .vert" ;
162+ ofFile::copyFromTo (vertToRead.getAbsolutePath (),pf_vsName,true ,true );
163+ }
152164 loadScript (filepath);
153165 reloading = true ;
154166 }else if (fileExtension == " VERT" ){
167+ string newVertOpened = copyFileToPatchFolder (this ->patchFolderPath ,currentScriptFile.getAbsolutePath ());
155168 string vsName = currentScriptFile.getFileName ();
156169 string fsName = currentScriptFile.getEnclosingDirectory ()+currentScriptFile.getFileName ().substr (0 ,vsName.find_last_of (' .' ))+" .frag" ;
157- filepath = fsName;
158- filepath = copyFileToPatchFolder (this ->patchFolderPath ,filepath);
170+ ofFile newFragGLSLFile (fsName);
171+ if (newFragGLSLFile.exists ()){
172+ filepath = copyFileToPatchFolder (this ->patchFolderPath ,newFragGLSLFile.getAbsolutePath ());
173+ }else {
174+ ofFile fragToRead (ofToDataPath (" scripts/empty.frag" ));
175+ ofFile patchFolderNewVert (newVertOpened);
176+ string pf_vsName = patchFolderNewVert.getFileName ();
177+ string pf_fsName = patchFolderNewVert.getEnclosingDirectory ()+patchFolderNewVert.getFileName ().substr (0 ,pf_vsName.find_last_of (' .' ))+" .frag" ;
178+ ofFile::copyFromTo (fragToRead.getAbsolutePath (),pf_fsName,true ,true );
179+ filepath = pf_fsName;
180+ }
159181 loadScript (filepath);
160182 reloading = true ;
161183 }
@@ -169,6 +191,13 @@ void ShaderObject::updateObjectContent(map<int,shared_ptr<PatchObject>> &patchOb
169191 ofFile newGLSLFile (lastShaderScript);
170192 ofFile::copyFromTo (fileToRead.getAbsolutePath (),checkFileExtension (newGLSLFile.getAbsolutePath (), ofToUpper (newGLSLFile.getExtension ()), " FRAG" ),true ,true );
171193 ofFile correctedFileToRead (checkFileExtension (newGLSLFile.getAbsolutePath (), ofToUpper (newGLSLFile.getExtension ()), " FRAG" ));
194+
195+ ofFile vertToRead (ofToDataPath (" scripts/empty.vert" ));
196+ string fsName = newGLSLFile.getFileName ();
197+ string vsName = newGLSLFile.getEnclosingDirectory ()+newGLSLFile.getFileName ().substr (0 ,fsName.find_last_of (' .' ))+" .vert" ;
198+ ofFile newVertGLSLFile (vsName);
199+ ofFile::copyFromTo (vertToRead.getAbsolutePath (),newVertGLSLFile.getAbsolutePath (),true ,true );
200+
172201 currentScriptFile = correctedFileToRead;
173202 if (currentScriptFile.exists ()){
174203 filepath = currentScriptFile.getAbsolutePath ();
0 commit comments