示例#1
0
void System<DataType,Integrator,Potential,Communicator>::simulate(int numIters, std::ostream & output) {
	// MPI Comms. //
	clearBuffers() ;
	appendTransitionsToBuffers() ;
	appendInteractionsToBuffers() ;
	communicateInteractionsTransitions() ;
	// Initialise the forces. //
	updateForces() ;
	// Prime the velocity based on the integration policy. //
	for (unsigned int i = 0 ; i < positions.size() ; i+=2) {
		Integrator::initialise(&positions[i], &velocities[i], &forces[i]) ;
	}
	// Update velocities and positions based on the integration policy. //
	for (int i = 0; i < numIters ; ++i) {
		updateVelocities() ;
		updatePositions() ;
		// MPI Comms. 
		clearBuffers() ;
		appendTransitionsToBuffers() ;
		appendInteractionsToBuffers() ;
		communicateInteractionsTransitions() ;
		updateForces() ;
		printSystem(output,i) ;
		output << std::endl << std::endl ;
	}
}		/* -----  end of member function simulate  ----- */
示例#2
0
//+------------------------------------------------------------------+
//| Деструктор
//+------------------------------------------------------------------+
CScene::~CScene()
{
   if(m_ball.program)
      glDeleteProgram(m_ball.program);

   if(m_cube.program)
      glDeleteProgram(m_cube.program);

   if(m_plane.program)
      glDeleteProgram(m_plane.program);

   clearBuffers(m_ball);
   clearBuffers(m_plane);

    if(m_ball.texture)
       glDeleteTextures(1, &m_ball.texture);

    if(m_cube.cube_map)
       glDeleteTextures(1, &m_cube.cube_map);

   if(m_shadow_texture)
      glDeleteTextures(1, &m_shadow_texture);

    glfwTerminate();
}
示例#3
0
void Serial::begin(int baudRate, SerialConfig config)
{
    disableInterrupt(UART_IRQn);

    LPC_SYSCON->SYSAHBCLKCTRL |= 1 << 12; // Enable UART clock
    LPC_SYSCON->UARTCLKDIV = 1;           // divided by 1

    LPC_UART->LCR = 0x80 | config;

    unsigned int val = SystemCoreClock * LPC_SYSCON->SYSAHBCLKDIV /
        LPC_SYSCON->UARTCLKDIV / 16 / baudRate;

    LPC_UART->DLM  = val / 256;
    LPC_UART->DLL  = val % 256;

    LPC_UART->LCR = (int) config;  // Configure data bits, parity, stop bits
    LPC_UART->FCR = 0x07;          // Enable and reset TX and RX FIFO.
    LPC_UART->MCR = 0;             // Disable modem controls (DTR, DSR, RTS, CTS)
    LPC_UART->IER |= UART_IE_RBR;  // Enable RX/TX interrupts

    // Ensure a clean start, no data in either TX or RX FIFO
    flush();
    clearBuffers();

    // Drop data from the RX FIFO
    while (LPC_UART->LSR & LSR_RDR)
        val = LPC_UART->RBR;

    enableInterrupt(UART_IRQn);
}
void YSE::CHANNEL::implementationObject::dsp() {
  // if no sounds or other channels are linked, we skip this channel
  if (children.empty() && sounds.empty()) return;

  // clear channel buffer
  clearBuffers();

  // calculate child channels if there are any
  for (auto i = children.begin(); i != children.end(); ++i) {
    INTERNAL::Global().addFastJob(*i);
  }

  // calculate sounds in this channel
  for (auto i = sounds.begin(); i != sounds.end(); ++i) {
    if ((*i)->dsp()) {
      (*i)->toChannels();
    }
  }

  REVERB::Manager().process(this);

  if (INTERNAL::UnderWaterEffect().channel() == this) {
    INTERNAL::UnderWaterEffect().apply(out);
  }
}
HeadlessView::~HeadlessView() {
    activate();
    clearBuffers();
    deactivate();

    destroyContext();
}
示例#6
0
bool DysonCompressor::set()
{
    QMutexLocker locker(&mutex);

    const bool newEnabled = sets().getBool("Compressor");

    peakpercent = sets().getInt("Compressor/PeakPercent");
    releasetime = sets().getDouble("Compressor/ReleaseTime");

    // Compression ratio for fast gain. This will determine how
    // much the audio is made more dense. 0.5 is equiv to 2:1
    // compression. 1.0 is equiv to inf:1 compression.
    fastgaincompressionratio = sets().getDouble("Compressor/FastGainCompressionRatio");

    // Overall ompression ratio.
    compressionratio = sets().getDouble("Compressor/OverallCompressionRatio");

    if (newEnabled != enabled)
    {
        enabled = newEnabled;
        clearBuffers();
    }

    return true;
}
/**
 * This is the main paint routine. It must be called by the viewer holding the reference to this canvas (e.g. when a 
 * window must be redrawn).
 *
 * @param content The elements to render.
 */
