Beispiel #1
0
bool
Tick::drawGlutText(QString str,
		   int xc0, int xc1, int yc0, int yc1,
		   float sclx, float scly,
		   float perpx, float perpy,
		   float angle, bool angleFixed, float pshift)
{
  int len = str.length();
  if (len <= 0)
    return false;

  int width = glutStrokeLength(GLUT_STROKE_ROMAN,
			       (unsigned char*)(str.toAscii().data()));

  int x = (xc0+xc1)/2;
  int y = (yc0+yc1)/2;
  x += perpx*pshift;
  y += perpy*pshift;
  if (angleFixed)
    {
      x += 0.9*perpx;
      y += 0.9*perpy;
    }

  glPushMatrix();
  glTranslatef(x, y, 0);
  glScaled(sclx, scly, 1);
  glRotatef(angle, 0, 0, 1);
  glTranslatef(-width/2, 0, 0);
  for (int i = 0; i < len; i++)
    glutStrokeCharacter(GLUT_STROKE_ROMAN, (str[i].toAscii()));
  glPopMatrix();
  
  return true;
}
Beispiel #2
0
static int
string_width (sws_configuration *sc, const char *s)
{
  if (textures_p)
    return texture_string_width (sc->texfont, s, 0);
  else
    return glutStrokeLength (GLUT_FONT, (unsigned char *) s);
}
Beispiel #3
0
void XSADrawString(d_XSA3DPoint translate,float rotation,double scale,const unsigned char* string) {
    int length = glutStrokeLength(GLUT_STROKE_MONO_ROMAN, string);
    glPushMatrix();
        glTranslated(translate.x, translate.y, translate.z);
        glScaled(scale, scale, scale);
        glRotatef(-rotation, 0.0, 1.0, 0.0);
        glTranslated(-(length / 2), 0.0, 0.0);
        glutStrokeString(GLUT_STROKE_MONO_ROMAN, string);
    glPopMatrix();
}
Beispiel #4
0
double drawString_length ( const std::string & str ) { 
    //this underestimates...
#ifdef _USE_FTGL_FONTS_
    float x1, y1, z1, x2, y2, z2;
	kernedFont->BBox( str.c_str() , x1, y1, z1, x2, y2, z2);
    return 10 * ( x2 - x1 );
#else
    return glutStrokeLength( GLUT_STROKE_ROMAN, (const unsigned char* ) str.c_str() );
#endif
}
Beispiel #5
0
void XSADrawStringHUD(d_XSA3DPoint point,float rotation,const unsigned char* buf) {
    int length = glutStrokeLength(GLUT_STROKE_MONO_ROMAN,  buf);
    glColor3f(0.0, 1.0, 0.0); // green
    glPushMatrix();
        glTranslated(point.x, point.y, point.z);
        glRotatef(-rotation, 0.0, 1.0, 0.0);
        glTranslated(0.0, 0.1, -10.0);
        glScaled(0.001, 0.001, 0.001);
        glTranslated(-(length / 2), 0.0, 0.0);
        glutStrokeString(GLUT_STROKE_MONO_ROMAN, buf);
    glPopMatrix();
}
Beispiel #6
0
void strokeCenterString(char *str,double x, double y, double z, double s)
{
	int i,n;

	n = strlen(str);
	glPushMatrix();
	glTranslated(x-glutStrokeLength(GLUT_STROKE_ROMAN,(const unsigned char*)str)*0.5*s,y-119.05*0.5*s,z);
	glScaled(s,s,s);
	for(i=0;i<n;i++)
		glutStrokeCharacter(GLUT_STROKE_ROMAN,(int)str[i]);
	glPopMatrix();

}
Beispiel #7
0
NODE *
do_StrokeLength(int nargs)
{
	NODE *tmp;
	void *font;
	const unsigned char *string;

	tmp = (NODE *) get_scalar_argument(0, FALSE);
	force_string(tmp);
	if ((font = str2font(tmp->stptr)) == NULL) {
		// TODO
	}

	tmp = (NODE *) get_scalar_argument(1, FALSE);
	force_string(tmp);
	string = (const unsigned char *) tmp->stptr;

	return make_number((AWKNUM) glutStrokeLength(font, string));
}
Beispiel #8
0
/** StrokeLength (font, string) -> number
 *   StrokeWidth (font, string) -> number
 */
static int glut_stroke_length(lua_State *L) {
  void *e;

   /* test argument */
  if(!lua_isstring(L, 1) || !lua_isstring(L, 2))
    luaL_error(L, "incorrect argument to function 'gl.StrokeLength'");

  e = get_glut_enum(L, 1);

   /* test argument */
  if(e == ENUM_ERROR)
    luaL_error(L, "incorrect string argument to function 'gl.StrokeLength'");


  const char *p = lua_tostring(L, 2);

  /* call opengl function and push the return value on the stack */
  lua_pushnumber(L, glutStrokeLength(e, p));

  return 1;
}
float Line::stringWidth(string* xiText)
{
    // Logger::Log("Calculating Line.stringWidth...", LOG_DEBUG);
    return glutStrokeLength(mFont, (const unsigned char*)xiText->c_str()) * mScale;
}
Beispiel #10
0
int
main(int argc, char **argv)
{
  void *font;
  int total;
  int i, j;

  glutInit(&argc, argv);

  /* Touch test the width determination of all bitmap
     characters. */
  for (i = 0; i < NUM_BITMAP_FONTS; i++) {
    font = bitmap_fonts[i];
    total = 0;
    for (j = -2; j < 259; j++) {
      total += glutBitmapWidth(font, j);
    }
    printf("  %s: bitmap total = %d (expected %d)\n", bitmap_names[i], total, bitmap_lens[i]);
    if (total != bitmap_lens[i]) {
      printf("FAIL: test25\n");
      exit(1);
    }
  }

  /* Touch test the width determination of all stroke
     characters. */
  for (i = 0; i < NUM_STROKE_FONTS; i++) {
    font = stroke_fonts[i];
    total = 0;
    for (j = -2; j < 259; j++) {
      total += glutStrokeWidth(font, j);
    }
    printf("  %s: stroke total = %d (expected %d)\n", stroke_names[i], total, stroke_lens[i]);
    if (total != stroke_lens[i]) {
      printf("FAIL: test25\n");
      exit(1);
    }
  }

  for (i = 0; i < NUM_BITMAP_FONTS; i++) {
    font = bitmap_fonts[i];
    total = glutBitmapLength(font, abc);
    printf("  %s: bitmap abc len = %d (expected %d)\n", bitmap_names[i], total, bitmap_abc_lens[i]);
    if (total != bitmap_abc_lens[i]) {
      printf("FAIL: test25\n");
      exit(1);
    }
  }

  for (i = 0; i < NUM_BITMAP_FONTS; i++) {
    font = bitmap_fonts[i];
    total = glutBitmapLength(font, "");
    printf("  %s: bitmap abc len = %d (expected %d)\n", bitmap_names[i], total, 0);
    if (total != 0) {
      printf("FAIL: test25\n");
      exit(1);
    }
  }

  for (i = 0; i < NUM_STROKE_FONTS; i++) {
    font = stroke_fonts[i];
    total = glutStrokeLength(font, abc);
    printf("  %s: stroke abc len = %d (expected %d)\n", stroke_names[i], total, stroke_abc_lens[i]);
    if (total != stroke_abc_lens[i]) {
      printf("FAIL: test25\n");
      exit(1);
    }
  }

  for (i = 0; i < NUM_STROKE_FONTS; i++) {
    font = stroke_fonts[i];
    total = glutStrokeLength(font, "");
    printf("  %s: stroke null len = %d (expected %d)\n", stroke_names[i], total, 0);
    if (total != 0) {
      printf("FAIL: test25\n");
      exit(1);
    }
  }

  printf("PASS: test25\n");
  return 0;             /* ANSI C requires main to return int. */
}
Beispiel #11
0
/* Renvoie l'espace occupe par la chaine de caracteres de taille donnee */
float tailleChaine(const char *chaine, float taille)
{
	return glutStrokeLength(GLUT_STROKE_ROMAN, (const unsigned char *)chaine)*taille/120.f;
}
Beispiel #12
0
void TeleportWindow::render(int window_w, int window_h)
{
	// Calculate size of 1 pixel
	float ps_w = 2. / window_w; // pixelsize x-direction
	float ps_h = 2. / window_h; // pixelsize y-direction
	float apsr = 1.*window_w / window_h; // aspectatio

	// Whole Window
	glColor3f(0.0, 0.0, 0.1);
	glBegin(GL_QUADS);
	{
		glVertex3f(-0.9, -0.9, -1.0);
		glVertex3f(-0.9,  0.9, -1.0);
		glVertex3f( 0.9,  0.9, -1.0);
		glVertex3f( 0.9, -0.9, -1.0);
	}
	glEnd();

	// Preview Widget
	glColor3f (0.1, 0.1, 0.1);
	glBegin(GL_QUADS);
	{
		glVertex3f(-0.45/apsr, -0.45, -1.0);
		glVertex3f(-0.45/apsr,  0.45, -1.0);
		glVertex3f( 0.45/apsr,  0.45, -1.0);
		glVertex3f( 0.45/apsr, -0.45, -1.0);
	}
	glEnd();

	glColor3f(1.0, 1.0, 1.0);
	glRasterPos2f(-0.9 + 4 * ps_w, -0.9 + 4 * ps_h);
	glutBitmapString(GLUT_BITMAP_HELVETICA_12,
		(unsigned char *)"Use arrow keys up and down to select the desired action.\
		Use arrow keys right and left to select your destination or type its name.");

	glColor3f(1, 1, 1);
	unsigned char *actionstring = (unsigned char *)
		m_actions.at(m_action_selected).getDescription().c_str();
	float actionstring_len = glutBitmapLength(GLUT_BITMAP_HELVETICA_18, actionstring);

	glRasterPos2f(0 - actionstring_len / 2 * ps_w, 1 - 70 * ps_h);
	glutBitmapString(GLUT_BITMAP_HELVETICA_18, actionstring);

	float offset_l = m_destination.length() * 4.5;
	glRasterPos2f(0 - offset_l * ps_w, 1 - 93 * ps_h);
	glutBitmapString(GLUT_BITMAP_HELVETICA_18, (unsigned char *)m_destination.c_str());

	glColor3f(1, 1, 1);
	// Render preview of TeleportTarget
	glPushAttrib(GL_ENABLE_BIT);
	{
		glEnable (GL_DEPTH);
		glEnable (GL_DEPTH_TEST);
		glEnable (GL_BLEND);

		glScalef(1.0f / apsr, 1.0f, 1.0f);

		glTranslatef(0.0f, 0.0f, -1.0f);
		if (m_target)
			m_target->renderPreview(m_preview_time, 0.4f);
		else
		{
			// Draw Wire Sphere
			glLineWidth(2.0);
			glPushMatrix();
			{
				glRotatef(m_preview_time * TELEPORT_PREVIEW_ROTSPEED, 0, 1, 0);
				glRotatef(90, 1, 0, 0);
				glutWireSphere(0.4, 20, 20);
			}
			glPopMatrix();

			// Draw red question mark
			glPushMatrix();
			{
				glColor3f(1.0f, 0.0f, 0.0f);
				glLineWidth(5.0);
				float textsize = 0.5;
				float font_height = textsize / glutStrokeHeight(GLUT_STROKE_MONO_ROMAN);
				float font_width  = textsize / glutStrokeLength(GLUT_STROKE_MONO_ROMAN,
					(unsigned char *)"?");

				glTranslatef(0.0f, 0.0f, 1.0f);
				glRotatef(m_preview_time * TELEPORT_PREVIEW_ROTSPEED, 0, 1, 0);
				glTranslatef(-textsize / 2, -textsize / 4, 0.4f);
				glScalef(font_width, font_height, font_width);
				glutStrokeString(GLUT_STROKE_MONO_ROMAN, (unsigned char *)"?");
			}
		}
	}
	glPopAttrib();
}
/*
 * Class:     gruenewa_opengl_GLUT__
 * Method:    glutStrokeLength
 * Signature: (ILjava/lang/String;)I
 */
JNIEXPORT jint JNICALL Java_gruenewa_opengl_GLUT_00024_glutStrokeLength
  (JNIEnv * jenv, jobject jobj, jint arg1, jobject arg2) {
  return glutStrokeLength((void*) arg1, (*jenv)->GetDirectBufferAddress(jenv, arg2)); 
}
Beispiel #14
0
int DrawGLUtils::GetStrokedTextWidth(float size, const wxString &text) {
    int ret = glutStrokeLength(GLUT_STROKE_ROMAN, text.c_str()) * size / 150;
    return ret;
}
Beispiel #15
0
 double length ( const std::string & str ) { 
     if ( m_mono )
         return m_mono_width * str.length();
     else 
         return glutStrokeLength( GLUT_STROKE_ROMAN, (const unsigned char* ) str.c_str() );
 }