Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: RenderMonkey inspired GLSL editor for linux?

  1. #11
    Junior Member Newbie
    Join Date
    Jun 2011
    Location
    Sweden
    Posts
    18

    Re: RenderMonkey inspired GLSL editor for linux?

    I have noticed some need for an application such as the post title suggests, and I lean towards making an effort.
    Maybe there are more channels I can use to investigate the interest?

    In the fall I will do my masters thesis and I will investigate if there are any companies where I live which would be interested in such an application. Of course, most of them should already have in-house tools, but anyway.

    I appreciate all feedback I can get!

  2. #12
    Junior Member Regular Contributor
    Join Date
    Jan 2011
    Location
    Paris, France
    Posts
    230

    Re: RenderMonkey inspired GLSL editor for linux?

    Yes, file modifications are detected with dnotify ...

    Code :
    #define _GNU_SOURCE
    #include <fcntl.h>
    #include <sys/stat.h>
    #include <stdio.h>
    #include <errno.h>
    #include <signal.h>
    #include <stdlib.h>
    #include <string.h>
     
     
    int	fd=0;
    char   *dir=NULL;
    char   *slashPtr=NULL;
     
    struct	stat statBuf;
    struct	sigaction action;
     
    int  	directorychanged=0;
    char 	splitFilename[128];
    char 	filechecked[127];
    time_t	modifiedTime;
     
    int 	isrunning=0;  
    int	filechanged=0;
     
     
    void EventHandlerFunc( int sig )
    {
    	// printf("This is the event Handler when the ./ directory is modified \n" /* , filechecked */ );
    	directorychanged = 1;
    }
     
    void DelayedActionToFileChange()
    {
    	printf("Delayed action after a modification to %s \n", filechecked);
    	filechanged = 0;
    }
     
     
    int InitDetectChange( int argc, char *argv[] )
    {
    	/* Find directory the file is in, or assume the current directory */
    	strncpy( splitFilename, argv[1], 127 );
    	strncpy( filechecked, argv[1], 127 );
    	if( (slashPtr = rindex( splitFilename, '/' )) == NULL ) 
    	{
    		dir = ".";
    	} 
    	else 
    	{
    		*slashPtr = 0;
    		dir = splitFilename;
    	}
     
    	/* Set up the signal handler */
    	action.sa_handler = EventHandlerFunc;
    	sigemptyset( &amp;action.sa_mask );
    	action.sa_flags = SA_RESTART;
    	sigaction( SIGRTMIN, &amp;action, NULL );
     
    	/* Open the directory the file is in */
    	if( (fd = open( dir, O_RDONLY )) < 0 ) 
    	{
    		printf( "Cannot open %s for reading : %s\n", dir, strerror(errno) );
    		exit( -1 );
    	}
     
    	/* Choose the signal I want to receive when the directory content changes */
    	if( fcntl( fd, F_SETSIG, SIGRTMIN) < 0 ) 
    	{
    		printf( "Cannot set signal : %s\n", strerror(errno) );
    		exit( -1 );
    	}
     
    	/* Ask for notification when a modification is made in the directory */
    	if( fcntl( fd, F_NOTIFY, DN_MODIFY|DN_MULTISHOT ) < 0 ) 
    	{
    		printf( "Cannot fcntl %s : %s\n", dir, strerror(errno) );
    		exit( -1 );
    	}
     
    	if( lstat( filechecked, &amp;statBuf ) < 0 ) 
    	{
    		printf( "Cannot lstat %s : %s\n", filechecked, strerror(errno) );	
    		exit( -1 );
    	}
     	modifiedTime = statBuf.st_mtime;
     
    	return fd;
    }
     
     
    int DetectChange(char *filename)
    {
    	if( lstat( filename, &amp;statBuf ) < 0 ) 
    	{
    		printf( "Cannot lstat %s : %s\n", filename, strerror(errno) );	
    		exit( -1 );
    	}
     
    	// If the modification time has changed, the file has been altered
    	if( modifiedTime != statBuf.st_mtime ) 
    	{
    		directorychanged = 1;
    		filechanged = 1;
    		modifiedTime = statBuf.st_mtime;
    		// printf( "File %s has really been modified since the lastest call\n", filename );
     
    	}else{
    		// directorychanged = 0;
    		filechanged = 0;		
    		// printf( "File %s hasn\'t been modified since the later call\n", filename );
    	}
     
    	return filechanged;
    }
     
    void PrintUsage(int argc, char **argv)
    {
    	if( argc != 2 ) 
    	{
    		printf( "Usage: %s filename", argv[0] );
    		exit( -1 );
    	}
     
    	if( lstat( argv[1], &amp;statBuf ) < 0 ) 
    	{
    		printf( "Cannot lstat %s : %s\n", argv[1], strerror(errno) );
    		exit( -1 );
    	}
     
    	if( ! S_ISREG( statBuf.st_mode ) ) 
    	{
    		printf( "%s is not a regular file\n", argv[1] );
    		exit( -1 );
    	}
    }
     
     
    int main( int argc, char *argv[] )
    {
     
    	PrintUsage(argc, argv);
     
    	isrunning = InitDetectChange(argc, argv);
     
    	while( isrunning ) 
    	{
    		/* This demo has nothing to do, so just wait for a signal */
    		sleep(10);
     
    		/* Check the flag which indicates the right signal has been received */
    		if( directorychanged ) 
    		{
    			if( DetectChange(argv[1]) )
    			{
    				sleep(1);
    				DelayedActionToFileChange();
    			}
    		}
    	}
     
    	return 0;	
    }

    But this use lstat( filechecked, &amp;statBuf ) vs modifiedTime too
    => if necessary the dnotify part can to be canceled ...
    (but perhaps with a %CPU increase because it limit really the number of calls to the DetectChange() func ...)

    This is not OpenGL code, this produce only a little executable that detect when the file in argument is modified.

    I think to use separates (but linked) tasks for

    1) edition of shaders

    2) detection of changes in a vertex/fragment shader file

    3) [re]compilation of shaders [that are changed]

    4) execution of a OpenGL task that show edited shaders in action

    The previous code can already be used for to implement the part 2) and the part 3) is't too difficult to make

    But Ok, if the part 4) can certainly to be make without too difficulties, I think that the really hard task is to make the editor ...


    @+
    Yannoo

  3. #13
    Junior Member Newbie
    Join Date
    Feb 2011
    Posts
    20

    Re: RenderMonkey inspired GLSL editor for linux?

    Put your code in git repo (or any other dvcs), under FLOS license and there will be folk who will help.

  4. #14
    Junior Member Newbie
    Join Date
    Jun 2011
    Location
    Sweden
    Posts
    18

    Re: RenderMonkey inspired GLSL editor for linux?

    This thread has been viewed quite many times now, but the comments are sparse.

    Please post your thoughts if you have any. It would be great with lots of opinions (written) about the idea. Pros, cons, decisions to make, hurdles to overcome, usefulness etcetera.

    In the next month (or two) I will decide if I'm willing to go 100% on this or not.

  5. #15
    Junior Member Newbie
    Join Date
    Jun 2011
    Location
    Sweden
    Posts
    18

    Re: RenderMonkey inspired GLSL editor for linux?

    A lot of readers but no feedback.
    Maybe the post title is misleading.
    Anyway, I take it the lack of response is a sign of little interest in the idea so will not proceed further at this point.
    Maybe the software already out there is good enough and evolving.

  6. #16
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: RenderMonkey inspired GLSL editor for linux?

    Well it is interesting but I can not access your original post ?
    Did you add your tool to the opengl wiki, to increase its visibility ?
    For example here :
    http://www.opengl.org/wiki/Category:...ading_Language

    And submit it to the front page of OpenGL.org

  7. #17
    Junior Member Newbie
    Join Date
    Jun 2011
    Location
    Sweden
    Posts
    18

    Re: RenderMonkey inspired GLSL editor for linux?

    Sorry for late reply.
    I never started development of that tool. The interest seemed a bit low.

  8. #18
    Member Regular Contributor
    Join Date
    Oct 2010
    Location
    France
    Posts
    466

    Re: RenderMonkey inspired GLSL editor for linux?

    It takes you 3 months each time to answer any of the replies here. Of course interrest is low under this condition.

    PS: I know you, like many others, are certainly a lot busy, but you can't do prospection and think it can live alone. Prospection is almost a full-time job.

    Regards.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •