예제 #1
0
void Graph::draw(int x, int y) {
	ofPushMatrix();
	ofPushStyle();
	ofTranslate(x, y);
	
	drawPosition = worldToScreen(ofVec2f(0, 0));
	
	ofFill();
	ofSetColor(ofMap(ofGetElapsedTimef() - lastTrigger, 0, .5, 255, 0, true));
	if(noData) {
		ofSetColor(128);
	}
	ofRect(0, 0, width, height);
	
	ofNoFill();
	ofSetColor(255);
	ofPushStyle();
//	if(hoverState) {
//		ofSetHexColor(0xffee00);
//		ofSetLineWidth(2);
//	}
	ofRect(0, 0, width, height);
	ofPopStyle();
	
	ofRectangle region(1, height - 1, width - 2, -(height - 2));
	ofSetHexColor(0xec008c);
	if(noData) {
		ofSetColor(200);
	}
	drawBuffer(derivativePolyline, threshold, derivativeBox, region);
	ofSetColor(255);
	drawBuffer(bufferPolyline, 0, bufferBox, region);
	
	ofSetColor(255);
	drawString(name, 5, 10);
	
	if(!buffer.empty() && !derivative.empty()) {
		ofPushMatrix();
		ofTranslate(width, 0);
		drawString(ofToString(bufferBox.y, 2) + "<" + (buffer.empty() ? "empty" :  ofToString(buffer.back(), 2)) + "<" + ofToString(bufferBox.y + bufferBox.height, 2), 5, 10);
		drawString(ofToString(derivativeBox.y, 2) + "<" + (derivative.empty() ? "empty" :  ofToString(derivative.back(), 2)) + "<" + ofToString(derivativeBox.y + derivativeBox.height, 2), 5, 18);
		drawString(ofToString(threshold, 2) + ", " + ofToString(buffer.back(), 2) + " (" + ofToString(getNormalized(), 2) + ") " + ofToString(derivative.back(), 2), 5, 26);
		ofPopMatrix();
	}
	
	ofPopStyle();
	ofPopMatrix();
}
//スクロールにともなうバッファの再描画
//渡される無効エリアの座標はコンテンツ座標系
void SXBSchView::updateViewBuffer(bool bForceUpdate)//int clipx,int clipy, int clipw, int cliph )
{


    bool update = bForceUpdate;
    int x = 0;
    int y = 0;
    int w = width();
    int h = height();
    int opCount = m_pDoc->opCount();

    if(m_oldContentsX != x || m_oldContentsY != y) {
        update = true;
        m_oldContentsX = x;
        m_oldContentsY = y;
    }

    if(m_oldOpCount    != opCount) {
        update = true;
        m_oldOpCount = opCount;
    }

    if(m_oldViewScale != m_viewScale || m_oldViewScaleMul != m_viewScaleMul) {
        update = true;
        m_oldViewScale = m_viewScale;
        m_oldViewScaleMul = m_viewScaleMul;
    }

    if(update)drawBuffer(x,y,x,y,w,h);
    m_applicationWindow->setWindowModified(m_pDoc->isDirty());
}
예제 #3
0
Action::ResultE RenderAction::stop(ResultE res)
{
#ifdef OSG_RENPART_DUMP_PAR
    fprintf(stderr, "Stop\n");
    fflush(stderr);
#endif

    Inherited::stop(res);

    if(!_doCullOnly)
    {
        drawBuffer(_currentBuffer);

        if(getVolumeDrawing())
            drawVolume(_oFrustum);
    }

    if(_pViewarea != NULL && _pViewarea->getRenderOptions() != NULL)
    {
        _pViewarea->getRenderOptions()->deactivate(this);
    }
    else if(_pWindow != NULL && _pWindow->getRenderOptions() != NULL)
    { 
        _pWindow->getRenderOptions()->deactivate(this);
    }

    return Action::Continue;
}
예제 #4
0
int main(void)
{
    unsigned char ret;

    DDRB  = 0xff;                              // use all pins on port B for output 
    PORTB = 0x00;                              // (LED's low & off)

    i2c_init();                                // init I2C interface

    ret = i2c_start(DevSSD1306+I2C_WRITE);       // set device address and write mode
    if ( ret ) {
        /* failed to issue start condition, possibly no device found */
        i2c_stop();
        PORTB=0xff;                            // activate all 8 LED to show error */
    }
    else {
    /* issuing start condition ok, device accessible */
    setup_i2c();
    setup_adc();
    }
    for(;;){
        clearBuffer(buffer);

        // get accelerometer values
        sample_adc_channel(1);
        sample_adc_channel(2);
        sample_adc_channel(3);

        PORTB=0x00;
        drawBuffer(0, 0, buffer);
        PORTB=0xFF;
        _delay_ms(500);

    }
}
예제 #5
0
    virtual void renderFinished(const Camera*)
    {
      GLCHECK4()
      CHECK(texture()->dimension() == TD_TEXTURE_1D)

      glDrawBuffer(drawBuffer()); GLCHECK4()
      glBindTexture(TD_TEXTURE_1D, texture()->handle() ); GLCHECK4()
      glCopyTexSubImage1D(TD_TEXTURE_1D, level(), xoffset(), x(), y(), width()); GLCHECK4()
      glBindTexture(TD_TEXTURE_1D, 0 ); GLCHECK4()
    }