void CGenericCanvas::render(TGCRenderContent content)
{
  // No display if the canvas is currently being updated.
  if (!updating())
  {
    beginUpdate();
    try
    {
      if ((FStates & GC_STATE_PENDING_ACTIVATION) != 0)
      {
        // A pending activation state always means there is a valid current view.
        FStates &= ~GC_STATE_PENDING_ACTIVATION;
        FCurrentView->activate();
      };

      if (FCurrentView != NULL)
      {
        FCurrentView->validate();
        clearBuffers();
        FCurrentView->render(content);
      };
      endUpdate();
    }
    catch(...)
    {
      endUpdate();
      throw;
    };

    checkError();
  };
}
示例#8
0
void PinDialog::getPassword (char* text)
{
    STRCPY (text, LOCAL_PASSWORD_SIZE, (char *) password);
    clearBuffers ();
    /*
       if (FALSE == ui->checkBox_PasswordMatrix->isChecked()) { STRCPY (&text[1],LOCAL_PASSWORD_SIZE-1,ui->lineEdit->text().toLatin1()); } else {
       STRCPY (text,LOCAL_PASSWORD_SIZE,(char*)password); } */
}
示例#9
0
bool DysonCompressor::setAudioParameters(uchar chn, uint srate)
{
    QMutexLocker locker(&mutex);
    channels = chn;
    sampleRate = srate;
    clearBuffers();
    return true;
}
task main()
{
  checkBTLinkConnected();
  cCmdBTPurgeRcvBuffer();

  purgeBT(mailbox1);
  clearSendMessage();
  while(true) {
  	clearBuffers();
    readAndSend(mailbox1, mailbox11);
  	if(dataReceived[1]==1) {
  		send2=true;
  		PlaySound(soundFastUpwardTones);
  	}
    clearBuffers();
  }
}
bool
GraspTester::resetPlanner()
{
    if (!EGPlanner::resetPlanner()) {
        return false;
    }
    clearBuffers();
    return true;
}
示例#12
0
void isoDriver::pauseEnable_CH2(bool enabled){
    paused_CH2 = enabled;

    if(!properlyPaused()){
        delay = 0;
        if (autoGainEnabled) autoGain();
        //window = windowAtPause;
    }

    if(!enabled) clearBuffers(0,1,0);
}
示例#13
0
void isoDriver::pauseEnable_multimeter(bool enabled){
    paused_multimeter = enabled;

    if(!properlyPaused()) {
        delay = 0;
        //window = windowAtPause;
    }

    if(!enabled) clearBuffers(1,0,0);
    qDebug() << "pauseEnable_multimeter" << enabled;
}
示例#14
0
void isoDriver::pauseEnable_CH1(bool enabled){
    paused_CH1 = enabled;

    if(!properlyPaused()) {
        delay = 0;
        if (autoGainEnabled) autoGain();
        //window = windowAtPause;
    }

    if(!enabled) clearBuffers(1,0,1);
    qDebug() << "pauseEnable_CH1" << enabled;
}
示例#15
0
bool Equalizer::setAudioParameters( uchar chn, uint srate )
{
	hasParameters = chn && srate;
	if ( hasParameters )
	{
		this->chn = chn;
		this->srate = srate;
		clearBuffers();
	}
	alloc( enabled && hasParameters );
	return true;
}
示例#16
0
文件: nRenderer.cpp 项目: gan74/nGine
void nRenderer::begin(bool clear) {
	computeVisibility();
	enableAttributes();
	if(clear) {
		clearBuffers();
	}

	glRasterPos2i(0, 0);
	glViewport(0, 0, viewport.x, viewport.y);

	resetMatrix();
}
void GLES2Lesson::render() {
    clearBuffers();
    prepareShaderProgram();
    setPerspective();
    resetTransformMatrices();

    drawGeometry(vboCubeVertexDataIndex,
                 vboCubeVertexIndicesIndex,
                 36,
                 cubeTransformMatrix
    );
}
示例#18
0
// would be called by main thread
bool
FLVParser::seek(boost::uint32_t& time)
{

	boost::mutex::scoped_lock streamLock(_streamMutex);
	// we might obtain this lock while the parser is pushing the last
	// encoded frame on the queue, or while it is waiting on the wakeup
	// condition

	// Setting _seekRequest to true will make the parser thread
	// take care of cleaning up the buffers before going on with
	// parsing, thus fixing the case in which streamLock was obtained
	// while the parser was pushing to queue
	_seekRequest = true;

	if ( _cuePoints.empty() )
	{
		log_debug("No known cue points yet, can't seek");
		return false;
	}

	CuePointsMap::iterator it = _cuePoints.lower_bound(time);
	if ( it == _cuePoints.end() )
	{
		log_debug("No cue points greater or equal requested time %d", time);
		return false;
	}

	long lowerBoundPosition = it->second;
	log_debug("Seek requested to time %d triggered seek to cue point at "
            "position %d and time %d", time, it->second, it->first);
	time = it->first;
	_lastParsedPosition=lowerBoundPosition; 
	_parsingComplete=false; // or NetStream will send the Play.Stop event...


	// Finally, clear the buffers.
	// The call will also wake the parse up if it was sleeping.
	// WARNING: a race condition might be pending here:
	// If we handled to do all the seek work in the *small*
	// time that the parser runs w/out mutex locked (ie:
	// after it unlocked the stream mutex and before it locked
	// the queue mutex), it will still push an old encoded frame
	// to the queue; if the pushed frame alone makes it block
	// again (bufferFull) we'll have a problem.
	// Note though, that a single frame can't reach a bufferFull
	// condition, as it takes at least two for anything != 0.
	//
	clearBuffers();

	return true;
}
//
//	Display up to 3 lines of text centered on screen
//  Each line is separated by a |
// It is the basic version that tries to use only 2 lines
// in most cases, 3 when needed
//______________________________________
void ADMVideoSubtitle::displayString(subLine *string)
{
 
	uint32_t base=0;	
	uint32_t nbLine=0;
	uint32_t i=0;
	uint32_t overflow=0;

      aprintf("Sub: Rendering string %s\n",string);
// bbase is the final position in line
// in the image

	clearBuffers();
	nbLine=string->nbLine;
	if(nbLine>SRT_MAX_LINE )
	{
		nbLine=SRT_MAX_LINE;
		printf("Too much lines\n");
	}
	switch(nbLine)
	{
		case 0:
			base=2*_conf->_fontsize;; // 1 or 2 lines we dont use the upper line		
			break;
		case 1:
			base=_conf->_fontsize;; // 1 or 2 lines we dont use the upper line		
			break;
		default:
                        base=0;
                        break;
	}	
		
	aprintf("Sub: %d lines to render\n",nbLine);
	// scan and display each line
	for(i=0;i<nbLine;i++)
	{
		
			if(string->lineSize[i]!=displayLine(string->string[i],base,string->lineSize[i]))
                                overflow=1;
			base+=_conf->_fontsize;
		
	}
        if(overflow && _conf->_selfAdjustable) 
        {
                printf("Do autosplit\n");
                doAutoSplit(string);
        }
    	doChroma();
	
	
}
示例#20
0
bool MIPMediaBuffer::destroy()
{
	if (!m_init)
	{
		setErrorString(MIPMEDIABUFFER_ERRSTR_NOTINIT);
		return false;
	}
	
	clearMessages();
	clearBuffers();
	m_init = false;
	
	return true;
}
void checkPwd(){
	if (chaineCompare(pwd_buffer, pwd_user) == true) { 
		toggleRelay(); 
		gotoNormalProcess();
	}
	else if (chaineCompare(pwd_buffer, pwd_menu) == true) { 
		stateProgram = MODIFPWD;
		statePwd = DEBUT;
		clearBuffers();
	}
	else { 
		Serial.println("pwd non reconnu");
		gotoNormalProcess();
	}
}
    void GLES2Lesson::render() {
        clearBuffers();
        prepareShaderProgram();
        setPerspective();
        resetTransformMatrices();

        for (auto &star : mStars) {

            glUniform4fv(fragmentTintPosition, 1, &star->mColor[0]);

            drawGeometry(vboCubeVertexDataIndex,
                         vboCubeVertexIndicesIndex,
                         4,
                         star->mTransform
            );
        }
    }
示例#23
0
HeadlessView::~HeadlessView() {
    activate();
    clearBuffers();
    deactivate();

#if MBGL_USE_CGL
    CGLDestroyContext(glContext);
#endif

#if MBGL_USE_GLX
    if (glxPbuffer) {
        glXDestroyPbuffer(xDisplay, glxPbuffer);
        glxPbuffer = 0;
    }

    glXDestroyContext(xDisplay, glContext);
#endif
}
    void GLES2Lesson::render() {
        clearBuffers();
        prepareShaderProgram();
        setPerspective();
        resetTransformMatrices();

        if (enableBlending) {
            enableAlphaBlending();
        } else {
            disableAlfaBlending();
        }


        drawGeometry(vboCubeVertexDataIndex,
                     vboCubeVertexIndicesIndex,
                     36,
                     cubeTransformMatrix
        );
    }
示例#25
0
void transverb::suspend () {

  clearBuffers();
  writer = 0;
  read1 = read2 = 0.0;
  smoothcount1[0] = smoothcount2[0] = 0;
  lastr1val[0] = lastr2val[0] = 0.0f;
  filter1[0].reset();
  filter2[0].reset();
#ifdef TRANSVERB_STEREO
  smoothcount1[1] = smoothcount2[1] = 0;
  lastr1val[1] = lastr2val[1] = 0.0f;
  filter1[1].reset();
  filter2[1].reset();
#endif
  SAMPLERATE = 44100.0f;
  bsize = bufferScaled(fBsize);
  speed1hasChanged = speed2hasChanged = true;
}
示例#26
0
void HeadlessView::resize(const uint16_t width, const uint16_t height, const float pixelRatio) {
    dimensions = { width, height, pixelRatio };

    clearBuffers();

    const unsigned int w = dimensions.width * dimensions.pixelRatio;
    const unsigned int h = dimensions.height * dimensions.pixelRatio;

    // Create depth/stencil buffer
    MBGL_CHECK_ERROR(glGenRenderbuffersEXT(1, &fboDepthStencil));
    MBGL_CHECK_ERROR(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fboDepthStencil));
    MBGL_CHECK_ERROR(glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, w, h));
    MBGL_CHECK_ERROR(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0));

    MBGL_CHECK_ERROR(glGenRenderbuffersEXT(1, &fboColor));
    MBGL_CHECK_ERROR(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fboColor));
    MBGL_CHECK_ERROR(glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA8, w, h));
    MBGL_CHECK_ERROR(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0));

    MBGL_CHECK_ERROR(glGenFramebuffersEXT(1, &fbo));
    MBGL_CHECK_ERROR(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo));

    MBGL_CHECK_ERROR(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, fboColor));
    MBGL_CHECK_ERROR(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER_EXT, fboDepthStencil));

    GLenum status = MBGL_CHECK_ERROR(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT));

    if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
        std::stringstream error("Couldn't create framebuffer: ");
        switch (status) {
            case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: (error << "incomplete attachment.\n"); break;
            case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: error << "incomplete missing attachment.\n"; break;
            case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: error << "incomplete dimensions.\n"; break;
            case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: error << "incomplete formats.\n"; break;
            case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: error << "incomplete draw buffer.\n"; break;
            case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: error << "incomplete read buffer.\n"; break;
            case GL_FRAMEBUFFER_UNSUPPORTED: error << "unsupported.\n"; break;
            default: error << "other\n"; break;
        }
        throw std::runtime_error(error.str());
    }
}
void loop(){
	if (delayInactif.check()) {
		stateProgram = NORMAL;
		clearBuffers();
		Serial.println("raz");
	}
	char key = keypad.getKey();
	if (key != NO_KEY){
		delayInactif.reset();
		delay(100); 
		switch (key){
			case 'A': 
			case 'B': 
			case 'C':
			case 'D':
				break; 
			case '#': 
				// reset pwd
				if (stateProgram == NORMAL) {
					chaineReset(&pwd_buffer);
				}
				else { modifyPwd(key); }
				break;
			case '*': 
				// check pwd
				if (stateProgram == NORMAL) {
					checkPwd();
					chaineReset(&pwd_buffer);
				}
				else { modifyPwd(key); }
				break;
			default: 
				//append to buffer
				if (stateProgram == NORMAL) {
					chaineAppend(key, &pwd_buffer);
					chainePrint(pwd_buffer);
				}
				else { modifyPwd(key); }
			// end of switch
		}
	}
}
void GLES2Lesson::render() {

    clearBuffers();
    prepareShaderProgram();
    setPerspective();

    drawGeometry( triangleVertices,
                  triangleColours,
                  triangleIndices,
                  3,
                  triangleTransformMatrix
                );

    drawGeometry( squareVertices,
                  squareColours,
                  squareIndices,
                  4,
                  squareTransformMatrix
                );
}
示例#29
0
void Buddha::set( double re, double im, double s, uint lr, uint lg, uint lb, uint hr, uint hg, uint hb, QSize wsize, bool pause ) {
	qDebug() << "Buddha::set()";
	bool haveToClear = (wsize.width() != (int) w) || (wsize.height() != (int) h) ||(re != cre) || (im != cim) || (s != scale);
	
	if ( pause ) pauseGenerators( );
	
	w = wsize.width();
	h = wsize.height();
	// I reallocate only if the dimensions are changed otherwise I simply clean the memory
	if ( size != w * h ) {
		size = w * h;
		resizeBuffers( );
	}
	
	cre = re;
	cim = im;
	scale = s;	
	rangere = w / scale;
	rangeim = h / scale;
	minre = cre - rangere * 0.5;
	maxre = cre + rangere * 0.5;
	minim = cim - rangeim * 0.5;
	maxim = cim + rangeim * 0.5;
    lowr = lr;
    lowg = lg;
    lowb = lb;
    highr = hr;
    highg = hg;
    highb = hb;
	high = max( max( highr, highg ), highb );
    low = min( min(lowr, lowg), lowb);
	resizeSequences( );
	//status = RUN;
	
	if ( pause ) {
		if ( haveToClear ) clearBuffers( );
		resumeGenerators( );
	}
	
	emit settedValues( );
}
void HeadlessView::activate() {
    active = true;

    if (!glContext) {
        if (!display) {
            throw std::runtime_error("Display is not set");
        }
        createContext();
    }

    activateContext();

    if (!extensionsLoaded) {
        gl::InitializeExtensions(initializeExtension);
        extensionsLoaded = true;
    }

    if (needsResize) {
        clearBuffers();
        resizeFramebuffer();
        needsResize = false;
    }
}