void DynamicRandomDots::drawFrame(shared_ptr<StimulusDisplay> display, int frameNumber) {
    // If we're drawing to the main display, update dot positions
    if (display->getCurrentContextIndex() == 0) {
        currentTime = getElapsedTime();
        updateDots();
        previousTime = currentTime;
    }

    // Enable antialiasing so dots are round, not square
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glBlendEquation(GL_FUNC_ADD);
    glEnable(GL_POINT_SMOOTH);
    glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST);
    
    glColor4f(colorR, colorG, colorB, alpha);

    glEnableClientState(GL_VERTEX_ARRAY);

    glPointSize(dotSizeInPixels[display->getCurrentContextIndex()]);
    glVertexPointer(verticesPerDot, GL_FLOAT, 0, &(dots[0]));
    glDrawArrays(GL_POINTS, 0, numDots);

    glDisableClientState(GL_VERTEX_ARRAY);
    
    glDisable(GL_BLEND);
    glDisable(GL_POINT_SMOOTH);
}
Example #2
0
void MovingDots::drawFrame(shared_ptr<StimulusDisplay> display) {
    //
    // If we're drawing to the main display, update dots
    //
    
    if (display->getCurrentContextIndex() == 0) {
        currentTime = getElapsedTime();
        if (previousTime != currentTime) {
            updateParameters();
            updateDots();
            previousTime = currentTime;
        }
    }
    
    if (0 == currentNumDots) {
        // No dots, so nothing to draw
        return;
    }
    
    //
    // Draw the dots
    //
    
    glPushMatrix();
    glTranslatef(fieldCenterX->getValue().getFloat(), fieldCenterY->getValue().getFloat(), 0.0f);
    glScalef(currentFieldRadius, currentFieldRadius, 1.0f);
    glRotatef(direction->getValue().getFloat(), 0.0f, 0.0f, 1.0f);
    
    // Enable antialiasing so dots are round, not square
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glBlendEquation(GL_FUNC_ADD);
    glEnable(GL_POINT_SMOOTH);
    glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST);
    
    glColor4f(red->getValue().getFloat(),
              green->getValue().getFloat(),
              blue->getValue().getFloat(),
              alpha->getValue().getFloat());

    glEnableClientState(GL_VERTEX_ARRAY);

    glPointSize(dotSize->getValue().getFloat() * dotSizeToPixels[display->getCurrentContextIndex()]);
    glVertexPointer(verticesPerDot, GL_FLOAT, 0, &(dotPositions[0]));
    glDrawArrays(GL_POINTS, 0, currentNumDots);

    glDisableClientState(GL_VERTEX_ARRAY);
    
    glDisable(GL_BLEND);
    glDisable(GL_POINT_SMOOTH);
    
    glPopMatrix();
}
Example #3
0
void MovingDots::drawFrame(shared_ptr<StimulusDisplay> display) {
    //
    // Update dots
    //
    
    currentTime = getElapsedTime();
    if (previousTime != currentTime) {
        updateParameters();
        updateDots();
        previousTime = currentTime;
        
        if (currentNumDots > 0) {
            gl::BufferBinding<GL_ARRAY_BUFFER> arrayBufferBinding(dotPositionBuffer);
            glBufferData(GL_ARRAY_BUFFER,
                         dotPositions.size() * sizeof(decltype(dotPositions)::value_type),
                         dotPositions.data(),
                         GL_STREAM_DRAW);
        }
    }
    
    if (0 == currentNumDots) {
        // No dots, so nothing to draw
        return;
    }
    
    //
    // Draw the dots
    //
    
    gl::ProgramUsage programUsage(program);
    gl::VertexArrayBinding vertexArrayBinding(vertexArray);
    
    auto currentMVPMatrix = GLKMatrix4Translate(display->getProjectionMatrix(),
                                                fieldCenterX->getValue().getFloat(),
                                                fieldCenterY->getValue().getFloat(),
                                                0.0);
    currentMVPMatrix = GLKMatrix4Scale(currentMVPMatrix, currentFieldRadius, currentFieldRadius, 1.0);
    currentMVPMatrix = GLKMatrix4Rotate(currentMVPMatrix,
                                        GLKMathDegreesToRadians(direction->getValue().getFloat()),
                                        0.0,
                                        0.0,
                                        1.0);
    glUniformMatrix4fv(mvpMatrixUniformLocation, 1, GL_FALSE, currentMVPMatrix.m);
    
#if !MWORKS_OPENGL_ES
    gl::Enabled<GL_PROGRAM_POINT_SIZE> pointSizeEnabled;
#endif
    glUniform1f(pointSizeUniformLocation, dotSize->getValue().getFloat() * dotSizeToPixels);
    
    auto currentColor = GLKVector4Make(red->getValue().getFloat(),
                                       green->getValue().getFloat(),
                                       blue->getValue().getFloat(),
                                       alpha->getValue().getFloat());
    glUniform4fv(colorUniformLocation, 1, currentColor.v);
    
    gl::Enabled<GL_BLEND> blendEnabled;
    glBlendEquation(GL_FUNC_ADD);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    
    glDrawArrays(GL_POINTS, 0, currentNumDots);
}
MainWindowLifeGame::MainWindowLifeGame(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindowLifeGame)
{
/*
export DISPLAY=":0.0"
xhost +
cd Desktop/ISIB_LifeGameClientV1/
sudo DISPLAY=:0 ./ISIB_LifeGameClient
*/
    this->rpiGpio = new mmapGpio();
    this->rpiGpio->setPinDir(this->pinNumIn,mmapGpio::INPUT);

   this->tnbr = new QRegExp ("Tree ([0-9]+)");
   this->herbr = new QRegExp ("Herbi ([0-9]+)");
   this->carbr  = new QRegExp ("Carni ([0-9]+)");
   this->invbr  = new QRegExp ("Invad ([0-9]+)");
   this->yearBr  = new QRegExp ("YEAR ([0-9]+)");


    int id = QFontDatabase::addApplicationFont("://data/Greenscr.ttf");
    QString family = QFontDatabase::applicationFontFamilies(id).at(0);
    QFont Greenscr(family,18);

    this->socket = new QTcpSocket(this);
    this->connect(this->socket, SIGNAL(readyRead()), SLOT(readTcpData()));
    this->connect(this->socket, SIGNAL(disconnected()), SLOT(autoReconnect()));

    QSettings settings("conf.ini", QSettings::IniFormat);
    this->ip = settings.value("OPTIONS/IP","127.0.0.1").toString();
    this->port = settings.value("OPTIONS/PORT", 11900).toInt();


    //qDebug() << "Address "<<this->ip<<":"<<this->port;

    this->timerDots = new QTimer();
    this->timerDots->connect(this->timerDots, SIGNAL(timeout()),this, SLOT(updateDots()));
    this->timerDots->start(500);

    this->timerButt = new QTimer();
    this->timerButt->connect(this->timerButt, SIGNAL(timeout()),this, SLOT(changeBG()));

    this->timerGpio = new QTimer();
    this->timerGpio->connect(this->timerGpio, SIGNAL(timeout()),this, SLOT(readGPIO()));
    this->timerGpio->start(100);

    this->dataTab[0]=0;
    this->dataTab[1]=0;
    this->dataTab[2]=0;
    this->dataTab[3]=0;

    bool connected = false;
    while(!(connected)){
        this->socket->connectToHost(this->ip,this->port);
        if( this->socket->waitForConnected(5000) ) {
           this->socket->write("HELLO SERVER[/TCP]");
           this->socket->flush();
           connected = true;
        }
    }

    ui->setupUi(this);



    ui->label->setFont(Greenscr);
    ui->label->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed));
    ui->labelYear->setFont(Greenscr);
    ui->labelDotAnim->setFont(Greenscr);
    ui->labelArbre->setFont(Greenscr);
    ui->labelArbre_2->setFont(Greenscr);
    ui->labelArbre_3->setFont(Greenscr);
    ui->labelArbre_4->setFont(Greenscr);
    ui->progressBarTree->setFont(Greenscr);
    ui->progressBarHerbi->setFont(Greenscr);
    ui->progressBarCarni->setFont(Greenscr);
    ui->progressBarInvade->setFont(Greenscr);

    ui->textEditTree->setFont(Greenscr);
    ui->textEditHerbi->setFont(Greenscr);
    ui->textEditCarni->setFont(Greenscr);
    ui->textEditBrut->setFont(Greenscr);
    ui->textEditInvad->setFont(Greenscr);

    QMainWindow::showFullScreen();
    QApplication::setOverrideCursor(Qt::BlankCursor);

     /*this->sbHerbi = ui->textEditHerbi->verticalScrollBar();
     this->sbHerbi->setValue(this->sbHerbi->maximum());

     this->sbCarni = ui->textEditCarni->verticalScrollBar();
     this->sbCarni->setValue(this->sbCarni->maximum());

     this->sbBrut = ui->textEditBrut->verticalScrollBar();
     this->sbBrut->setValue(this->sbBrut->maximum());

     this->sbInvad = ui->textEditInvad->verticalScrollBar();
     this->sbInvad->setValue(this->sbInvad->maximum());

    this->sbTree = ui->textEditTree->verticalScrollBar();
    this->sbTree->setValue(this->sbTree->maximum());
*/

}