Program* build_Program( const char* name, int n_shaders, Shader* shaders[], int n_attribs, const char* attribs[], int n_uniforms, const char* uniforms[]) { GLuint id = glCreateProgram(); if( !id ) return NULL; pointer pgmbuf = malloc( sizeof(Program) + strlen(name)+1 + n_shaders*sizeof(Shader*) ); Program* pgm = pgmbuf; pgm->id = id; pgm->name = pgmbuf + sizeof(Program); strcpy( (char*)pgm->name, name ); // Build pgm->n_shaders = n_shaders; pgm->shaders = pgmbuf + sizeof(Program) + strlen(name) + 1; pgm->log = NULL; for( int i=0; i<n_shaders; i++ ) { glAttachShader( id, shaders[i]->id ); check_GL_error; pgm->shaders[i] = shaders[i]; } for( int i=0; i<n_attribs; i++ ) glBindAttribLocation( id, i, attribs[i] ); check_GL_error; glLinkProgram( id ); check_GL_error; // Get the results GLint built; glGetProgramiv( id, GL_LINK_STATUS, &built ); check_GL_error; pgm->built = GL_TRUE == built ? true : false; // Get the log fetchLog( pgm ); // Build the attribute and uniform metadata if( GL_TRUE == built ) { pgm->attribs = get_active_attribs( pgm, n_attribs, attribs ); pgm->uniforms = get_active_uniforms( pgm, n_uniforms, uniforms ); } else { debug( "failed to link program '%s':", pgm->name ); dumpLog( pgm->log, "\t" ); } return pgm; }
bool validate_Program( Program* pgm ) { glValidateProgram(pgm->id); check_GL_error; GLint status; glGetProgramiv( pgm->id, GL_VALIDATE_STATUS, &status ); check_GL_error; fetchLog( pgm ); return GL_TRUE == status; }
void RLogMill::run() { logmill_thread_state = LOGMILL_STATE_FETCHING; #if defined(HAVE_PTHREAD) && !defined(_WIN32) sigset_t mask; sigemptyset(&mask); // unblock SIGINT so user can cancel // NOTE: assumes SDL is using pthreads sigaddset(&mask, SIGINT); pthread_sigmask(SIG_UNBLOCK, &mask, 0); #endif std::string log_format = gGourceSettings.log_format; try { clog = fetchLog(log_format); } catch(SeekLogException& exception) { error = "unable to read log file"; } catch(SDLAppException& exception) { error = exception.what(); } if(!clog && error.empty()) { if(SDLAppDirExists(logfile)) { if(!log_format.empty()) { error = "failed to generate log file"; #ifdef _WIN32 // no error - should trigger help message } else if(gGourceSettings.default_path && boost::filesystem::exists("./gource.exe")) { error = ""; #endif } else { error = "directory not supported"; } } else { error = "unsupported log format (you may need to regenerate your log file)"; } } logmill_thread_state = clog ? LOGMILL_STATE_SUCCESS : LOGMILL_STATE_FAILURE; }
void RLogMill::run() { logmill_thread_state = LOGMILL_STATE_FETCHING; #if defined(HAVE_PTHREAD) && !defined(_WIN32) sigset_t mask; sigemptyset(&mask); // unblock SIGINT so user can cancel // NOTE: assumes SDL is using pthreads sigaddset(&mask, SIGINT); pthread_sigmask(SIG_UNBLOCK, &mask, 0); #endif std::string log_format = gGourceSettings.log_format; try { clog = fetchLog(log_format); // find first commit after start_timestamp if specified if(clog != 0 && gGourceSettings.start_timestamp != 0) { RCommit commit; while(!gGourceSettings.shutdown && !clog->isFinished()) { if(clog->nextCommit(commit) && commit.timestamp >= gGourceSettings.start_timestamp) { clog->bufferCommit(commit); break; } } } } catch(SeekLogException& exception) { error = "unable to read log file"; } catch(SDLAppException& exception) { error = exception.what(); } if(!clog && error.empty()) { if(boost::filesystem::is_directory(logfile)) { if(!log_format.empty()) { if(gGourceSettings.start_timestamp || gGourceSettings.stop_timestamp) { error = "failed to generate log file for the specified time period"; } else { error = "failed to generate log file"; } #ifdef _WIN32 // no error - should trigger help message } else if(gGourceSettings.default_path && boost::filesystem::exists("./gource.exe")) { error = ""; #endif } else { error = "directory not supported"; } } else { error = "unsupported log format (you may need to regenerate your log file)"; } } logmill_thread_state = clog ? LOGMILL_STATE_SUCCESS : LOGMILL_STATE_FAILURE; }