예제 #1
0
void drawText ( const char *str, int fontNumber )
{
  unsigned columns = 0;
  const unsigned8 *fptr;
  unsigned8 high;

  switch ( fontNumber )
  {
  case 1:
    fptr = fontB8x16;
    high = (unsigned8)( sizeof(fontB8x16)/16 - 1 );
    break;
  default:
    fptr = fontA8x16;
    high = (unsigned8)( sizeof(fontA8x16)/16 - 1 );
  }

  while ( *str )
  {
    unsigned8 ch = (unsigned8)( *str++ );

    if ( ch == '\n' )
    {
      glBitmap( 0, 0, 0.0f, 0.0f, columns * -8.0f, -16.0f, fptr );
      columns = 0;
      continue;
    }

    if ( ch > high )
      ch = ' ';

    glBitmap( 8, 16, 0.0f, 0.0f, 8.0f, 0.0f, fptr + (((unsigned)ch) << 4) );
    columns++;
  }
}
예제 #2
0
파일: bitmaps.c 프로젝트: 1272371/Academics
void display( void )
{
 glClear(GL_COLOR_BUFFER_BIT);     /*clear the window */
 glMatrixMode(GL_MODELVIEW);       /* The following coordinates are expressed */
 glLoadIdentity();                 /* in terms of World coordinates */
 int X = 9, Y = 0;
 
 GLubyte bitShapeA[8] = {0x84 ,0x84,0x84,0x78 ,0x48, 0x48,0x30,0x30 };
 GLubyte bitShapeB[8] = {0x78 ,0x48,0x48,0x78 ,0x48, 0x48,0x78 };
 GLubyte bitShapeC[8] = {0x78 ,0x82,0x80,0x80 ,0x80, 0x42,0x38 };
 GLubyte bitShapeD[8] = {0x70 ,0x48,0x44,0x44,0x44, 0x44,0x48,0x70 };
 GLubyte bitShapeE[8] = {0x7c ,0x40,0x40,0x78,0x78, 0x40,0x40,0x7c };
// GLubyte bitShapel[8] = {0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10};
// GLubyte bitShapeA[8] = {0x00,0x40,0x42,0x2d,0x24,0x14,0x18,0x18};
 //GLubyte bitShapeL[16] = {0x800 ,0x400,0x400,0x200 ,0x100, 0x080,0x080,0x040,0x020,0x010,0x010,0x008,0x004,0x002,0x002,0x001 };
 glPixelStorei (GL_UNPACK_ALIGNMENT,1); 
 glRasterPos2i(50,50);
 glColor3f(1.0, 0.0, 0.0);
 glBitmap (6,8, 0.0, 0.0, X, Y, bitShapeA); 
 glBitmap (6,8, 0.0, 0.0, X, Y, bitShapeB);                    
  glBitmap (6,8, 0.0, 0.0, X, Y, bitShapeC); 
glBitmap (6,8, 0.0, 0.0, X, Y, bitShapeD);                    
glBitmap (6,8, 0.0, 0.0, X, Y, bitShapeE);                   
 glFlush();                       /* send all commands */
}
예제 #3
0
/* Place the light's OpenGL light number next to the light's sphere.  To
   ensure a readable number with good contrast, a black version of the number 
   is drawn shifted a pixel to the left and right of the actual white number. 
 */
void
labelLight(LightInfo * info, int num)
{
  GLubyte nothin = 0;
  void *font = GLUT_BITMAP_HELVETICA_18;
  int width = glutBitmapWidth(font, '0' + num);

  glPushMatrix();
  glColor3f(0.0, 0.0, 0.0);
  glRasterPos3f(info->xyz[0], info->xyz[1], info->xyz[2]);
  glBitmap(1, 1, 0, 0, 4, 5, &nothin);
  glutBitmapCharacter(font, '0' + num);

  glBitmap(1, 1, 0, 0, 2 - width, 0, &nothin);
  glutBitmapCharacter(font, '0' + num);

  if (lightState[num]) {
    glColor3fv(white);
  } else {
    /* Draw disabled lights dimmer. */
    glColor3fv(dim);
  }
  glRasterPos3f(info->xyz[0], info->xyz[1], info->xyz[2]);
  glBitmap(1, 1, 0, 0, 5, 5, &nothin);
  glutBitmapCharacter(font, '0' + num);
  glPopMatrix();
}
예제 #4
0
파일: font.cpp 프로젝트: Chiasung/Webcam
void
FontPrintf(GLFONT     *font,   /* I - Font to use */
           int        align,   /* I - Alignment to use */
           const char *format, /* I - printf() style format string */
           ...)                /* I - Other arguments as necessary */
{
    va_list       ap;          /* Argument pointer */
    const char    s[1024]="a",     /* Output string */
                  *ptr;        /* Pointer into string */
    /*int*/GLfloat    width;       /* Width of string in pixels */

    if (font == (GLFONT *)0 || format == (char *)0)
        return;

    /* Format the string */
    va_start(ap, format);
    vsprintf_s((char *)s, 1024, format, ap);
    va_end(ap);

    /* Figure out the width of the string in pixels... */
    for (ptr = s, width = 0; *ptr; ptr ++)
        width += font->widths[*ptr];

    /* Adjust the bitmap position as needed to justify the text */
    if (align < 0)
        glBitmap(0, 0, 0, 0, -width  , 0, NULL);
    else if (align == 0)
        glBitmap(0, 0, 0, 0, -width / 2, 0, NULL);

    /* Draw the string */
    FontPuts(font, s);
}
예제 #5
0
void glMakeRasterFont(void)
{
    GLuint i, j;
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);  
    glShadeModel (GL_FLAT);
    fontOffset = glGenLists (128);
    
    for (i = 0,j = 'A'; i < 26; i++,j++) {
        glNewList(fontOffset + j, GL_COMPILE);
        glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, letters[i]);
        glEndList(); }
    
    for (i = 0,j = 'a'; i < 26; i++,j++) {
        glNewList(fontOffset + j, GL_COMPILE);
        glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, lowletters[i]);
        glEndList(); }
    
    for (i = 0,j = '0'; i < 16; i++,j++) {
        glNewList(fontOffset + j, GL_COMPILE);
        glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, numletters[i]);
        glEndList(); }
    
    for (i = 0,j = ' '; i < 16; i++,j++) {
        glNewList(fontOffset + j, GL_COMPILE);
        glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, specialletters[i]);
        glEndList(); }
    glShadeModel (GL_SMOOTH);
}
예제 #6
0
파일: drawf.c 프로젝트: roymuste/Qt
static void display(void) {
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0,1.0,1.0);
    glRasterPos2i(20,20);
    glBitmap(10,12,0.0,0.0,11.0,0.0,rasters);
    glBitmap(10,12,0.0,0.0,11.0,0.0,rasters);
    glBitmap(10,12,0.0,0.0,11.0,0.0,rasters);
    glFlush();
}
예제 #7
0
void FTPixmapGlyph::RenderFunctionName(const FT_Vector& pen,
                                       const FTGLRenderContext *)
{
  // Move the glyph origin
  glBitmap( 0, 0, 0.0, 0.0, (float)(pen.x + pos.x), (float)(pen.y - pos.y), (const GLubyte *)0);
  
  glDrawPixels( destWidth, destHeight, GL_RGBA, GL_UNSIGNED_BYTE, (const GLvoid*)data);

  // Restore the glyph origin
  glBitmap( 0, 0, 0.0, 0.0, (float)(-pen.x - pos.x), (float)(-pen.y + pos.y), (const GLubyte *)0);
}
예제 #8
0
void FTBitmapGlyph::RenderFunctionName(const FT_Vector& pen,
                                       const FTGLRenderContext *)
{
  // Move the glyph origin
  glBitmap( 0, 0, 0.0, 0.0, (float)(pen.x + pos.x), (float)(pen.y - pos.y), (const GLubyte *)0 );

  glBitmap( destWidth, destHeight, 0.0f, 0.0, 0.0, 0.0, (const GLubyte *)data);

  // Restore the glyph origin
  glBitmap( 0, 0, 0.0, 0.0, (float)(-pen.x - pos.x), (float)(-pen.y + pos.y), (const GLubyte *)0 );
}
예제 #9
0
파일: 01_textF.c 프로젝트: c14006078/opengl
void drawTextF(void) {
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0, 1.0, 1.0);
    
    glWindowPos2i(20, 20);
    //glRasterPos2i(20, 20);				//glRasterPos* function has been depreacted in openGL 3.0? so the current raster location is invalid, then glBitmap will draw nothing. 
    glBitmap(10, 12, 0.0, 0.0, 11.0, 0.0, rasters);
    glBitmap(10, 12, 0.0, 0.0, 11.0, 0.0, rasters);
    glBitmap(10, 12, 0.0, 0.0, 11.0, 0.0, rasters);

    glFlush();
}
예제 #10
0
const FTPoint& FTPixmapGlyph::Render( const FTPoint& pen) {
	glBitmap( 0, 0, 0.0f, 0.0f, pen.X() + pos.X(), pen.Y() - pos.Y(), (const GLubyte*)0);
	
	if( data) {
		glPixelStorei( GL_UNPACK_ROW_LENGTH, 0);
		glPixelStorei( GL_UNPACK_ALIGNMENT, 2);
		
		glDrawPixels( destWidth, destHeight, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, (const GLvoid*)data);
	}
	glBitmap( 0, 0, 0.0f, 0.0f, -pos.X(), pos.Y(), (const GLubyte*)0);
	return advance;
}
예제 #11
0
파일: Tag.cpp 프로젝트: play113/swer
void CTag::glCommands(bool select, bool marked, bool no_color)
{
	if(marked)
	{
		glColor3ub(0, 0, 0);
		glRasterPos2dv(m_pos);
		glBitmap(16, 5, 8, 3, 10.0, 0.0, bmp16);

		glColor3ub(0, 0, 255);
		glRasterPos2dv(m_pos);
		glBitmap(16, 16, 8, 8, 10.0, 0.0, cross16);
	}
}
예제 #12
0
float FTBitmapGlyph::Render( const FTPoint& pen)
{
    if( data)
    {
        glBitmap( 0, 0, 0.0, 0.0, pen.x + pos.x, pen.y - pos.y, (const GLubyte*)0 );

        glPixelStorei( GL_UNPACK_ROW_LENGTH, destPitch * 8);
        glBitmap( destWidth, destHeight, 0.0f, 0.0, 0.0, 0.0, (const GLubyte*)data);

        glBitmap( 0, 0, 0.0, 0.0, -pen.x - pos.x, -pen.y + pos.y, (const GLubyte*)0 );
    }
    
    return advance;
}
예제 #13
0
파일: fg_font.c 프로젝트: Downfy/liquidfun
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( );
}
예제 #14
0
void makeRasterFont(void)
{
   GLuint i, j;
   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

   fontOffset = glGenLists (128);
   for (i = 0,j = 'A'; i < 26; i++,j++) {
      glNewList(fontOffset + j, GL_COMPILE);
      glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, letters[i]);
      glEndList();
   }
   glNewList(fontOffset + ' ', GL_COMPILE);
   glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, space);
   glEndList();
}
예제 #15
0
void HPoint::glCommands(bool select, bool marked, bool no_color)
{
	if(!no_color){
		wxGetApp().glColorEnsuringContrast(color);
	}
	GLfloat save_depth_range[2];
	if(marked){
		glGetFloatv(GL_DEPTH_RANGE, save_depth_range);
		glDepthRange(0, 0);
	}
	else if(!m_draw_unselected)
	{
		glBegin(GL_POINTS);
		glVertex3d(m_p.X(), m_p.Y(), m_p.Z());
		glEnd();
		return;
	}


	glRasterPos3d(m_p.X(), m_p.Y(), m_p.Z());
	glBitmap(16, 16, 8, 8, 10.0, 0.0, marked ? cross16_selected : cross16);
	if(marked){
		glDepthRange(save_depth_range[0], save_depth_range[1]);
	}
}
예제 #16
0
static void Bitmap(void)
{

    glBegin(GL_LINES);
	SetColor(COLOR_GREEN);
	glVertex2i(-boxW/2, 0);
	glVertex2i(boxW/2, 0);
	glVertex2i(0, -boxH/2);
	glVertex2i(0, boxH/2);
	SetColor(COLOR_RED);
	glVertex2i(0, -3);
	glVertex2i(0, -3+OPENGL_HEIGHT);
	SetColor(COLOR_BLUE);
	glVertex2i(0, -3);
	glVertex2i(OPENGL_WIDTH, -3);
    glEnd();

    SetColor(COLOR_GREEN);

    glPixelStorei(GL_UNPACK_LSB_FIRST, GL_TRUE);
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

    glRasterPos2i(0, 0);
    glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, 0, 3, 0.0, 0.0, OpenGL_bits);
}
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::printString(const char * s)
{
  int i,n;
  n = strlen(s);
  for (i = 0; i < n; i++)
    glBitmap(8, 12, 0.0, 2.0, 10.0, 0.0, fps2dfont[s[i] - 32]);
}
예제 #18
0
void layprop::DrawProperties::draw_reference_marks(const TP& p0, const binding_marks mark_type) const
{
   GLubyte* the_mark;
   switch (mark_type) {
      case  cell_mark:if (_cellmarks_hidden) return;
                      else
                      {
                         glColor4f(1.0, 1.0, 1.0, 0.8);
                         the_mark = cell_mark_bmp;
                         break;
                      }
      case array_mark:if (_cellmarks_hidden) return;
                      else
                      {
                         glColor4f(1.0, 1.0, 1.0, 0.8);
                         the_mark = array_mark_bmp;
                         break;
                      }
      case  text_mark:if (_textmarks_hidden) return;
                      else the_mark = text_mark_bmp;break;
      default: assert(false);
   }
   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
   glRasterPos2i(p0.x(),p0.y());
   glBitmap(16,16,7,7,0,0, the_mark);
}
예제 #19
0
파일: bitmap2.c 프로젝트: medusade/mxde
static void Init(void)
{
    GLint i;

    if (!rgb) {
	glutSetColor(0, 0.0, 0.0, 0.0);
	glutSetColor(1, 1.0, 0.0, 0.0);
	glutSetColor(2, 0.0, 1.0, 0.0);
	glutSetColor(3, 1.0, 1.0, 0.0);
	glutSetColor(4, 0.0, 0.0, 1.0);
	glutSetColor(5, 1.0, 0.0, 1.0);
	glutSetColor(6, 0.0, 1.0, 1.0);
	glutSetColor(7, 1.0, 1.0, 1.0);
    }

    glClearColor(0.0, 0.0, 0.0, 0.0);
    glClearIndex(0.0);

    glPixelStorei(GL_UNPACK_LSB_FIRST, GL_TRUE);
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    for (i = 0; i < 7; i++) {
	exp_lists[i] = glGenLists(1);
	glNewList(exp_lists[i], GL_COMPILE);
	glBitmap(80, 80, 40.0, 40.0, 0.0, 0.0, exp_bits[i]);
	glEndList();
    }

    abuse = GL_FALSE;
    useLists = GL_TRUE;
}
예제 #20
0
파일: showfps.c 프로젝트: ghub/NVprSDK
static void drawFPS(double fpsRate)
{
  GLubyte dummy;
  char buffer[200], *c;

  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
    glLoadIdentity();
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
      glLoadIdentity();
      glOrtho(0, 1, 1, 0, -1, 1);
      //glDisable(GL_DEPTH_TEST);
      glColor3fv(textColor);
      glRasterPos2f(1,1);
      glBitmap(0, 0, 0, 0, -10*9, 15, &dummy);
      if (fpsRate > 0 || !validFPS) {
        sprintf(buffer, "fps %0.1f", fpsRate);
      } else {
        strcpy(buffer, "fps --");
      }
      for (c = buffer; *c != '\0'; c++)
        glutBitmapCharacter(GLUT_BITMAP_9_BY_15, *c);
      //glEnable(GL_DEPTH_TEST);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
  glPopMatrix();
}
예제 #21
0
//------------------------------------------------------------------------------
// Font loader -- loads the font
//------------------------------------------------------------------------------
void BitmapFont::loadFont()
{
    if (isLoaded())
        return;

    setBase( glGenLists(256) );

    // Loop through the font map
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    for (unsigned int i=0; i < numFonts; i++)
    {
        GLubyte* bitmap = loadTypeFace(i, reverse);
        if (bitmap == 0) continue;

        GLfloat xmove = GLfloat(getBitmapWidth());
        GLfloat ymove = 0.0;

        glNewList(getBase()+i, GL_COMPILE);
        glBitmap(getBitmapWidth(), getBitmapHeight(), 0.0, 0.0, xmove, ymove, bitmap);
        glEndList();

        delete[] bitmap;
    }
    setFontLoaded();
}
예제 #22
0
/*
 * 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( );
}
예제 #23
0
    void glDrawString(const char * myText, const BitFont & font) {
        // Save current modes
        glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);

        // Set new mode
        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);

        for (const unsigned char * b = (unsigned char *) myText; *b != '\0'; b++) {
            if (*b < font.first || *b >= font.first + font.num_chars) {
                continue;
            }

            const BitChar * ch = font.ch[*b - font.first];

            if (ch) {
                // finally draw
                glBitmap(ch->width, ch->height, ch->xorig, ch->yorig,
                         ch->advance, 0, ch->bitmap);
            }
        }

        glPopClientAttrib();
    }}
예제 #24
0
파일: ex19.c 프로젝트: jchan1e/graphics
/*
 *  Load pattern from RLE file
 */
void LoadPattern(char* file)
{
   FILE* f;         //  File
   char  ch;        //  Character read
   int   x0=0;      //  Starting line position
   int   x,y;       //  Current position
   int   dx,dy;     //  Pattern size
   int   k=0;       //  Repeat count
   char  rule[256]; //  Rule string

   //  Open file
   f = fopen(file,"r");
   if (!file) Fatal("Cannot open %s\n",file);
   //  Skip header (starts with #)
   for (ch=fgetc(f) ; ch=='#' ; ch=ReadLine(f));
   ungetc(ch,f);
   //  Check header line
   if (fscanf(f," x = %d , y = %d , rule = %s",&dx,&dy,rule)!=3) Fatal("Error reading header line from %s\n",file);
   if (strcmp("B3/S23",rule)) Fatal("Only rule B3/S23 implemented (%s)\n",rule);
   warn = (dx>W || dy>H);
   //  Center pattern
   x0 = x = (dx<W) ? (W-dx)/2 : 0;
   y = H-1-(dy<H ? (H-dy)/2 : 0);
   //  Read pattern from file
   for (ch=ReadLine(f) ; ch!='!' && ch!=EOF ; ch=fgetc(f))
   {
      //  Live cell(s)
      if (ch=='o')
      {
         //  k==0 => one
         if (k<=0) k = 1;
         //  Draw k live cells in a row
         for (;k>0;k--)
         {
            GLubyte dot[] = {0xFF};
            glWindowPos2i(x++,y);
            glBitmap(1,1,0,0,0,0,dot);
         }
      }
      //  Dead cell(s)
      else if (ch=='b')
      {
         x += (k?k:1);
         k = 0;
      }
      //  End of Line
      else if (ch=='$')
      {
         y -= (k?k:1);
         x = x0;
         k = 0;
      }
      //  Repeat count
      else if (isdigit(ch))
         k = 10*k+(ch-'0');
   }
   // Done
   fclose(f);
}
예제 #25
0
void set_pos(int x, int y) {
    if (x < 0 || y < 0) {
        glWindowPos2i(0, 0);
        glBitmap(0, 0, 0, 0, x, y, NULL);
    } else {
        glWindowPos2i(x, y);
    }
}
예제 #26
0
void GLGraphics2D::drawTextImpl(float  ox, float  oy, char const* str)
{
	assert( mFont );
	glColor4ub( mColorFont.r , mColorFont.g , mColorFont.b , mAlpha );
	glRasterPos2i(0, 0);
	glBitmap(0, 0, 0, 0, ox , -oy , NULL);
	mFont->print( str );
}
예제 #27
0
const FTPoint& FTBitmapGlyphImpl::RenderImpl(const FTPoint& pen, int renderMode)
{
    if(data)
    {
        float dx, dy;

        dx = pen.Xf() + pos.Xf();
        dy = pen.Yf() - pos.Yf();

        glBitmap(0, 0, 0.0f, 0.0f, dx, dy, (const GLubyte*)0);
        glPixelStorei(GL_UNPACK_ROW_LENGTH, destPitch * 8);
        glBitmap(destWidth, destHeight, 0.0f, 0.0, 0.0, 0.0,
                 (const GLubyte*)data);
        glBitmap(0, 0, 0.0f, 0.0f, -dx, -dy, (const GLubyte*)0);
    }

    return advance;
}
예제 #28
0
//这里进行所有的绘图工作
void SceneShow(GLvoid)        
{
	glClear(GL_COLOR_BUFFER_BIT);	// 清空颜色缓冲区
	glColor3f(1.0, 0.0, 0.0);


	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);       // Pixel Storage Mode (Word Alignment / 4 Bytes)
	glRasterPos2f (0, 0);
	glBitmap (10, 12, 0.0, 0.0, 11.0, 0.0, rasters);
	glBitmap (10, 12, 0.0, 0.0, 11.0, 0.0, rasters);

	glWindowPos2i(0, 0);
	glBitmap (10, 12, 0.0, 0.0, 11.0, 0.0, rasters);
	glBitmap (10, 12, 0.0, 0.0, 11.0, 0.0, rasters);
	glBitmap (10, 12, 0.0, 0.0, 11.0, 0.0, rasters);

	glFlush();
}  
예제 #29
0
파일: graphics.c 프로젝트: huettner94/TTT
void drawImage() {
	int i = 0;
	int j = 0;

	glPixelStoref(GL_UNPACK_ALIGNMENT, 1);
	glClear(GL_COLOR_BUFFER_BIT);
	glColor3f(1.0, 1.0, 1.0);
	glPixelZoom(1.0, -1.0);
	glBitmap(0, 0, 0, 0, info->width*0.5, info->height+lines*15+19, NULL);
	if (info->bpp/8 == 3) {
		glDrawPixels(info->width, info->height, GL_RGB, GL_UNSIGNED_BYTE, image);
	} else {
		glDrawPixels(info->width, info->height, GL_LUMINANCE, GL_UNSIGNED_BYTE, image);
	}
	glBitmap(0, 0, 0, 0, -info->width*0.5, -info->height-lines*15-19, NULL);

	glBegin(GL_LINES); //Border left
	 glVertex2f(info->width*0.5, lines*15+19);
	 glVertex2f(info->width*0.5, info->height+lines*15+19);
	glEnd();
	glBegin(GL_LINES); //Border bottom
	 glVertex2f(info->width*0.5-1, lines*15+19);
	 glVertex2f(info->width*1.5+1, lines*15+19);
	glEnd();
	glBegin(GL_LINES); //Border right
	 glVertex2f(info->width*1.5+1, lines*15+19);
	 glVertex2f(info->width*1.5+1, info->height+lines*15+19);
	glEnd();
	glBegin(GL_LINES); //Border top
	 glVertex2f(info->width*0.5-1, info->height+lines*15+19);
	 glVertex2f(info->width*1.5+1, info->height+lines*15+19);
	glEnd();

	do {
		glRasterPos2f(info->width*0.1, (lines-1-i)*15+10);
		for (j = 0; j < 27 && (i*27+j < (int)strlen(text)); j++) {
			glutBitmapCharacter(GLUT_BITMAP_9_BY_15, text[i*27+j]);
		}
		i++;
	} while (i <= ((int)strlen(text))/27);
	glRasterPos2f(0,0);

	glFlush();
}
예제 #30
0
void makeRasterFont(void)
{
	GLuint i;
	GLuint j;

	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
	/* initial buffer of font list */
	fontOffset = glGenLists(LETTER_BUFFER_SIZE); 
	/* fill bitmap of font into letter buffer list */
	for(i = 0, j = 'A'; i < 26; i++, j++)
	{
		glNewList(fontOffset + j, GL_COMPILE);
		glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, letters[i]);
		glEndList();
	}
	glNewList(fontOffset + ' ', GL_COMPILE);
	glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0,space);
	glEndList();
}