GLint to GLfloat in ofTexture.draw


This is a very, very tiny bug which i happened to come across. In ofTexture.draw GLint is used to represent the coordinates and size of the texture to be drawn. When drawing this with width and height smaller than 1, the video isn’t drawn, because they are rounded downwards to 0. By changing all occurrences of GLint to GLfloat, the decimals are kept and the texture is drawn nicely. But maybe there is a reason why GLint is used in the first place?


The edited ofTexture.draw looks like this:

void ofTexture::draw(float x, float y, float w, float h){  
	// bind the texture  
	glBindTexture( textureTarget, (GLuint)textureName[0] );  
		GLfloat px0 = 0;  
		GLfloat py0 = 0;  
		GLfloat px1 = (GLfloat)w;  
		GLfloat py1 = (GLfloat)h;  
		if (bFlipTexture == true){  
			GLfloat temp = py0;  
			py0 = py1;  
			py1 = temp;  
		// for rect mode center, let's do this:  
		if (ofGetRectMode() == OF_RECTMODE_CENTER){  
			px0 = (GLfloat)-w/2;  
			py0 = (GLfloat)-h/2;  
			px1 = (GLfloat)+w/2;  
			py1 = (GLfloat)+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;  
		GLfloat offseth = 0;  
		if (textureTarget == GL_TEXTURE_2D){  
			offsetw = 1.0f/(tex_w);  
			offseth = 1.0f/(tex_h);  
		// -------------------------------------------------  
		GLfloat tx0 = 0+offsetw;  
		GLfloat ty0 = 0+offseth;  
		GLfloat tx1 = tex_t - offsetw;  
		GLfloat ty1 = tex_u - offseth;  
		glTranslated(x, y, 0);  
		glBegin( GL_QUADS );  
			glTexCoord2f(tx0,ty0);	glVertex3f(px0, py0,0);  
			glTexCoord2f(tx1,ty0);	glVertex3f(px1, py0,0);  
			glTexCoord2f(tx1,ty1);	glVertex3f(px1, py1,0);  
			glTexCoord2f(tx0,ty1);	glVertex3f(px0, py1,0);