   Printing Text To The Screen Wont Work...
  HI,I have a problem with Print Text To The Screen...I have all the code... I have all the error checking that I could thing of and nothing comes back.... Nothing will print to screen.... I get no Errors or Warnings... and the Error checking I set up with MessageBox()... No Message Box's coming up that mean every thing is running right..Will some one help me please!!!Thanks,AndrewHere is the code:   HDC g_HDC;unsigned int listBase1;int PrintOut = 1;int CreateBitmapFont(char *fontName, int fontSize, char Italic, char Underline, char Strikeout);void PrintString(unsigned int base, char* str);void ClearFont(unsigned int base);void Initialize() //This is called just not showen here{glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // clear to blackglShadeModel(GL_SMOOTH);glEnable(GL_DEPTH_TEST);}// Render//we do our drawing here...void Render(){glEnable(GL_POLYGON_SMOOTH);glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glLoadIdentity();glClearColor(0.0f, 0.0f, 0.0f, 0.0f);glTranslatef(0.0f, 0.0f, -1.0f); //Move one Unit to the ScreenglColor3f(1.0f, 1.0f, 1.0f); //Sets the color and makes the fade... glRasterPos2f(0.0f, 0.0f); //2D Screen Coords to where to put the text...    if (PrintOut == 1) PrintString(listBase1, "Lord of the Rings The Two Towers");if (PrintOut == 2)  PrintString(listBase1, "by...");    if (PrintOut == 3)  PrintString(listBase1, "Idahorazor (Davey Hutchision...)");  if (PrintOut == 4)  PrintString(listBase1, "and...");   if (PrintOut == 5)  PrintString(listBase1, "ComputerNerd8888 (Andrew Balmos)...");glFlush();SwapBuffers(g_HDC);}/////////////////////////////////////////////////////////////This is called only once////////////////////////////////listBase1 = CreateBitmapFont("Arial", //Change this to the name of the font you want to use...   20, //Font Size Here   FALSE, //True if you want Italic, FALSE if not...   FALSE, //True if you want Underline, FALSE if not...   FALSE  //True if you want Strikeout, FALSE if not...   );   if (!listBase1)   MessageBox(NULL, "Nothing In listBase1", NULL, MB_OK);//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////int CreateBitmapFont(char *fontName, int fontSize, char Italic, char Underline, char Strikeout) {HFONT hFont; //The Handle for the font....unsigned int base;HDC HdC;base = glGenLists(96);if (stricmp(fontName, "symbol") == 0){hFont = CreateFont(fontSize,0,0,0,FW_BOLD,Italic,Underline,Strikeout,SYMBOL_CHARSET,OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY,FF_DONTCARE | DEFAULT_PITCH,fontName    );} else {hFont = CreateFont(fontSize,0,0,0,FW_BOLD,Italic,Underline,Strikeout,ANSI_CHARSET,OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY,FF_DONTCARE | DEFAULT_PITCH,fontName    );   if (!hFont){    MessageBox(NULL, "Error On Loading Text", NULL, MB_OK); //Add any error thign you want here...    return 0;    }    SelectObject(g_HDC, hFont);wglUseFontBitmaps(g_HDC, 32, 96, base);return base;}}void PrintString(unsigned int base, char* str) {    if ((base == 0) || (str == NULL)){MessageBox(NULL, "Error On Loading Text", NULL, MB_OK);   return;}  glPushAttrib(GL_LIST_BIT);   glListBase(base - 32);   glCallLists(strlen(str), GL_UNSIGNED_BYTE, str);    glPopAttrib();    }void ClearFont(unsigned int base){    if (base != 0)   glDeleteLists(base, 96);}I believe that is every thing.... of course the window code is there ect...Thanks,Andrew[edited by - ComputerNerd888 on July 31, 2003 2:43:47 PM]
  If it prints at 0.0f, 0.0f, doesnt this mean either you wont see it, or it''ll get clipped and wont display? Try (-2.5f, 1.7f), that prints mine to the top left of the standard window.  ;  Nope it still wont work...THANKS FOR YOUR HELP THOUGH!!!!!!Andrew ;  learn to program c++ before opengl...if (PrintOut = 1) is not comparing, you are setting PrintOut equal to 1...if (PrintOut == 1) is correct. ;  I know C++!!! Dont Assome things... i had very limited time to write this pice of code... And you are going to go and insulate my over a little thing like that that can be easly missed...Still it dont even work!!!!!!Andrew   [edited by - ComputerNerd888 on July 30, 2003 12:15:18 AM];  It still will not work but I can not find anything wornge with it...Andrew ;  Try positioning your text as follows: glPushAttrib( GL_TRANSFORM_BIT | GL_VIEWPORT_BIT );glMatrixMode( GL_PROJECTION );glPushMatrix();glLoadIdentity();glMatrixMode( GL_MODELVIEW );glPushMatrix();glLoadIdentity();/*As y is flipped (0 at bottom) we subtract screen height. As font is placed from baseline, also account for that...*///assign the actual screen coord to y as we want to keepy m_y as the original valuey = g_screen_height - m_font_height - m_y;// Create a new viewport to draw into at position x, yglViewport( x - 1, y - 1, 0, 0 );//Position the text in the viewportglRasterPos4f( 0, 0, 0, 1 );glPopMatrix();glMatrixMode( GL_PROJECTION );glPopMatrix();glPopAttrib();as the viewport is positioned where we want the text, you just set raster pos at 0hope that worked for you   -----------------------"Without a sense of humour we couldn''t react to a lot of things" ;quote:Original post by ComputerNerd888  I know C++!!! Dont Assome things... i had very limited time to write this pice of code... And you are going to go and insulate my over a little thing like that that can be easly missed...Don''t feed the trolling AP...Not being very good at windows programming (I can''t practice it if I''m on linux now can I?) I can''t really help debug your code, but I can point out some good sources for doing the font stuff (using the windows fonts, and certain windows calls) for a nice font system:http://nehe.gamedev.net/lesson.asp?index=03specifically the 4th one there I think if I remember correct...sorry I can''t help more ;quote: /*As y is flipped (0 at bottom) we subtract screen height. As font is placed from baseline, also account for that...*///assign the actual screen coord to y as we want to keepy m_y as the original valuey = g_screen_height - m_font_height - m_y;Humm... I guess I am confused... The font height could be differnt for each charter....And what is m_y?Thanks,Andrew;quote:Original post by ComputerNerd888  I know C++!!! Dont Assome things... i had very limited time to write this pice of code... And you are going to go and insulate my over a little thing like that that can be easly missed...Still it dont even work!!!!!!Andrew   [edited by - ComputerNerd888 on July 30, 2003 12:15:18 AM]You can''t "know C++" in such a short time...Just a week or so ago you were posting on the GameTutorials Forum asking for help with simple things... I''ve been learning C++ about a month now. I know the basics and can write anything simple right off the top of my head. But C++ is a huge language...It takes years of practice to..."know C++". You may know the basics...but not the entire language. 