This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's Calculator Programming subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. General Coding and Design => Calculator Programming
Author Message
JoeImp
Enlightened


Active Member


Joined: 24 May 2003
Posts: 747

Posted: 06 Nov 2003 03:14:28 pm    Post subject:

For use with opengl. I included a sample program that uses this at the very bottom. Include glut.h and glu32.lib in source file, and include this as Fonts.h:


Code:
/*
                FONTS.h
   Font File so far complete with 5 fonts.
   
   Note:

  For the speed paramter in each function,
  enter how long you want each letter to take
  to be placed. If you want every letter down
  at once like regular print, enter 0.0. Enter 1.0
  for 1 sec, 2.0 for 2 sec, etc.

   Examples:

   8 by 13: (One Size Only)
   Font8by13Text(int xpos, int ypos, float speed, char message[50]);
   Font8by13Text(-50, 0, 1.0, "8 By 13!");

   9 by 15 (One Size Only)
   Font9by15Text(int xpos, int ypos, float speed, char message[50]);
   Font9by15Text(-50, 0, 0.5, "9 By 15!");

   Helvetica: (Sizes are 10,12,18)
   FontHelveticaText(int xpos, int ypos, int size, float speed, char message[50]);
   FontHelveticaText(-100,0,10, 0.0, "Helvetica!");

    Times Roman: (Sizes are 10,24)
   FontTimesRoman(int xpos, int ypos, int size, float speed, char message[50]);
   FontTimesRoman(-100,20,24, 0.3, "Times Roman!");

    IceFont: (Sized best at 16x16)
    (Enter 0.0, 0.0 for xbo and ybo most of the time.)
    (xbi & ybi are how much the x/y values are
       incremented after each letter.)
    (Usually xbi = (width + 2.0), and 0.0 for ybi.)
   FontIce(int xpos, int ypos, int width, int height, float xbo, float ybo, float xbi, float ybi, float speed, char message[50]);
   FontIce(-100,84,16,16,0.0,0.0,17.0,0.0, 0.5, "ICE FONT");

*/

// 8 By 13 Start

void Font8by13Text(int xpos,int ypos, float speed, char message[50])
{
   speed *= 1000.0;
   glRasterPos2i(xpos,ypos);
   for (unsigned int place = 0; place <= (strlen(message)); place++)
   {glutBitmapCharacter(GLUT_BITMAP_8_BY_13,message[place]);Sleep(speed);glutSwapBuffers();}
}

// 9 by 15 Start

void Font9by15Text(int xpos, int ypos, float speed, char message[50])
{
   speed *= 1000.0;
   glRasterPos2i(xpos,ypos);
   for (unsigned int place = 0; place <= (strlen(message)); place++)
   {glutBitmapCharacter(GLUT_BITMAP_9_BY_15,message[place]);Sleep(speed);glutSwapBuffers();}
}

// Helvetica Start

void FontHelveticaText(int xpos, int ypos, int size, float speed, char message[50])
{
   speed *= 1000.0;
   glRasterPos2i(xpos,ypos);
   if (size = 10)
   {
  for (unsigned int place = 0; place <= (strlen(message)); place++)
  {glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, message[place]);Sleep(speed);glutSwapBuffers();}
   }
   if (size == 12)
   {
  for (unsigned int place = 0; place <= (strlen(message)); place++)
  {glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, message[place]);Sleep(speed);glutSwapBuffers();}
   }
   if (size == 18)
   {
  for (unsigned int place = 0; place <= (strlen(message)); place++)
  {glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, message[place]);Sleep(speed);glutSwapBuffers();}
   }
   if ((size != 10) & (size != 12) & (size != 18))
   {
  message = "Parameter Error";
  for (unsigned int place = 0; place <= (strlen(message)); place++)
  {glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,message[place]);}
   }
}

// Times Roman Start

void FontTimesRomanText(int xpos, int ypos, int size, float speed, char message[50])
{
   speed *= 1000.0;
   glRasterPos2i(xpos,ypos);
   if (size == 10)
   {
  for (unsigned int place = 0; place <= (strlen(message)); place++)
  {glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_10, message[place]);Sleep(speed);glutSwapBuffers();}
   }
   
   if (size == 24)
   {
  for (unsigned int place = 0; place <= (strlen(message)); place++)
  {glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, message[place]);Sleep(speed);glutSwapBuffers();}
   }
   if ((size != 10) & (size != 24))
   {
  message = "Parameter Error";
  for (unsigned int place = 0; place <= (strlen(message)); place++)
  {glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_10,message[place]);}
   }
}

// IceFont Start

GLubyte rasterA[] =
{0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xFF,0xFF
,
 0xFF,0xFF,0xC0,0x03,0xC0,0x03,0x60,0x06,0x30,0x0C,0x18,0x18,0x0C,0x30,0x07,0xE0}
;
GLubyte rasterB[] =
{0x7F,0x3F,0xFF,0xFE,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x06
,
 0xFF,0x3F,0xC0,0x06,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xFF,0xFE,0x7F,0x3F}
;
GLubyte rasterC[] =
{0x1F,0xFF,0x7F,0xFF,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00
,
 0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x7F,0xFF,0x1F,0xFF}
;
GLubyte rasterD[] =
{0xFF,0x1F,0xE0,0x0C,0xC0,0x06,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03
,
 0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x06,0xE0,0x0C,0xFF,0x1F}
;
GLubyte rasterE[] =
{0xFF,0xFF,0xFF,0xFF,0xC0,0x01,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xE0,0x00,0xFF,0xFF
,
 0xFF,0xFF,0xE0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xFF,0xFF,0xFF,0xFF}
;
GLubyte rasterF[] =
{0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00
,
 0xE0,0x00,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0xC0,0x00,0xE0,0x00,0xFF,0xFF,0xFF,0xFF}
;
GLubyte rasterG[] =
{0x1F,0xFF,0x7F,0xFF,0x60,0x07,0xC0,0x03,0xC0,0x03,0xC3,0x03,0xC3,0xFF,0xC0,0x00
,
 0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xE0,0x00,0x7F,0xFF,0x1F,0xFF}
;
GLubyte rasterH[] =
{0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xE0,0x07,0xFF,0xFF
,
 0xFF,0xFF,0xE0,0x07,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03}
;
GLubyte rasterI[] =
{0xFF,0xFF,0xFF,0xFF,0x03,0xC0,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80
,
 0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x03,0xC0,0xFF,0xFF,0xFF,0xFF}
;
GLubyte rasterJ[] =
{0x1F,0xFF,0x38,0x07,0x60,0x03,0xE0,0x03,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00
,
 0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xE0,0x00}
;
GLubyte rasterK[] =
{0xC0,0x30,0xC0,0x60,0xC0,0xC0,0xC1,0x80,0xC3,0x00,0xC6,0x00,0xCC,0x00,0xF8,0x00
,
 0xF0,0x00,0xD8,0x00,0xCC,0x00,0xC6,0x00,0xC3,0x00,0xC1,0x80,0xC0,0xC0,0xC0,0x60}
;
GLubyte rasterL[] =
{0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00
,
 0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00}
;
GLubyte rasterM[] =
{0xC1,0x83,0xC1,0x83,0xC1,0x83,0xC1,0x83,0xC1,0x83,0xC1,0x83,0xC1,0x83,0xC1,0x83
,
 0xC1,0x83,0xC1,0x83,0xC1,0x83,0xC1,0x83,0xC1,0x83,0xE3,0xC7,0xFF,0xFF,0xFF,0xFF}
;
GLubyte rasterN[] =
{0xC0,0x07,0xC0,0x0F,0xC0,0x1B,0xC0,0x33,0xC0,0x33,0xC0,0x63,0xC0,0xC3,0xC0,0xC3
,
 0xC1,0x83,0xC3,0x03,0xC3,0x03,0xC6,0x03,0xCC,0x03,0xCC,0x03,0xD8,0x03,0xF0,0x03}
;
GLubyte rasterO[] =
{0xFF,0xFF,0xFF,0xFF,0xE0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03
,
 0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xE0,0x07,0xFF,0xFF,0xFF,0xFF}
;
GLubyte rasterP[] =
{0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xFF,0xFF
,
 0xFF,0xFF,0xE0,0x07,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xE0,0x07,0xFF,0xFF,0xFF,0xFF}
;
GLubyte rasterQ[] =
{0x00,0x03,0x00,0x06,0xFF,0xFE,0xE0,0x3C,0xC0,0x6C,0xC0,0xCC,0xC0,0x0C,0xC0,0x0C
,
 0xC0,0x0C,0xC0,0x0C,0xC0,0x0C,0xC0,0x0C,0xC0,0x0C,0xE0,0x1C,0xFF,0xFC,0xFF,0xFC}
;
GLubyte rasterR[] =
{0xC0,0x1C,0xC0,0x30,0xC0,0xE0,0xC1,0x80,0xC7,0x00,0xCC,0x00,0xF8,0x00,0xF0,0x00
,
 0xFF,0xFF,0xFF,0xFF,0xE0,0x07,0xC0,0x03,0xC0,0x03,0xE0,0x07,0xFF,0xFF,0xFF,0xFF}
;
GLubyte rasterS[] =
{0xFF,0xFF,0xFF,0xFF,0x00,0x07,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x07,0xFF,0xFF
,
 0xFF,0xFF,0xE0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xE0,0x00,0xFF,0xFF,0xFF,0xFF}
;
GLubyte rasterT[] =
{0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80
,
 0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x03,0xC0,0xFF,0xFF,0xFF,0xFF}
;
GLubyte rasterU[] =
{0xFF,0xFF,0xFF,0xFF,0xE0,0x07,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03
,
 0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03}
;
GLubyte rasterV[] =
{0x01,0x80,0x03,0xC0,0x03,0xC0,0x06,0x60,0x06,0x60,0x0C,0x30,0x0C,0x30,0x18,0x18
,
 0x18,0x18,0x30,0x0C,0x30,0x0C,0x60,0x06,0x60,0x06,0xC0,0x03,0xC0,0x03,0xC0,0x03}
;
GLubyte rasterW[] =
{0xFF,0xFF,0xFF,0xFF,0xE3,0xC7,0xC1,0x83,0xC1,0x83,0xC1,0x83,0xC1,0x83,0xC1,0x83
,
 0xC1,0x83,0xC1,0x83,0xC1,0x83,0xC1,0x83,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03}
;
GLubyte rasterX[] =
{0x60,0x06,0x30,0x0C,0x18,0x18,0x0C,0x30,0x06,0x60,0x06,0x60,0x03,0xC0,0x01,0x80
,
 0x01,0x80,0x03,0xC0,0x06,0x60,0x06,0x60,0x0C,0x30,0x18,0x18,0x30,0x0C,0x60,0x06}
;
GLubyte rasterY[] =
{0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80
,
 0x01,0x80,0x01,0x80,0x03,0xC0,0x06,0x60,0x0C,0x30,0x18,0x18,0x30,0x0C,0x60,0x06}
;
GLubyte rasterZ[] =
{0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x60,0x00,0x30,0x00,0x1C,0x00,0x06,0x00,0x03,0x00
,
 0x01,0xC0,0x00,0x60,0x00,0x30,0x00,0x1C,0x00,0x06,0x00,0x03,0xFF,0xFF,0xFF,0xFF}
;
GLubyte rasterSPACE[] =
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
;

void FontIceText(int xpos, int ypos, int width, int height, float xbo, float ybo,
        float xbi, float ybi, float speed, char message[50])
{
   speed *= 1000.0;
   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
   glRasterPos2i(xpos, ypos);
   unsigned int place = 0;
   for (place; place <= (strlen(message)); place++)
   {
  Sleep(speed);
  glutSwapBuffers();
  switch (message[place])
  {
  case 'A':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterA);break;
  case 'B':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterB);break;
  case 'C':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterC);break;
  case 'D':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterD);break;
  case 'E':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterE);break;
  case 'F':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterF);break;
  case 'G':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterG);break;
  case 'H':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterH);break;
  case 'I':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterI);break;
  case 'J':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterJ);break;
  case 'K':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterK);break;
  case 'L':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterL);break;
  case 'M':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterM);break;
  case 'N':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterN);break;
  case 'O':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterO);break;
  case 'P':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterP);break;
  case 'Q':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterQ);break;
  case 'R':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterR);break;
  case 'S':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterS);break;
  case 'T':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterT);break;
  case 'U':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterU);break;
  case 'V':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterV);break;
  case 'W':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterW);break;
  case 'X':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterX);break;
  case 'Y':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterY);break;
  case 'Z':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterZ);break;
  case ' ':glBitmap(width, height, xbo, ybo, xbi, ybi, rasterSPACE);break;
  }
   }
}



SOURCE FILE EXAMPLE:
Note: Change your includes around!

Example.cpp:


Code:
// Existing Includes
#include <windows.h>
#include <iostream.h>
#include <stdio.h>
// Project Includes
#include "Includes/GL/glut.h"
#include "Includes/Fonts/Fonts.h"

void RenderScene()
{
   glOrtho(-100.0,100.0,-100.0,100.0,100.0,-100.0);
   glClearColor(0.0,0.0,0.0,1.0);
   glClear(GL_COLOR_BUFFER_BIT);
   glColor3f(1.0,0.0,0.0);

   FontHelveticaText(-100,80,12, .08, "Look At All My Fonts -");
   FontTimesRomanText(-100,60,10, .1, "Times Roman 10");
   FontHelveticaText(-100,40,10, .07, "Helvetica 10");
   FontHelveticaText(-100,20,12, .1, "Helvetica 12");
   FontHelveticaText(-100,0,18, .1, "Helvetica 18");
   Font8by13Text(-100,-20, .09, "8by13");
   Font9by15Text(-100,-40, .1, "9by15");
   FontTimesRomanText(-100,-60,24, .09, "Times Roman 24");
   FontIceText(-100,-85,16,16,0.0,0.0,18.0,0.0, .1, "ICEFONT");

   glutSwapBuffers();   
}

void main()
{
   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
   glutCreateWindow("Font.h Testing");
   glutDisplayFunc(RenderScene);
   glutMainLoop();
}
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement