/* * Returns the width in pixels of a font's character */ int glutBitmapWidth( void* fontID, int character ) { SFG_Font* font = fghFontByID( fontID ); freeglut_return_val_if_fail( character > 0 && character < 256, 0 ); return *( font->Characters[ character - 1 ] ); }
/* * Draw a bitmap character */ void FGAPIENTRY glutBitmapCharacter( void* fontID, int character ) { const GLubyte* face; SFG_Font* font; FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapCharacter" ); font = fghFontByID( fontID ); freeglut_return_if_fail( ( character >= 1 )&&( character < 256 ) ); freeglut_return_if_fail( font ); /* * Find the character we want to draw (???) */ face = font->Characters[ character ]; glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT ); glPixelStorei( GL_UNPACK_SWAP_BYTES, GL_FALSE ); glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE ); glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 ); glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 ); glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 ); glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); glBitmap( face[ 0 ], font->Height, /* The bitmap's width and height */ font->xorig, font->yorig, /* The origin in the font glyph */ ( float )( face[ 0 ] ), 0.0, /* The raster advance -- inc. x,y */ ( face + 1 ) /* The packed bitmap data... */ ); glPopClientAttrib( ); }
/* * Return the width of a string drawn using a bitmap font */ int FGAPIENTRY glutBitmapLength( void* fontID, const unsigned char* string ) { unsigned char c; int length = 0, this_line_length = 0; SFG_Font* font; FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapLength" ); font = fghFontByID( fontID ); if (!font) { fgWarning("glutBitmapLength: bitmap font 0x%08x not found. Make sure you're not passing a stroke font.\n",fontID); return 0; } if ( !string || ! *string ) return 0; while( ( c = *string++) ) { if( c != '\n' )/* Not an EOL, increment length of line */ this_line_length += *( font->Characters[ c ]); else /* EOL; reset the length of this line */ { if( length < this_line_length ) length = this_line_length; this_line_length = 0; } } if ( length < this_line_length ) length = this_line_length; return length; }
/* * Return the width of a string drawn using a bitmap font */ int FGAPIENTRY glutBitmapLength( void* fontID, const unsigned char* string ) { unsigned char c; int length = 0, this_line_length = 0; SFG_Font* font; FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapLength" ); font = fghFontByID( fontID ); freeglut_return_val_if_fail( font, 0 ); if ( !string || ! *string ) return 0; while( ( c = *string++) ) { if( c != '\n' )/* Not an EOL, increment length of line */ this_line_length += *( font->Characters[ c ]); else /* EOL; reset the length of this line */ { if( length < this_line_length ) length = this_line_length; this_line_length = 0; } } if ( length < this_line_length ) length = this_line_length; return length; }
/* * Returns the height of a bitmap font */ int FGAPIENTRY glutBitmapHeight( void* fontID ) { SFG_Font* font; FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapHeight" ); font = fghFontByID( fontID ); freeglut_return_val_if_fail( font, 0 ); return font->Height; }
/* * Returns the width in pixels of a font's character */ int FGAPIENTRY glutBitmapWidth(void* fontID, int character) { SFG_Font* font = fghFontByID(fontID); if(character > 0 && character < 256) return *(font->Characters[ character - 1 ]); return 0; }
/* * Returns the width in pixels of a font's character */ int FGAPIENTRY glutBitmapWidth( void* fontID, int character ) { SFG_Font* font; FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapWidth" ); font = fghFontByID( fontID ); freeglut_return_val_if_fail( character > 0 && character < 256, 0 ); freeglut_return_val_if_fail( font, 0 ); return *( font->Characters[ character ] ); }
/* * Returns the height of a bitmap font */ int FGAPIENTRY glutBitmapHeight( void* fontID ) { SFG_Font* font; FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapHeight" ); font = fghFontByID( fontID ); if (!font) { fgWarning("glutBitmapHeight: bitmap font 0x%08x not found. Make sure you're not passing a stroke font.\n",fontID); return 0; } return font->Height; }
/* * Draw a bitmap character */ void FGAPIENTRY glutBitmapCharacterTex(void* fontID, int x, int y, int character) { #if (GL_OES_VERSION_1_1 >= 1) const GLubyte* face; SFG_Font* font = fghFontByID(fontID); GLint v[] = {0, 0, _INT2FIXED(64), _INT2FIXED(64)}; //face[0], font->Height}; GLubyte buff[64*64]; GLuint tid; if(!font) return; if(!(character >= 1)&&(character < 256)) return; /* * Find the character we want to draw (???) */ face = font->Characters[ character - 1 ]; memset(buff, 0, 64*64*sizeof(GLubyte)); BitsToBytes(face+1, face[0], font->Height, buff, 64, 64); glGenTextures(1, &tid); glBindTexture(GL_TEXTURE_2D, tid); glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 64, 64, 0, GL_ALPHA, GL_UNSIGNED_BYTE, buff); glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glEnable(GL_TEXTURE_2D); glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_ALPHA_TEST); glAlphaFuncx(GL_EQUAL, 0); glTexParameterxv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, v); glDrawTexxOES(_INT2FIXED(x), _INT2FIXED(y), _INT2FIXED(0), _INT2FIXED(16), _INT2FIXED(16)); //face[0], font->Height); glDisable(GL_ALPHA_TEST); glDisable(GL_TEXTURE_2D); glDeleteTextures(1, &tid); #endif }
/* * Returns the width in pixels of a font's character */ int FGAPIENTRY glutBitmapWidth( void* fontID, int character ) { SFG_Font* font; FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapWidth" ); freeglut_return_val_if_fail( character > 0 && character < 256, 0 ); font = fghFontByID( fontID ); if (!font) { fgWarning("glutBitmapWidth: bitmap font 0x%08x not found. Make sure you're not passing a stroke font.\n",fontID); return 0; } return *( font->Characters[ character ] ); }
void FGAPIENTRY glutBitmapString( void* fontID, const unsigned char *string ) { unsigned char c; float x = 0.0f ; SFG_Font* font; FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapString" ); font = fghFontByID( fontID ); if (!font) { fgWarning("glutBitmapString: bitmap font 0x%08x not found. Make sure you're not passing a stroke font.\n",fontID); return; } if ( !string || ! *string ) return; glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT ); glPixelStorei( GL_UNPACK_SWAP_BYTES, GL_FALSE ); glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE ); glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 ); glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 ); glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 ); glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); /* * Step through the string, drawing each character. * A newline will simply translate the next character's insertion * point back to the start of the line and down one line. */ while( ( c = *string++) ) if( c == '\n' ) { glBitmap ( 0, 0, 0, 0, -x, (float) -font->Height, NULL ); x = 0.0f; } else /* Not an EOL, draw the bitmap character */ { const GLubyte* face = font->Characters[ c ]; glBitmap( face[ 0 ], font->Height, /* Bitmap's width and height */ font->xorig, font->yorig, /* The origin in the font glyph */ ( float )( face[ 0 ] ), 0.0, /* The raster advance; inc. x,y */ ( face + 1 ) /* The packed bitmap data... */ ); x += ( float )( face[ 0 ] ); } glPopClientAttrib( ); }
/* * Changes the current menu's font */ void FGAPIENTRY glutSetMenuFont( int menuID, void* fontID ) { SFG_Font* font; SFG_Menu* menu; FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetMenuFont" ); menu = fgMenuByID( menuID ); freeglut_return_if_fail( menu ); if (fgState.ActiveMenus) fgError("Menu manipulation not allowed while menus in use."); font = fghFontByID( fontID ); if (!font) { fgWarning("glutChangeMenuFont: bitmap font 0x%08x not found. Make sure you're not passing a stroke font. Ignoring...\n",fontID); return; } fgStructure.CurrentMenu->Font = fontID; fghCalculateMenuBoxSize( ); }
void glutBitmapString( void* fontID, const unsigned char *string ) { int c; int numchar = strlen( string ); SFG_Font* font = fghFontByID( fontID ); float raster_position[ 4 ]; glGetFloatv ( GL_CURRENT_RASTER_POSITION, raster_position ); glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT ); glPixelStorei( GL_UNPACK_SWAP_BYTES, GL_FALSE ); glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE ); glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 ); glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 ); glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 ); glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); /* * Step through the string, drawing each character. * A newline will simply translate the next character's insertion * point back to the start of the line and down one line. */ for( c = 0; c < numchar; c++ ) if( string[c] == '\n' ) { raster_position[ 1 ] -= ( float )font->Height; glRasterPos4fv( raster_position ); } else /* Not an EOL, draw the bitmap character */ { const GLubyte* face = font->Characters[ string[ c ] - 1 ]; glBitmap( face[ 0 ], font->Height, /* Bitmap's width and height */ font->xorig, font->yorig, /* The origin in the font glyph */ ( float )( face[ 0 ] ), 0.0, /* The raster advance; inc. x,y */ ( face + 1 ) /* The packed bitmap data... */ ); } glPopClientAttrib( ); }
/* * Return the width of a string drawn using a bitmap font */ int glutBitmapLength( void* fontID, const unsigned char* string ) { int c, length = 0, this_line_length = 0; SFG_Font* font = fghFontByID( fontID ); int numchar = strlen( string ); for( c = 0; c < numchar; c++ ) { if( string[ c ] != '\n' )/* Not an EOL, increment length of line */ this_line_length += *( font->Characters[ string[ c ] - 1 ]); else /* EOL; reset the length of this line */ { if( length < this_line_length ) length = this_line_length; this_line_length = 0; } } if ( length < this_line_length ) length = this_line_length; return length; }
void FGAPIENTRY glutBitmapCharacterPoints(void* fontID, int x, int y, int character) { const GLubyte* face; SFG_Font* font = fghFontByID(fontID); if(!font) return; if(!(character >= 1)&&(character < 256)) return; face = font->Characters[ character - 1 ]; glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrthox(0, _INT2FIXED(fgStructure.Window->State.Width), 0, _INT2FIXED(fgStructure.Window->State.Height), 0, _INT2FIXED(1)); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glDisable(GL_DEPTH_TEST); glTranslatex(_INT2FIXED(x), _INT2FIXED(y), 0); __glutBitmapCharacter(font, character); glTranslatex(_INT2FIXED(face[0]), 0, 0); glEnable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); }
void FGAPIENTRY glutBitmapStringTex(void* fontID, int x, int y, const char *string) { SFG_Font* font = fghFontByID(fontID); int xx = x; int c, numchar = strlen((char*)string); if(!font) return; for(c = 0; c < numchar; c++) { if(string[c] == '\n') { xx = x; y -= font->Height; } else { glutBitmapCharacterTex(fontID, xx, y, string[c]); xx += *(font->Characters[ string[c] - 1 ]); } } }
void FGAPIENTRY glutBitmapStringPoints(void* fontID, int x, int y, const char *string) { SFG_Font* font = fghFontByID(fontID); int numchar, xx = 0, yy = 0, nbpoints = 0, i, c; GLshort *points; GLushort *indices; if(!font || !string) return; if(!string[0]) return; glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrthox(0, _INT2FIXED(fgStructure.Window->State.Width), 0, _INT2FIXED(fgStructure.Window->State.Height), 0, _INT2FIXED(1)); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glDisable(GL_DEPTH_TEST); glTranslatex(_INT2FIXED(x), _INT2FIXED(y), 0); numchar = (int)strlen((char*) string); points = (GLshort*)malloc(numchar * font->Height * (*(font->Characters[ 'X' - 1 ])) * 8 * sizeof(GLshort)); for(c = 0; c < numchar; c++) { if(string[c] == '\n') { yy -= font->Height; xx = 0; } else { const GLubyte* face = font->Characters[ string[c] - 1 ]; nbpoints += BitsToIndexedShorts(face+1, face[0], font->Height, points+(nbpoints*2), xx, yy); xx += face[0]; } } glEnable(GL_ALPHA_TEST); glAlphaFuncx(GL_NOTEQUAL, 0); indices = (GLushort*)malloc(nbpoints*sizeof(GLushort)); for(i = 0; i < nbpoints; i++) indices[i] = i; glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glEnableClientState (GL_VERTEX_ARRAY); glVertexPointer(2, GL_SHORT, 0, points); glDrawElements(GL_POINTS, nbpoints, GL_UNSIGNED_SHORT, indices); glDisable(GL_ALPHA_TEST); free(indices); free(points); glEnable(GL_DEPTH_TEST); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); }
/* * Returns the height of a bitmap font */ int FGAPIENTRY glutBitmapHeight(void* fontID) { SFG_Font* font = fghFontByID(fontID); return font->Height; }