float charWidth (char c, float myFontMetrics) {
  static bool use_bit = XMLSupport::parse_bool(vs_config->getVariable ("graphics","high_quality_font","false"));
  void * fnt = use_bit?getFont():GLUT_STROKE_ROMAN;  
  float charwid = use_bit?glutBitmapWidth(fnt,c):glutStrokeWidth(fnt,c);
  float dubyawid = use_bit?glutBitmapWidth(fnt,'W'):glutStrokeWidth(fnt,'W');
  return charwid*myFontMetrics/dubyawid;
}
Exemple #2
0
float getTextWidth(string* str, float size) {
	int width = 0;
	for (unsigned int c = 0; c < str->length(); c++) {
		width += glutStrokeWidth(FONT, (*str)[c]);
	}
	return (float) width * size;
}
Exemple #3
0
void scaledglprintf2(float sx,float sy,const char *fmt, ...)
{

    //printf("x=%f, y=%f, %s\n\n",sx, sy,fmt);

    float       length=0;                               // Used To Find The Length Of The Text
    char        text[256];                              // Holds Our String
    va_list     ap;                                     // Pointer To List Of Arguments
    int i,tl;

    va_start(ap, fmt);                                  // Parses The String For Variables
    vsprintf(text, fmt, ap);                            // And Converts Symbols To Actual Numbers
    va_end(ap);                                         // Results Are Stored In Text

    tl=strlen(text);
    for(i=0;i<tl;i++) {
        length+=glutStrokeWidth(GLUT_STROKE_MONO_ROMAN,text[i]);
    }

    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glScalef(sx,sy,1.0f);

    glNormal3f(0.0,0.0,1.0);
    for(i=0;i<tl;i++) {
        glutStrokeCharacter(GLUT_STROKE_MONO_ROMAN,text[i]);

    }

    glPopMatrix();

} /* scaledglprintf2 */
Exemple #4
0
void glprintf(const char *fmt, ...)
{
    float       length=0;                               // Used To Find The Length Of The Text
    char        text[256];                              // Holds Our String
    va_list     ap;                                     // Pointer To List Of Arguments
    int i,tl;

    if (fmt==0) return;

    va_start(ap, fmt);                                  // Parses The String For Variables
    vsprintf(text, fmt, ap);                            // And Converts Symbols To Actual Numbers
    va_end(ap);                                         // Results Are Stored In Text

    tl=strlen(text);
    for(i=0;i<tl;i++) {
        length+=glutStrokeWidth(GLUT_STROKE_MONO_ROMAN,text[i]);
    } /* for /*/

    glTranslatef(-length/2,0.0f,0.0f);                  // Center Our Text On The Screen

    glNormal3f(0.0,0.0,1.0);
    for(i=0;i<tl;i++) {
        glutStrokeCharacter(GLUT_STROKE_MONO_ROMAN,text[i]);
    } /* for */
} /* glprintf */
Exemple #5
0
GLfloat text_width(const char* text) {
    GLfloat sum = 0;
    for (const char* p = text; *p; p++) {
        sum += glutStrokeWidth(GLUT_STROKE_ROMAN, *p);
    }
    return sum/STROKE_SCALE;
}
Exemple #6
0
double tglGetTextWidth(const string &s, void *font)
{
	double factor = 0.07;
	double w = 0;
	for (int i = 0; i < (int)s.length(); i++)
		w += glutStrokeWidth(font, s[i]);
	return w * factor;
}
static void glPrintF (int row, int col, const char *fmt, ...)
{
    if (useFont == 0) return;

    const float scale = 0.09f;

    static char buf[128];
    void *strokeFont = GLUT_STROKE_MONO_ROMAN;
    void *bitmapFont = GLUT_BITMAP_9_BY_15;

    static float charWidth = glutStrokeWidth(strokeFont, 35) * scale;
    static float charHeight = glutStrokeHeight(strokeFont) * scale;

    va_list args;
    va_start(args, fmt);
    vsnprintf_s(buf, 128, fmt, args);
    va_end(args);

    glPushMatrix();
    glLoadIdentity();
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glOrtho(0, width, 0, height, -1, 1);

    glDisable(GL_LIGHTING);
    glColor3f(1.0, 1.0, 0.0);
    switch(useFont) {
    case 1:
        //StrokeString, very fast
        glTranslatef(charWidth * col, height - charHeight * row, 0.0);
        glScalef(scale, scale, 1);
        glutStrokeString(strokeFont, (const unsigned char*)buf);
        break;
    case 2:
        //BitmapString, high CPU load
        glRasterPos2i(glutBitmapWidth(bitmapFont, ' ') * col, height - glutBitmapHeight(bitmapFont) * row);
        glutBitmapString (bitmapFont, (const unsigned char*)buf);
        break;
    default:
        //disable
        break;
    }
    glEnable(GL_LIGHTING);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
}
Exemple #8
0
/* seed with text string */
void seed_text(char *string)
{
    int i;
    int width = 0;

    for (i = 0; i < strlen(string); i++) {
        width += glutStrokeWidth(GLUT_STROKE_ROMAN, string[i]);
    }

    glLoadIdentity();
    glScalef(seedsize / 100.0, seedsize / 100.0, seedsize / 100.0);
    glTranslatef(-width / 2.0, -50.0, 0.0);

    for (i = 0; i < strlen(string); i++) {
        set_colour();
        glutStrokeCharacter(GLUT_STROKE_ROMAN, string[i]);
    }
}
Exemple #9
0
NODE *
do_StrokeWidth(int nargs)
{
	NODE *tmp;
	void *font;
	int character;

	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);
	if (tmp->stlen != 1) {
		// TODO
	}
	character = (int) tmp->stptr[0];

	return make_number((AWKNUM) glutStrokeWidth(font, character));
}
Exemple #10
0
    void Util::drawStrokeString(std::string s, GLdouble x, GLdouble y, GLdouble scale, bool centered, double lineWidth, GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha, GLdouble rotation) {
		glPushMatrix();
		{
			glPushAttrib(GL_ENABLE_BIT);
			glEnable(GL_LINE_SMOOTH);
			glEnable(GL_NORMALIZE);
			glLineWidth(lineWidth);
			glColor4d(red, green, blue, alpha);

			glTranslatef(x, y, 0);
			
			int length = 0;
			
			for (int i = 0; s[i] != '\0'; i++) {
				length += glutStrokeWidth(GLUT_STROKE_ROMAN, s[i]);
			}
			
			if(centered) {
				glTranslatef(-length*scale/2, 0, 0);
			}
			
	/*		if(!centered) {
				glTranslatef(-length*scale/2, 0, 0);
				glTranslatef(, 0, 0);
				glRotated(rotation, 0, 0, 1);
			}
	*/		
			glScaled(scale, scale, 0);
			

			glRotated(rotation, 0, 0, 1);
			for (int i = 0; s[i] != '\0'; i++) {
				glutStrokeCharacter(GLUT_STROKE_ROMAN, s[i]);
			}

			glPopAttrib();
		}
		glPopMatrix();
    }
void TextArea::ChompIntoItems( const char *text, const char *parent )
{
    char *temp = strdup( text );
    char *cur  = temp, chr = '\0';
    int   i    = 0, max = strlen( temp );
    float cur_width = 0, wid = 0, end = glutStrokeWidth( GLUT_STROKE_ROMAN, 'A' );
    end /= 2500;
    wid  = end;
    for (i = 0; i <= max; i++) {
        if (temp[i] == '\r') continue;
        cur_width = WidthOfChar( temp[i] );
        if (wid+cur_width > width[5] || temp[i] == '\n') {
            chr     = temp[i];
            temp[i] = '\0';
            AddTextItem( "content", cur, parent );
            temp[i] = chr;
            cur     = &temp[i];
            if (cur[0] == '\n') cur++;
            wid     = end;
        } else {wid += cur_width; }}
    if (temp[i] != '\0') AddTextItem( "content", cur, parent );
    free( temp );
}
void draw_arrow(
	float ax, float ay, float az,
	float bx, float by, float bz,
	float ah, float bh,
	char const * const annotation,
	float annot_size )
{
	int i;

	GLdouble mv[16];
	glGetDoublev(GL_MODELVIEW_MATRIX, mv);
	
	/* We're assuming the modelview RS part is (isotropically scaled)
	 * orthonormal, so the inverse is the transpose.
	 * The local view direction vector is the 3rd column of the matrix;
	 * assuming the view direction to be the normal on the arrows tangent
	 * space  taking the cross product of this with the arrow direction
	 * yields the binormal to be used as the orthonormal base to the 
	 * arrow direction to be used for drawing the arrowheads */

	double d[3] = {
	      bx - ax,
	      by - ay,
	      bz - az
	};
	normalize_v(d);

	double r[3] = { mv[0], mv[4], mv[8] };
	int rev = scalarproduct_v(d, r) < 0.;

	double n[3] = { mv[2], mv[6], mv[10] };
	{
		double const s = scalarproduct_v(d,n);
		for(int i = 0; i < 3; i++)
			n[i] -= d[i]*s;
	}
	normalize_v(n);

	double b[3];
	crossproduct_v(n, d, b);

	GLfloat const pos[][3] = {
		{ax, ay, az},
		{bx, by, bz},
		{ ax + (0.866*d[0] + 0.5*b[0])*ah,
		  ay + (0.866*d[1] + 0.5*b[1])*ah,
		  az + (0.866*d[2] + 0.5*b[2])*ah },
		{ ax + (0.866*d[0] - 0.5*b[0])*ah,
		  ay + (0.866*d[1] - 0.5*b[1])*ah,
		  az + (0.866*d[2] - 0.5*b[2])*ah },
		{ bx + (-0.866*d[0] + 0.5*b[0])*bh,
		  by + (-0.866*d[1] + 0.5*b[1])*bh,
		  bz + (-0.866*d[2] + 0.5*b[2])*bh },
		{ bx + (-0.866*d[0] - 0.5*b[0])*bh,
		  by + (-0.866*d[1] - 0.5*b[1])*bh,
		  bz + (-0.866*d[2] - 0.5*b[2])*bh }
	};
	GLushort const idx_line[][2] = {
		{0, 1},
	};
	GLushort const idx_heads[][3] = {
		{0, 2, 3},
		{1, 4, 5}
	};
	glDisableClientState(GL_COLOR_ARRAY);
	glDisableClientState(GL_NORMAL_ARRAY);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);

	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3, GL_FLOAT, 0, pos);

	glDrawElements(GL_LINES, 2, GL_UNSIGNED_SHORT, idx_line);
	glDrawElements(GL_TRIANGLES, 2*3, GL_UNSIGNED_SHORT, idx_heads);
	glDisableClientState(GL_VERTEX_ARRAY);

	if(annotation) {
		float w = 0;
		for(char const *c = annotation; *c; c++)
			w += glutStrokeWidth(GLUT_STROKE_ROMAN, *c);
		w *= annot_size / 100.;

		float tx = (ax + bx)/2.;
		float ty = (ay + by)/2.;
		float tz = (az + bz)/2.;

		GLdouble r[16] = {
			d[0], d[1], d[2], 0,
			b[0], b[1], b[2], 0,
			n[0], n[1], n[2], 0,
			   0,    0,    0, 1
		};
		glPushMatrix();
		glTranslatef(tx, ty, tz);
		glMultMatrixd(r);
		if(rev)
			glScalef(-1, -1, 1);
		glTranslatef(-w/2., annot_size*0.1, 0);
		draw_strokestring(GLUT_STROKE_ROMAN, annot_size, annotation);
		glPopMatrix();
	}
}
Exemple #13
0
ENTRYPOINT void 
init_sws (ModeInfo *mi)
{
  double font_height;

  sws_configuration *sc = 0;

  if (!scs) {
    scs = (sws_configuration *)
      calloc (MI_NUM_SCREENS(mi), sizeof (sws_configuration));
    if (!scs) {
      fprintf(stderr, "%s: out of memory\n", progname);
      exit(1);
    }
  }

  sc = &scs[MI_SCREEN(mi)];

  sc->dpy = MI_DISPLAY(mi);
  sc = &scs[MI_SCREEN(mi)];
  sc->lines = (char **) calloc (max_lines+1, sizeof(char *));

  if ((sc->glx_context = init_GL(mi)) != NULL) {
    gl_init(mi);
    reshape_sws (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
    clear_gl_error(); /* WTF? sometimes "invalid op" from glViewport! */

    init_stars (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
  }

  if (textures_p)
    {
      int cw, lh;
      sc->texfont = load_texture_font (MI_DISPLAY(mi), "font");
      cw = texture_string_width (sc->texfont, "n", &lh);
      sc->char_width = cw;
      font_height = lh;
      glEnable(GL_ALPHA_TEST);
      glEnable (GL_TEXTURE_2D);

      check_gl_error ("loading font");

      /* "Anistropic filtering helps for quadrilateral-angled textures.
         A sharper image is accomplished by interpolating and filtering
         multiple samples from one or more mipmaps to better approximate
         very distorted textures.  This is the next level of filtering
         after trilinear filtering." */
      if (smooth_p && 
          strstr ((char *) glGetString(GL_EXTENSIONS),
                  "GL_EXT_texture_filter_anisotropic"))
      {
        GLfloat anisotropic = 0.0;
        glGetFloatv (GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &anisotropic);
        if (anisotropic >= 1.0)
          glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 
                           anisotropic);
      }
    }
  else
    {
      font_height = GLUT_FONT->top - GLUT_FONT->bottom;
      sc->char_width = glutStrokeWidth (GLUT_FONT, 'z'); /* 'n' seems wide */
    }
  
  sc->font_scale = 1.0 / sc->char_width;


  /* We consider a font that consumes 80 columns to be "18 points".

     If neither -size nor -columns was specified, default to 60 columns
     (which is 24 points.)

     If both were specified, -columns has priority.
   */
  {
    int base_col  = 80;
    int base_size = 18;

    if (target_columns <= 0 && font_size <= 0)
      target_columns = 60;

    if (target_columns > 0)
      font_size = base_size * (base_col / (double) target_columns);
    else if (font_size > 0)
      target_columns = base_col * (base_size / (double) font_size);
  }

  sc->line_pixel_width = target_columns * sc->char_width;

  sc->font_scale /= target_columns;
  sc->line_height = font_height * sc->font_scale;


  /* Buffer only two lines of text.
     If the buffer is too big, there's a significant delay between
     when the program launches and when the text appears, which can be
     irritating for time-sensitive output (clock, current music, etc.)
   */
  sc->buf_size = target_columns * 2;
  if (sc->buf_size < 80) sc->buf_size = 80;
  sc->buf = (char *) calloc (1, sc->buf_size);

  sc->total_lines = max_lines-1;

  if (random() & 1)
    star_spin = -star_spin;

  if (!alignment_str || !*alignment_str ||
      !strcasecmp(alignment_str, "left"))
    alignment = -1;
  else if (!strcasecmp(alignment_str, "center") ||
           !strcasecmp(alignment_str, "middle"))
    alignment = 0;
  else if (!strcasecmp(alignment_str, "right"))
    alignment = 1;
  else
    {
      fprintf (stderr,
               "%s: alignment must be left, center, or right, not \"%s\"\n",
               progname, alignment_str);
      exit (1);
    }

  sc->tc = textclient_open (sc->dpy);

  /* one more reshape, after line_height has been computed */
  reshape_sws (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
}
int TextPlane::Draw(const string & newText, int offset,bool startlower, bool force_highquality, bool automatte)
{
  int retval=1;
  bool drawbg = (bgcol.a!=0);
  static unsigned int * display_lists=CreateLists ();
	// some stuff to draw the text stuff
  string::const_iterator text_it = newText.begin();
  static bool use_bit = force_highquality||XMLSupport::parse_bool(vs_config->getVariable ("graphics","high_quality_font","false"));
  static float font_point = XMLSupport::parse_float (vs_config->getVariable ("graphics","font_point","16"));
  static bool font_antialias = XMLSupport::parse_bool (vs_config->getVariable ("graphics","font_antialias","true"));
  void * fnt = getFont();
  static float std_wid=glutStrokeWidth (GLUT_STROKE_ROMAN,'W');
  myFontMetrics.i=font_point*std_wid/(119.05+33.33);
  if (use_bit)
	  myFontMetrics.i=glutBitmapWidth(fnt,'W');
  myFontMetrics.j=font_point;
  myFontMetrics.i/=.5*g_game.x_resolution;
  myFontMetrics.j/=.5*g_game.y_resolution;
  float tmp,row, col;
  float origcol,origrow;
  GetPos (row,col);
  GetPos(row,origcol);
  float rowheight=use_bit?getFontHeight():myFontMetrics.j;
  myFontMetrics.j=rowheight;
  
	  
  if (startlower) {
      row -= rowheight;

  }
  GFXPushBlendMode();
  glLineWidth (1);
  if (!use_bit&&font_antialias) {
    GFXBlendMode (SRCALPHA,INVSRCALPHA);
	if(gl_options.smooth_lines)
	{
		glEnable(GL_LINE_SMOOTH);
	}
  }else {
	GFXBlendMode (SRCALPHA,INVSRCALPHA);
	if(gl_options.smooth_lines)
	{
		glDisable(GL_LINE_SMOOTH);
	}
  }
  GFXColorf(this->col);

  GFXDisable (DEPTHTEST);
  GFXDisable (CULLFACE);

  GFXDisable (LIGHTING);

  GFXDisable (TEXTURE0);
  GFXDisable (TEXTURE1);

  glPushMatrix();
  glLoadIdentity();
  if (!automatte&&drawbg) {
	GFXColorf(this->bgcol);
	DrawSquare(col,this->myDims.i,row-rowheight*.25,row+rowheight);
  }
  GFXColorf(this->col);

  int entercount=0;
  for (;entercount<offset&&text_it!=newText.end();text_it++) {
    if (*text_it=='\n')
      entercount++;
  }
  glTranslatef(col,row,0);  
  //  glRasterPos2f (g_game.x_resolution*(1-(col+1)/2),g_game.y_resolution*(row+1)/2);
  glRasterPos2f (0,0);
  float scalex=1;
  float scaley=1;
  int potentialincrease=0;
  if (!use_bit) {
    int numplayers=1;
    if (_Universe) // _Universe can be NULL during bootstrap.
      numplayers = (_Universe->numPlayers()>3?_Universe->numPlayers()/2:
                    _Universe->numPlayers());
    scalex=numplayers*myFontMetrics.i/std_wid;
    scaley=myFontMetrics.j/(119.05+33.33);
  }
  glScalef (scalex,scaley,1);
  bool firstThroughLoop=true;
  GFXColor currentCol (this->col);
  while(text_it != newText.end() && (firstThroughLoop||row>myDims.j-rowheight*.25)) {
    unsigned char myc = *text_it;
    if (myc=='_') {
      myc = ' ';
    }
    float shadowlen = 0;
    if(myc=='\t') {
      shadowlen=glutBitmapWidth(fnt,' ')*5./(.5*g_game.x_resolution);
    } else {
      if (use_bit) {
        shadowlen = glutBitmapWidth (fnt,myc)/(float)(.5*g_game.x_resolution); // need to use myc -- could have transformed '_' to ' '
      } else {
        shadowlen = myFontMetrics.i*glutStrokeWidth(GLUT_STROKE_ROMAN,myc)/std_wid;
      }
    }
    
    if (*text_it=='#') {
      if (newText.end()-text_it>6) {
	float r,g,b;
	r = TwoCharToFloat (*(text_it+1),*(text_it+2));
	g = TwoCharToFloat (*(text_it+3),*(text_it+4));
	b = TwoCharToFloat (*(text_it+5),*(text_it+6));
	if (r==0&&g==0&&b==0) {
		currentCol = this->col;
	}else {
		currentCol = GFXColor(r, g, b, this->col.a);
	}
	GFXColorf(currentCol);
        static bool setRasterPos= XMLSupport::parse_bool(vs_config->getVariable("graphics","set_raster_text_color","true"));
        if (use_bit&&setRasterPos)
          glRasterPos2f(col-origcol,0);
	text_it = text_it+6;
      } else {
        break;
      }
      text_it++;
      continue;
    }else if(*text_it>=32) {//always true
	  if(automatte){
		GFXColorf(this->bgcol);
		DrawSquare(col-origcol,col-origcol+shadowlen/scalex,-rowheight*.25/scaley,rowheight*.75/scaley);
		GFXColorf(currentCol);
	  }
      //glutStrokeCharacter (GLUT_STROKE_ROMAN,*text_it);
      retval+=potentialincrease;
      potentialincrease=0;
      int lists = display_lists[myc+(isInside()?128:0)];
      if (lists) {
	    GFXCallList(lists);
	  }else{
		 if (use_bit){
	        glutBitmapCharacter (fnt,myc);
		  }
		 else{
           glutStrokeCharacter (GLUT_STROKE_ROMAN,myc);
		 }
      }
	}
    if(*text_it=='\t') {
	  if(automatte){
		GFXColorf(this->bgcol);
		DrawSquare(col-origcol,col-origcol+shadowlen*5/(.5*g_game.x_resolution),-rowheight*.25/scaley,rowheight*.75/scaley);
		GFXColorf(currentCol);
	  }
      col+=shadowlen;
      glutBitmapCharacter (fnt,' ');
      glutBitmapCharacter (fnt,' ');
      glutBitmapCharacter (fnt,' ');
      glutBitmapCharacter (fnt,' ');
      glutBitmapCharacter (fnt,' ');
    } else {
      col+=shadowlen;
    }
    if(doNewLine(text_it,newText.end(),col,myDims.i, myFontMetrics.i,row-rowheight<=myDims.j)){
      GetPos (tmp,col);
      firstThroughLoop=false;
      row -= rowheight;
      glPopMatrix();
      glPushMatrix ();
      glLoadIdentity();
	  if (!automatte&&drawbg) {
		GFXColorf(this->bgcol);
		DrawSquare(col,this->myDims.i,row-rowheight*.25,row+rowheight*.75);
	  }
      if (*text_it=='\n') {
	    currentCol = this->col;
      }
	  GFXColorf(currentCol);
      glTranslatef (col,row,0);
      glScalef(scalex,scaley,1);
      glRasterPos2f(0,0);
      potentialincrease++;
	}
    text_it++;
  }
  if(gl_options.smooth_lines)
  {
	  glDisable(GL_LINE_SMOOTH);
  }
  glPopMatrix();

  
  GFXPopBlendMode();
  GFXColorf(this->col);
  return retval;
}
Exemple #15
0
void wmArrangeWindows(int w, int h)
{
  int i;
  int lbot, rbot, tleft, bleft;
  int lwidth;
  char *ch;
  
  mww=w;
  mwh=h;
  
  lbot=0;
  rbot=0;
  tleft=0;
  bleft=0;
  
  for (i=0;i<nWindows;i++) {
    lwidth=0;
    for (ch=ws[i].label;*ch;ch++)
      lwidth+=glutStrokeWidth(GLUT_STROKE_MONO_ROMAN,*ch)*0.1;
    
    switch (ws[i].side) {
      case WM_WINDOW_LEFT:
        ws[i].x=bsize;
        if (ws[i].y < 0) {
          ws[i].y=lbot;
        }
        ws[i].bx=0;
        ws[i].by=ws[i].y;
        ws[i].bw=bsize;
        ws[i].bh=ws[i].h;
        ws[i].blx=ws[i].bx+ws[i].bw*0.75;
        ws[i].bly=ws[i].by+(ws[i].bh+lwidth)/2;
        ws[i].blr=90;
        lbot+=ws[i].h;
        break;
      case WM_WINDOW_TOP:
        if (ws[i].x < 0) {
          ws[i].x=tleft;
        }
        ws[i].y=bsize;
        ws[i].bx=ws[i].x;
        ws[i].by=0;
        ws[i].bw=ws[i].w;
        ws[i].bh=bsize;
        ws[i].blx=ws[i].bx+(ws[i].bw-lwidth)/2;
        ws[i].bly=ws[i].by+ws[i].bh*0.75;
        ws[i].blr=0;
        tleft+=ws[i].w;
        break;
      case WM_WINDOW_RIGHT:
        ws[i].x=w-ws[i].w-bsize;
        if (ws[i].x < 0) {
          ws[i].y=rbot;
        }
        ws[i].bx=w-bsize;
        ws[i].by=ws[i].y;
        ws[i].bw=bsize;
        ws[i].bh=ws[i].h;
        ws[i].blx=ws[i].bx+ws[i].bw*0.75;
        ws[i].bly=ws[i].by+(ws[i].bh+lwidth)/2;
        ws[i].blr=90;
        rbot+=ws[i].h;
        break;
      case WM_WINDOW_BOTTOM:
        if (ws[i].x < 0) {
          ws[i].x=bleft;
        }
        ws[i].y=h-ws[i].h-bsize;
        ws[i].bx=ws[i].x;
        ws[i].by=h-bsize;
        ws[i].bw=ws[i].w;
        ws[i].bh=bsize;
        ws[i].blx=ws[i].bx+(ws[i].bw-lwidth)/2;
        ws[i].bly=ws[i].by+ws[i].bh*0.75;
        ws[i].blr=0;
        bleft+=ws[i].w;
        break;
      case WM_WINDOW_FLOAT:
        if (ws[i].x < 0) {
          ws[i].x=0;
        }
        if (ws[i].y < 0) {
          ws[i].y=bsize;
        }
        ws[i].bx=ws[i].x;
        ws[i].by=ws[i].y-bsize;
        ws[i].bw=ws[i].w;
        ws[i].bh=bsize;
        ws[i].blx=ws[i].bx+(ws[i].bw-lwidth)/2;
        ws[i].bly=ws[i].by+ws[i].bh*0.75;
        ws[i].blr=0;
        break;
    }
  }
}    
Exemple #16
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. */
}
/*
 * Class:     gruenewa_opengl_GLUT__
 * Method:    glutStrokeWidth
 * Signature: (II)I
 */
JNIEXPORT jint JNICALL Java_gruenewa_opengl_GLUT_00024_glutStrokeWidth
  (JNIEnv * jenv, jobject jobj, jint arg1, jint arg2) {
  return glutStrokeWidth((void*) arg1, arg2); 
}
Exemple #18
0
	inline GLfloat glutStrokeHeight ( void *font )
	{
		return 3*glutStrokeWidth(font, 'n');
	}