Exemplo n.º 1
0
// see drawSubsection
void mui::TextureAtlas::addSubsection(float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh){
	GLfloat px0 = x;		// up to you to get the aspect ratio right
	GLfloat py0 = y;
	GLfloat px1 = w+x;
	GLfloat py1 = h+y;
	
	if (tex.texData.bFlipTexture == ofIsVFlipped()){
		swap(py0,py1);
	}
	
	// for rect mode center, let's do this:
	if (ofGetRectMode() == OF_RECTMODE_CENTER){
		px0 -= w/2;
		py0 -= h/2;
		px1 -= w/2;
		py1 -= h/2;
	}
	
	// -------------------------------------------------
	// complete hack to remove border artifacts.
	// slightly, slightly alters an image, scaling...
	// to remove the border.
	// we need a better solution for this, but
	// to constantly add a 2 pixel border on all uploaded images
	// is insane..
	
	GLfloat offsetw = 0.0f;
	GLfloat offseth = 0.0f;
	
	if (!ofGLSupportsNPOTTextures() && ofIsTextureEdgeHackEnabled()) {
		offsetw = 1.0f / (tex.texData.tex_w);
		offseth = 1.0f / (tex.texData.tex_h);
	}
	// -------------------------------------------------
	
	ofPoint topLeft = tex.getCoordFromPoint(sx, sy);
	ofPoint bottomRight = tex.getCoordFromPoint(sx + sw, sy + sh);
	
	GLfloat tx0 = topLeft.x + offsetw;
	GLfloat ty0 = topLeft.y + offseth;
	GLfloat tx1 = bottomRight.x - offsetw;
	GLfloat ty1 = bottomRight.y - offseth;
	

	add.addVertex(ofVec3f(px0,py0,z));
	add.addVertex(ofVec3f(px1,py0,z));
	add.addVertex(ofVec3f(px1,py1,z));

	add.addVertex(ofVec3f(px0,py0,z));
	add.addVertex(ofVec3f(px1,py1,z));
	add.addVertex(ofVec3f(px0,py1,z));
	
	add.addTexCoord(ofVec3f(tx0,ty0));
	add.addTexCoord(ofVec3f(tx1,ty0));
	add.addTexCoord(ofVec3f(tx1,ty1));
	
	add.addTexCoord(ofVec3f(tx0,ty0));
	add.addTexCoord(ofVec3f(tx1,ty1));
	add.addTexCoord(ofVec3f(tx0,ty1));
}
Exemplo n.º 2
0
void ofxPanel::render(){
	border.draw();
	headerBg.draw();

	ofBlendMode blendMode = ofGetStyle().blendingMode;
	if(blendMode!=OF_BLENDMODE_ALPHA){
		ofEnableAlphaBlending();
	}
	ofColor c = ofGetStyle().color;
	ofSetColor(thisTextColor);

	bindFontTexture();
	textMesh.draw();
	unbindFontTexture();

	bool texHackEnabled = ofIsTextureEdgeHackEnabled();
	ofDisableTextureEdgeHack();
	loadIcon.draw(loadBox);
	saveIcon.draw(saveBox);

	if(texHackEnabled){
		ofEnableTextureEdgeHack();
	}

	for(int i = 0; i < (int)collection.size(); i++){
		collection[i]->draw();
	}

	ofSetColor(c);
	if(blendMode!=OF_BLENDMODE_ALPHA){
		ofEnableBlendMode(blendMode);
	}
}
Exemplo n.º 3
0
void ofxPanel::render(){
	border.draw();
	headerBg.draw();
    
    
    
	ofBlendMode blendMode = ofGetStyle().blendingMode;
	if(blendMode!=OF_BLENDMODE_ALPHA){
		ofEnableAlphaBlending();
	}
	ofColor c = ofGetStyle().color;
	ofSetColor(thisTextColor);
    
	bindFontTexture();
	textMesh.draw();
	unbindFontTexture();
    
	bool texHackEnabled = ofIsTextureEdgeHackEnabled();
	ofDisableTextureEdgeHack();
    //	loadIcon.draw(loadBox);
    //	saveIcon.draw(saveBox);
    if(isDynamic){
        ofSetColor(255,0,0);
        if(*isActive){
            ofFill();
        }
        else ofNoFill();
        
        ofRect(activeBox);
        
        ofSetColor(0,255,0);
        if(*isPiping){
            ofFill();
        }
        else ofNoFill();
        ofRect(pipeBox);
    }
	if(texHackEnabled){
		ofEnableTextureEdgeHack();
	}
    
	for(int i = 0; i < (int)collection.size(); i++){
		collection[i]->draw();
	}
    
	ofSetColor(c);
	if(blendMode!=OF_BLENDMODE_ALPHA){
		ofEnableBlendMode(blendMode);
	}
}
Exemplo n.º 4
0
void ofxPanel::render(){
    
    this->prerender();
    
    ofColor c;
    ofBlendMode blendMode;
    bool performDraw = !useFbo || requiresRerender;
    if( performDraw ){
    
        border.draw();
        headerBg.draw();

        blendMode = ofGetStyle().blendingMode;
        if(blendMode!=OF_BLENDMODE_ALPHA){
            ofEnableAlphaBlending();
        }
        c = ofGetStyle().color;
        ofSetColor(thisTextColor);

        bindFontTexture();
        textMesh.draw();
        unbindFontTexture();

        bool texHackEnabled = ofIsTextureEdgeHackEnabled();
        ofDisableTextureEdgeHack();
        loadIcon.draw(loadBox);
        saveIcon.draw(saveBox);
        if(texHackEnabled){
            ofEnableTextureEdgeHack();
        }
        
        
    }

    int len = (int)collection.size();
	for(int i = 0; i < len; i++){
		collection[i]->draw(useFbo);
	}

    if( performDraw ){
        ofSetColor(c);
        if(blendMode!=OF_BLENDMODE_ALPHA){
            ofEnableBlendMode(blendMode);
        }
        
        requiresRerender = false;
    }
    this->postrender();
}
Exemplo n.º 5
0
// copied almost directly from ofTexture.cpp
// changes:
// - no anchor point support (doesn't make sense)
// - removed bind/unbind/activetex
//----------------------------------------------------------
void mui::TextureAtlas::drawSubsection(float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh) {
	GLfloat px0 = x;		// up to you to get the aspect ratio right
	GLfloat py0 = y;
	GLfloat px1 = w+x;
	GLfloat py1 = h+y;
	
	if (tex.texData.bFlipTexture == ofIsVFlipped()){
		swap(py0,py1);
	}
	
	// for rect mode center, let's do this:
	if (ofGetRectMode() == OF_RECTMODE_CENTER){
		px0 -= w/2;
		py0 -= h/2;
		px1 -= w/2;
		py1 -= h/2;
	}
	
	//we translate our drawing points by our anchor point.
	//we still respect ofRectMode so if you have rect mode set to
	//OF_RECTMODE_CENTER your anchor will be relative to that.
	GLfloat anchorX;
	GLfloat anchorY;
	
	
	// -------------------------------------------------
	// complete hack to remove border artifacts.
	// slightly, slightly alters an image, scaling...
	// to remove the border.
	// we need a better solution for this, but
	// to constantly add a 2 pixel border on all uploaded images
	// is insane..
	
	GLfloat offsetw = 0.0f;
	GLfloat offseth = 0.0f;
	
	if (!ofGLSupportsNPOTTextures() && ofIsTextureEdgeHackEnabled()) {
		offsetw = 1.0f / (tex.texData.tex_w);
		offseth = 1.0f / (tex.texData.tex_h);
	}
	// -------------------------------------------------
	
	ofPoint topLeft = tex.getCoordFromPoint(sx, sy);
	ofPoint bottomRight = tex.getCoordFromPoint(sx + sw, sy + sh);
	
	GLfloat tx0 = topLeft.x + offsetw;
	GLfloat ty0 = topLeft.y + offseth;
	GLfloat tx1 = bottomRight.x - offsetw;
	GLfloat ty1 = bottomRight.y - offseth;
	
	/*if(z>0 || z<0){
		ofPushMatrix();
	 
		ofTranslate(0,0,z);
	 }*/
	quad.getVertices()[0].set(px0,py0,z);
	quad.getVertices()[1].set(px1,py0,z);
	quad.getVertices()[2].set(px1,py1,z);
	quad.getVertices()[3].set(px0,py1,z);
	
	quad.getTexCoords()[0].set(tx0,ty0);
	quad.getTexCoords()[1].set(tx1,ty0);
	quad.getTexCoords()[2].set(tx1,ty1);
	quad.getTexCoords()[3].set(tx0,ty1);
	
	quad.draw();
}