예제 #6
0
파일: main.cpp 프로젝트: forevermzm/s096
void NBodyWindow::display() {
  updateBuffer();

	glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

  drawBuffer();

  glutSwapBuffers();
	glutPostRedisplay();
}
예제 #7
0
void LedCube::lightsOut(unsigned int wait)
{
    enableBuffer();
    fillBuffer();
    drawBuffer(25);
    for(byte w=0, l, c, max = num; w<max; )
    {
        // lower bound is inclusive, upper is exclusive
        l = random(0, levels);
        c = random(0, cols);
        
        if(getBufferAt(l,c) == HIGH)
        {
            lightOff(l,c);
            drawBuffer(wait);
            w++;
        }
    }
    enableBuffer(false);
}
Action::ResultE RenderAction::stop(ResultE res)
{
#ifdef OSG_RENPART_DUMP_PAR
    fprintf(stderr, "Stop\n");
    fflush(stderr);
#endif

    Inherited::stop(res);

    if(!_doCullOnly)
    {
        drawBuffer(_currentBuffer);

        if(getVolumeDrawing())
            drawVolume(_oFrustum);

        if(_pStatistics != NULL)
        {
            UInt32 uiNMatrix      = 0;
            UInt32 uiNState       = 0;
            UInt32 uiNShader      = 0;
            UInt32 uiNShaderParam = 0;
            UInt32 uiNTriangles   = 0;
            
            for(UInt32 i = 0; 
                       i < _vRenderPartitions[_currentBuffer].size(); 
                     ++i)
            {
                uiNMatrix +=
                    _vRenderPartitions[
                        _currentBuffer][i]->getNumMatrixChanges();
                
                uiNState  +=
                    _vRenderPartitions[
                        _currentBuffer][i]->getNumStateChanges();
                
                uiNShader +=
                    _vRenderPartitions[
                        _currentBuffer][i]->getNumShaderChanges();
                
                uiNShaderParam +=
                    _vRenderPartitions[
                        _currentBuffer][i]->getNumShaderParamChanges();
                
                uiNTriangles +=
                    _vRenderPartitions[_currentBuffer][i]->getNumTriangles();
            }


            _pStatistics->getElem(statNMatrices    )->set(uiNMatrix     );
            _pStatistics->getElem(statNStates      )->set(uiNState      );
            _pStatistics->getElem(statNShaders     )->set(uiNShader     );
            _pStatistics->getElem(statNShaderParams)->set(uiNShaderParam);
            _pStatistics->getElem(statNTriangles   )->set(uiNTriangles);
        }
    }

    if(_pViewport != NULL && _pViewport->getRenderOptions() != NULL)
    {
        _pViewport->getRenderOptions()->deactivate(this);
    }
    else if(_pWindow != NULL && _pWindow->getRenderOptions() != NULL)
    { 
        _pWindow->getRenderOptions()->deactivate(this);
    }

    return Action::Continue;
}
예제 #9
0
void main(void) {
	/* your definitions here */
  int leftADValue = 0;
  int rightADValue = 0;
  char leftButton = 1;
  char leftButtonLast = 1;
  char rightButton = 1;
  char rightButtonLast = 1;
	
	// init buttons and seven-segment displays
	initIO();
	// init LCD
	initLCD();
	// init A/D converter
	initADC();

	
	/* your code here */
  drawBuffer();
  wait(100001);
  //setPixel(10, 10, 1);

  //writeString(5, 0, "Hallo Welt");
  writeText(LOREM);

  for(;;) {
    switch (curMode) {
      case 0:
        leftADValue = getADCValue(1);
        curLine = inverseScaleDown(leftADValue, lines);
        writeInt(7, 0, curLine+1);
        writeInt(7, 104, lines);
        copyBuffer(curLine, 7);
        drawBuffer();
    //eventloop(4);
      break;
      case 1:
        copyBuffer(curLine, 7);
        writeInt(7, 0, curLine+1);
        writeInt(7, (128 - 4*CHARACTER_WIDTH), lines);
        drawBuffer();
        curLine++;
        if(curLine > lines)
          curMode = 6;
        else
          curMode = 2;
      break;
      case 2:
        wait(DELAY/2);
        curMode = 3;
      break;
      case 3:
        wait(DELAY/2);
        curMode = 4;
      break;
      case 4:
        wait(DELAY/2);
        curMode = 5;
      break;
      case 5:
        wait(DELAY/2);
        curMode = 1;
      break;
      case 6:
        __wait_nop();
      break;
    }
  printNumber(curMode);
  leftButton = PDR07_P0;
  rightButton = PDR07_P2;
  if(leftButton == 1 && leftButtonLast == 0) {
    if (curMode == 0) {
      curLine = 0;
      curMode = 1;
    }
    else {
      curMode = 0;

    }
  }
  leftButtonLast = leftButton;
  rightButtonLast = rightButton;
		__wait_nop();
  }
}
예제 #10
0
int main () {

    //allegro initializations
    allegro_init();
    install_keyboard();
    set_color_depth (desktop_color_depth() );
    set_gfx_mode (GFX_AUTODETECT_WINDOWED, screenWidth, screenHeight, 0, 0);

    LOCK_VARIABLE (timer);
    LOCK_FUNCTION (timestep);
    install_int_ex (timeStep, BPS_TO_TIMER (frameRate) );

    //bitmap initializations
    buffer = create_bitmap (screenWidth, screenHeight);

    //data initializations
    unsigned int n = 0;
    unsigned int i = 0;

    strcpy (planet[EARTH].name, "Earth");
    planet[EARTH].radius = 200;
    planet[EARTH].mass = 5.9742e2;
    planet[EARTH].fillColour = makecol (0, 255, 0);
    planet[EARTH].atmosphereColour = makecol (0, 0, 255);
    planet[EARTH].atmosphereHeight = 3;

    for (n = 0; n < PLANETMAX; n++) {
        planet[n] = planet[EARTH];
        planet[n].x = 1;
        planet[n].y = 1;
    }

    planet[EARTH].x = screenWidth / 2;
    planet[EARTH].y = screenHeight / 2;


    strcpy (craft[HAB].name, "Habitat");
    craft[HAB].fillColour = makecol (211, 211, 211);
    craft[HAB].engineColour = makecol (139, 0, 0);
    craft[HAB].radius = 30;
    craft[HAB].x = screenWidth / 2 + planet[EARTH].radius + craft[HAB].radius;
    craft[HAB].y = screenHeight / 2;
    craft[HAB].mass = 50000;

//    craft[HAB].x = planet[EARTH].x + 1;
//    craft[HAB].y = planet[EARTH].y + 1;

    strcpy (planet[MARS].name, "Mars");
    planet[MARS].x = planet[EARTH].x + planet[EARTH].radius + 800;
    planet[MARS].y = planet[EARTH].y;
    planet[MARS].radius = 150;
    planet[MARS].mass = 6e1;
    planet[MARS].fillColour = makecol (205, 164, 150);
    planet[MARS].atmosphereColour = makecol (160, 40, 40);
    planet[MARS].atmosphereHeight = 7;

    camera.zoom = pow (camera.actualZoom(), 1 / zoomMagnitude);
    camera.x = craft[HAB].x - (screenWidth / 4);
    camera.y = craft[HAB].y - (screenHeight / 4);

    camera.target = &craft[HAB];
    camera.reference = &planet[EARTH];

    while (!key[KEY_ESC]) {

        while (timer > 0) {

            input();

            for (i = 0; i < CRAFTMAX; i++)
                for (n = 0; n < PLANETMAX; n++) {
                    craft[i].gravitate (planet[n]);
                    craft[i].detectCollision (planet[n]);
                    planet[n].gravitate (craft[i]);
                }

//            for (i = 1; i < 4; i++)
//                for (n = 1; n < 4; n++) {
////					craft[i].gravitate (planet[n]);
//                    if (n != i)
//                        planet[n].gravitate (planet[i]);
//
//                    planet[n].detectCollision (planet[i]);
//                }

//            planet[EARTH].accX (2 * PI, 50);
//            planet[EARTH].accY (2 * PI, 50);

            for (n = 1; n < PLANETMAX; n++)
                planet[n].move();

            for (n = 0; n < CRAFTMAX; n++) {
                craft[n].turn();
                craft[n].fireEngine();
                craft[n].move();
            }

            camera.autoZoom();
            camera.shift();




            timer--;
        }

        drawGrid();

        for (n = 0; n < PLANETMAX; n++)
            planet[n].draw();

        for (n = 0; n < CRAFTMAX; n++)
            craft[n].draw();

//        craft[HAB].detectCollision (planet[EARTH]);

        debug();

        drawBuffer();

    }

    //end of program
    destroy_bitmap (buffer);
    return (0);
}