//---------------------------------------------------------------------
void ofDrawBitmapCharacterStart(int stringLength) {

    verts.clear();
    coords.clear();

    verts.assign(12 * (stringLength+1), 0);
    coords.assign(12 * (stringLength+1), 0);

    if(!bBitmapTexturePrepared) {
        prepareBitmapTexture();
    }

    glesBitmappedFontTexture.bind();

#ifndef TARGET_OPENGLES
    // this temporarily enables alpha testing,
    // which discards pixels unless their alpha is 1.0f
    glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT);
    glEnable(GL_ALPHA_TEST);
    glAlphaFunc(GL_EQUAL, 1.0f);
#endif

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState( GL_TEXTURE_COORD_ARRAY );

    glTexParameterf(glesBitmappedFontTexture.getTextureData().textureTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    vC = 0;
}
//---------------------------------------------------------------------
void ofDrawBitmapCharacterStart(int stringLength){
	charMesh.getVertices().resize(6 * stringLength);
	charMesh.getTexCoords().resize(6 * stringLength);

	if(!bBitmapTexturePrepared){
		prepareBitmapTexture();
	}
	
	vC = 0;
}
Exemple #3
0
//---------------------------------------------------------------------
void  ofDrawBitmapCharacter(int character, int x , int y){

	if(!bBitmapTexturePrepared){
		prepareBitmapTexture();
	}
		
	if (character < 128) {
		
		//TODO: look into a better fix. 
		//old ofDrawBitmapString was 3 pixels higher, so this version renders text in a different position. 
		//3 pixel adjustment corrects that. 
		y -= 3;
		
		glesBitmappedFontTexture.bind();
		
		float posTexW = (float)(character % 16)/16.0f;
		float posTexH = ((int)(character / 16.0f))/16.0f;
		
		if( vC + 12 > 2048 ){
			return;
		}
		
		coords[vC]		= posTexW;
		coords[vC+1]	= posTexH;
		coords[vC+2]	= posTexW + widthTex;
		coords[vC+3]	= posTexH;
		coords[vC+4]	= posTexW+widthTex;
		coords[vC+5]	= posTexH+heightTex;
		

		coords[vC+6]	= posTexW + widthTex;
		coords[vC+7]	= posTexH+heightTex;
		coords[vC+8]	= posTexW;
		coords[vC+9]	= posTexH+heightTex;
		coords[vC+10]	= posTexW;
		coords[vC+11]	= posTexH;
		
		verts[vC]	= x;
		verts[vC+1]	= y;
		verts[vC+2]	= x+8;
		verts[vC+3]	= y;
		verts[vC+4]	= x+8;
		verts[vC+5]	= y+14;
				
		verts[vC+6]	= x+8;
		verts[vC+7]	= y+14;
		verts[vC+8] = x;
		verts[vC+9] = y+14;
		verts[vC+10] = x;
		verts[vC+11] = y;
			
		vC += 12;
	}	
}
//---------------------------------------------------------------------
void  ofDrawBitmapCharacter(int character, int x , int y){

	if(!bBitmapTexturePrepared){
		prepareBitmapTexture();
	}
		
	if (character < 128) {
		
		glesBitmappedFontTexture.bind();
		
		float posTexW = (float)(character % 16)/16.0f;
		float posTexH = ((int)(character / 16.0f))/16.0f;
		
		if( vC + 12 > 2048 ){
			return;
		}
		
		coords[vC]		= posTexW;
		coords[vC+1]	= posTexH;
		coords[vC+2]	= posTexW + widthTex;
		coords[vC+3]	= posTexH;
		coords[vC+4]	= posTexW+widthTex;
		coords[vC+5]	= posTexH+heightTex;
		

		coords[vC+6]	= posTexW + widthTex;
		coords[vC+7]	= posTexH+heightTex;
		coords[vC+8]	= posTexW;
		coords[vC+9]	= posTexH+heightTex;
		coords[vC+10]	= posTexW;
		coords[vC+11]	= posTexH;
		
		verts[vC]	= x;
		verts[vC+1]	= y;
		verts[vC+2]	= x+8;
		verts[vC+3]	= y;
		verts[vC+4]	= x+8;
		verts[vC+5]	= y+14;
				
		verts[vC+6]	= x+8;
		verts[vC+7]	= y+14;
		verts[vC+8] = x;
		verts[vC+9] = y+14;
		verts[vC+10] = x;
		verts[vC+11] = y;
			
		vC += 12;
	}	
}
//---------------------------------------------------------------------
void  ofDrawBitmapCharacter(int character, int x , int y){

	if(!bBitmapTexturePrepared){
		prepareBitmapTexture();
	}
		
	if (character < 128) {		

		float posTexW = (float)(character % 16)/16.0f;
		float posTexH = ((int)(character / 16.0f))/16.0f;

		float texY1 = posTexH;
		float texY2 = posTexH+heightTex;

		//TODO: look into a better fix.
		//old ofDrawBitmapString was 3 pixels higher, so this version renders text in a different position.
		//3 pixel adjustment corrects that when y is flpped 5 when it's not.
		int yOffset = 14;
		if(!ofIsVFlipped()){
			y += 5;
			y += yOffset;
			yOffset *= -1;
		}else{
			y -= 3;
		}


		charMesh.getTexCoords()[vC].set(posTexW,texY1);
		charMesh.getTexCoords()[vC+1].set(posTexW + widthTex,texY1);
		charMesh.getTexCoords()[vC+2].set(posTexW+widthTex,texY2);

		charMesh.getTexCoords()[vC+3].set(posTexW + widthTex,texY2);
		charMesh.getTexCoords()[vC+4].set(posTexW,texY2);
		charMesh.getTexCoords()[vC+5].set(posTexW,texY1);

		charMesh.getVertices()[vC].set(x,y);
		charMesh.getVertices()[vC+1].set(x+8,y);
		charMesh.getVertices()[vC+2].set(x+8,y+yOffset);

		charMesh.getVertices()[vC+3].set(x+8,y+yOffset);
		charMesh.getVertices()[vC+4].set(x,y+yOffset);
		charMesh.getVertices()[vC+5].set(x,y);
			
		vC += 6;
	}	
}
ofTexture & ofBitmapStringGetTextureRef(){
	if(!bBitmapTexturePrepared){
		prepareBitmapTexture();
	}
	return bitmappedFontTexture;
}