RSS

OpenGL에서 text display

23 Jan
void glutPrint(float x, float y, void* font, std::string text, float r = 1.0, float g = 1.0, float b = 1.0, float a = 1.0)
{
	if(!text.length()) return;
	bool blending = false;
	//    glEnable(GL_BLEND);
	//    glDisable(GL_TEXTURE_2D);
	if(glIsEnabled(GL_BLEND))
	{
		blending = true;
	}
	glEnable(GL_BLEND);
	//    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	//    glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
	//    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_DST_ALPHA);
	//    glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_DST_ALPHA);

	glColor4f(r,g,b,a);
	glRasterPos2f(x,y);
	for (int i=0;i<text.length();i++) {
		glutBitmapCharacter(font, text[i]);
	}
	if(!blending)
	{
		glDisable(GL_BLEND);
	}
	//    glEnable(GL_TEXTURE_2D);

}

 

 

 

usage :

glutPrint(10, 30, GLUT_BITMAP_TIMES_ROMAN_24, "Emiya Muljomdao !!!", 1.0, 105.0 / 255.0, 180.0 / 255.0);
Advertisements
 
Leave a comment

Posted by on January 23, 2014 in OpenGL

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: