Advertisement
thecplusplusguy

OpenGL (SDL,C++) - 3d text rendering - text.cpp

Oct 14th, 2011
1,599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. /*3d text rendering - text.cpp*/
  2. #include "text.h"
  3.  
  4. void text::drawText(vector3d pos,vector3d rot,const char* tex)
  5. {
  6.     glPushMatrix();
  7.         glTranslatef(pos.x,pos.y,pos.z);
  8.         glRotatef(rot.x,1,0,0);
  9.         glRotatef(rot.y,0,1,0);
  10.         glRotatef(rot.z,0,0,1);
  11.         int g=0;
  12.         for(int i=0;i<strlen(tex);i++)
  13.         {
  14.             if(tex[i]=='\n')
  15.             {
  16.                 glTranslatef(-g*width,-height,0);
  17.                 g=0;
  18.                 continue;
  19.             }
  20.             g++;
  21.             glCallList(characters.at((int)tex[i]-65));
  22.             glTranslatef(width,0,0);
  23.         }
  24.     glPopMatrix();
  25. }
  26.  
  27. text::text(float w,float h,std::vector<unsigned int>& ch)
  28. {
  29.     width=w;
  30.     height=h;
  31.     characters=ch;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement