Ejemplo n.º 1
0
void RogersGuiApp::draw(){
    float currTime = timer.getSeconds();
	float deltaTime = currTime - prevTime;
	prevTime = currTime;
    
	if (autoRotation)
		rotation += deltaTime/2;
    
    gl::clear( colorBack );
    gl::enableAdditiveBlending();
    gl::disableDepthRead();    
    gl::pushMatrices();
    gl::translate(Vec3f(getWindowWidth()/2, getWindowHeight()/2, 0));
    
    gl::color( color );    
    for(int i=0;i<50; i++) {
        gl::rotate(Vec3f(0, 0, rotation));
        gl::drawSolidRect(Rectf(20, 20, 140, 140));
    }
    
    gl::color(ColorA(0.5, 0.25, 0.0, 0.05));    
    for(int i=0;i<50; i++) {
        gl::rotate(Vec3f(0, 0, rotation/4));
        gl::drawSolidRect(Rectf(50, 50, 340, 340));
    }
    
    gl::enableDepthRead();    
    gl::disableAlphaBlending();
    gl::popMatrices();	
	
	FPS = getAverageFps();
	gui->draw();
	
	//std::cout << "LIST = " << listVal << std::endl;
}
Ejemplo n.º 2
0
void ButtonsAndTexturesApp::draw(){
    float currTime = timer.getSeconds();
	float deltaTime = currTime - prevTime;
	prevTime = currTime;
    
    rotation += deltaTime/2;
    
    gl::clear(ColorA(0.1, 0.1, 0.5, 0.92));
    gl::enableAdditiveBlending();
    gl::disableDepthRead();    
    gl::pushMatrices();
    gl::translate(Vec3f(getWindowWidth()/2, getWindowHeight()/2, 0));
    
    gl::color(ColorA(1, 0.2, 0.2, 0.1));    
    for(int i=0;i<50; i++) {
        gl::rotate(Vec3f(0, 0, rotation));
        gl::drawSolidRect(Rectf(20, 20, 140, 140));
    }
    
    gl::color(ColorA(0.5, 0.25, 0.0, 0.05));    
    for(int i=0;i<50; i++) {
        gl::rotate(Vec3f(0, 0, rotation/4));
        gl::drawSolidRect(Rectf(50, 50, 340, 340));
    }
    
    gl::enableDepthRead();    
    gl::disableAlphaBlending();
    gl::popMatrices();	
	gui->draw();
}
Ejemplo n.º 3
0
void ScheinrieseApp::draw()
{
    gl::clear( Color( 0, 0, 0 ) );
    gl::setMatricesWindow( getWindowWidth(), getWindowHeight() );
    glColor3f( 1.0f, 1.0f, 1.0f );

    /* debug view */
    drawDebug();

    //	glPushMatrix();
    //	for (int i = 0; i < mContours.size(); i++) {
    //		glColor3f(0.0f,1.0f,1.0f);
    //		glBegin( GL_LINE_STRIP );
    //		for (int j = 0; j < mContours[i].size(); j+=10) {
    //			glVertex2f( mContours[i][j].x, mContours[i][j].y);
    //		}
    //		glEnd();
    //	}
    //	glPopMatrix();

    /*
     //for (int i = 0; i < mContours.size(); i++) {
     //		vector<p2t::Point*> polyline;
     //		for (int j = 0; j < mContours[i].size(); j+=1) {
     //			polyline.push_back(new p2t::Point(mContours[i][j].x, mContours[i][j].y));
     //		}
     //		if (polyline.size() > 9) {
     //		cout << "Number of line points = " << polyline.size() << endl;
     //		CDT* cdt = new CDT(polyline);
     //		cdt->Triangulate();
     //		//vector<p2t::Triangle*> triangles = cdt->GetTriangles();
     //		//cout << "Number of triangles = " << triangles.size() << endl;
     //		}
     //	}

     gl::setMatricesWindow( getWindowWidth(), getWindowHeight() );
     glPushMatrix();
     glTranslatef(200,200,0);
     GLdouble quad1[4*3] = { -100,300,0, 0,0,0, 100,300,0, 0,200,0 };
     tessellate(quad1, 12);
     glPopMatrix();

     for (int i = 0; i < mContours.size(); i++) {
     gl::setMatricesWindow( getWindowWidth(), getWindowHeight() );
     glPushMatrix();
     for (int j = 0; j < mContours[i].size(); j+=1) {

     }
     glPopMatrix();
     }
     */
    // GUI
    mGui->draw();
}
void GroupingApp::draw() {
	float currTime = timer.getSeconds();
	float deltaTime = currTime - prevTime;
	prevTime = currTime;
	
	if (autoRotation) {
		rotation += deltaTime * 60;
		rotation = fmod(rotation, 360);
	}
	
	fbo.bindFramebuffer();
	
	gl::pushMatrices();
	gl::clear(ColorA(0.2, 0.2, 0.2, 1.0));
	gl::translate(Vec2f(getWindowWidth()/2, getWindowHeight()/2));
	gl::rotate(rotation);
	gl::color(color);
	gl::enableAlphaBlending();
	gl::disableDepthRead();
	
	if (fill) {
		gl::translate(Vec2f(-50, -50));
		gl::drawSolidRect(Rectf(-size/2, -size/2, size/2, size/2));
		gl::translate(Vec2f(+100, +100));
		gl::drawSolidRect(Rectf(-size/2, -size/2, size/2, size/2));
	}
	else if (stroke) {
		glLineWidth(thickness);
		gl::translate(Vec2f(-50, -50));
		gl::drawLine(Vec2f(-size/2, -size/2), Vec2f( size/2, -size/2));
		gl::drawLine(Vec2f( size/2, -size/2), Vec2f( size/2,  size/2));
		gl::drawLine(Vec2f( size/2,  size/2), Vec2f(-size/2,  size/2));
		gl::drawLine(Vec2f(-size/2,  size/2), Vec2f(-size/2, -size/2));		
		gl::translate(Vec2f(+100, +100));
		gl::drawLine(Vec2f(-size/2, -size/2), Vec2f( size/2, -size/2));
		gl::drawLine(Vec2f( size/2, -size/2), Vec2f( size/2,  size/2));
		gl::drawLine(Vec2f( size/2,  size/2), Vec2f(-size/2,  size/2));
		gl::drawLine(Vec2f(-size/2,  size/2), Vec2f(-size/2, -size/2));
		glLineWidth(1);
	}
	gl::popMatrices();	
	
	fbo.unbindFramebuffer();
	
	gl::color(ColorA(1,1,1,1));
	gl::draw(fbo.getTexture());
	
	strokePanel->enabled = stroke ? true : false;
	gui->draw();
}
Ejemplo n.º 5
0
void BasicApp::draw() {
	float currTime = timer.getSeconds();
	float deltaTime = currTime - prevTime;
	prevTime = currTime;

	if (autoRotation) {
		rotation += deltaTime * 60;
		rotation = fmod(rotation, 360);
	}
	
	gl::pushMatrices();
	gl::clear(ColorA(0.0, 0.0, 0.0, 0.92));
	gl::translate(Vec2f(getWindowWidth()/2, getWindowHeight()/2));
	gl::rotate(rotation);
	gl::color(color);
	gl::enableAlphaBlending();
	gl::disableDepthRead();
	
	if (fill) {
		gl::translate(Vec2f(-50, -50));
		gl::drawSolidRect(Rectf(-size/2, -size/2, size/2, size/2));
		gl::translate(Vec2f(+100, +100));
		gl::drawSolidRect(Rectf(-size/2, -size/2, size/2, size/2));
	}
	else if (stroke) {
		gl::translate(Vec2f(-50, -50));
		gl::drawLine(Vec2f(-size/2, -size/2), Vec2f( size/2, -size/2));
		gl::drawLine(Vec2f( size/2, -size/2), Vec2f( size/2,  size/2));
		gl::drawLine(Vec2f( size/2,  size/2), Vec2f(-size/2,  size/2));
		gl::drawLine(Vec2f(-size/2,  size/2), Vec2f(-size/2, -size/2));		
		gl::translate(Vec2f(+100, +100));
		gl::drawLine(Vec2f(-size/2, -size/2), Vec2f( size/2, -size/2));
		gl::drawLine(Vec2f( size/2, -size/2), Vec2f( size/2,  size/2));
		gl::drawLine(Vec2f( size/2,  size/2), Vec2f(-size/2,  size/2));
		gl::drawLine(Vec2f(-size/2,  size/2), Vec2f(-size/2, -size/2));
	}
	gl::popMatrices();	
	gui->draw();
}
Ejemplo n.º 6
0
void RogalarmApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) );
	gl::enableAlphaBlending();
	
	if (mKinectConected) {
        
		//Rectf centeredRect = Rectf( mDepthTexture.getBounds() ).getCenteredFit( getWindowBounds(), true );
		//gl::draw( mDepthTexture, centeredRect  );
		
		
		//gl::drawLine(Vec2f(mUserPos, 0), Vec2f(mUserPos, 640));
		gl::color (Color8u(255 ,255, 0));
		gl::drawSolidRect (Rectf(mUserPos-2, 0, mUserPos+2, 640) ,false);
        
		mGui->draw();
        
	}else {
		Rectf centeredRect2 = Rectf( mKonnect.getBounds() ).getCenteredFit( getWindowBounds(), true );
		gl::draw( mKonnect, centeredRect2  );
	}

}
void GesichtertauschApp::draw() {
    
    glClearColor( 0, 0, 0, 1.0 );
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    
    if ( ! mCameraTexture ) {
        return;
    }
        
//    gl::setMatricesWindow( getWindowSize() ),
    gl::setMatricesWindow(WINDOW_WIDTH, WINDOW_HEIGHT);
    gl::enableAlphaBlending();
    glScalef(-1.0, 1.0, 1.0);
    glTranslatef(-WINDOW_WIDTH, 0, 0);
    
    /* shader */
    // TODO make this more opt'd
    if (ENABLE_SHADER) {
        mShader.bind();
        const int STEPS = 32;
        float mThresholds[STEPS];// = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0};
        for (int i=0; i < STEPS; ++i) {
            mThresholds[i] = float(i) / float(STEPS - 1);
        }
        mShader.uniform("thresholds", mThresholds, STEPS);   
        mShader.uniform( "tex0", 0 );
    }

    /* draw the webcam image */
    gl::color( BACKGROUND_IMAGE_COLOR );
    gl::draw( mCameraTexture, Rectf(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT) );
    mCameraTexture.disable();
    
    /* normalize texture coordinates */
    Vec2f mNormalizeScale = Vec2f(1.0 / float(WINDOW_WIDTH), 1.0 / float(WINDOW_HEIGHT));
    glMatrixMode(GL_TEXTURE);
    glPushMatrix();
    glScalef(mNormalizeScale.x, mNormalizeScale.y, 1.0);
    glMatrixMode(GL_MODELVIEW);
    
    /* draw orgiginal faces */
    if (mEntities.size() < 2) {
        gl::enableAlphaBlending();
        mCameraTexture.enableAndBind();
        for( vector<FaceEntity>::const_iterator mIter = mEntities.begin(); mIter != mEntities.end(); ++mIter ) {
            drawEntity(*mIter, FACE_COLOR_UNO);
        }    
        mCameraTexture.disable();
        gl::disableAlphaBlending();
    }
    
    /* HACK // swap faces */
    mCameraTexture.enableAndBind();
    if (mEntities.size() >= 2) {
        const FaceEntity A = mEntities[0];
        const FaceEntity B = mEntities[1];
        if (A.visible && B.visible) {
            FaceEntity mEntityA = FaceEntity();
            FaceEntity mEntityB = FaceEntity();
            
            mEntityA.border = B.border;
            mEntityB.border = A.border;
            mEntityA.slice = A.slice;
            mEntityB.slice = B.slice;
            mEntityA.visible = A.visible;
            mEntityB.visible = B.visible;
            mEntityA.ID = A.ID;
            mEntityB.ID = B.ID;
            
            drawEntity(mEntityA, FACE_COLOR_DUO);
            drawEntity(mEntityB, FACE_COLOR_DUO);
        }
    }

    /* restore texture coordinates */
    glMatrixMode(GL_TEXTURE);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);

    mCameraTexture.disable();

    /* shader */
    if (ENABLE_SHADER) {
        mShader.unbind();
    }

    /* mask */
    float MASK_LEFT_TOP = 1;
    float MASK_LEFT_BOTTOM = 1;
    float MASK_RIGHT_TOP = 1;
    float MASK_RIGHT_BOTTOM = 1;
    
    gl::color(0, 0, 0, 1);

    Path2d mPathLeft;
    mPathLeft.moveTo(0, 0);
    mPathLeft.lineTo(MASK_LEFT_TOP, 0);
    mPathLeft.lineTo(MASK_LEFT_BOTTOM, WINDOW_HEIGHT);
    mPathLeft.lineTo(0, WINDOW_HEIGHT);
    mPathLeft.close();    
    gl::drawSolid(mPathLeft);
    
    Path2d mPathRight;
    mPathRight.moveTo(WINDOW_WIDTH, 0);
    mPathRight.lineTo(WINDOW_WIDTH-MASK_RIGHT_TOP, 0);
    mPathRight.lineTo(WINDOW_WIDTH-MASK_RIGHT_BOTTOM, WINDOW_HEIGHT);
    mPathRight.lineTo(WINDOW_WIDTH, WINDOW_HEIGHT);
    mPathRight.close();    
    gl::drawSolid(mPathRight);

    /* draw entity IDs */
    const bool DRAW_ENTITY_ID = false;
    if (DRAW_ENTITY_ID) {
        for( vector<FaceEntity>::const_iterator mIter = mEntities.begin(); mIter != mEntities.end(); ++mIter ) {
            const FaceEntity mEntity = *mIter;
            std::stringstream mStr;
            mStr << mEntity.ID;
            gl::drawStringCentered(mStr.str(), mEntity.border.getCenter(), Color(1, 0, 0), mFont);
        }    
    }
        
    /* gooey */
    mGui->draw();
}