Thread: can't show font no errors

  1. #1
    Registered User
    Join Date
    May 2017
    Posts
    2

    can't show font no errors

    my system:
    linux debian7 32bit (C language not C++)

    After dozens of tutorial sites, I think this font string should work, yet it will not.
    I don't get any terminal errors and I can not open it.

    Could you please fix my code.
    I'm a struggling noob,
    Please help me.

    Code:
    /* gcc myFont.c -l glut -o myFont */
    #include <GL/glut.h>
    
    void display()
    {
      glClearColor(0.8, 0.8, 0.8, 0.0);     // gray background
      glClear( GL_COLOR_BUFFER_BIT );
    
      glColor3f(0.0, 0.0, 0.0);             // black text
      glutBitmapString(GLUT_BITMAP_HELVETICA_18, 10, 10, "HELLO TODAY");
    
      glFlush();
    }
    
    int main( int argc, char **argv )
    {
      glutInit( &argc, argv );
      glutInitWindowSize( 200,200 );
      glutInitWindowPosition (100, 100);
      glutCreateWindow( "myFont" );
      glutDisplayFunc( display );
      glutMainLoop();
      return 0;
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well calling the function with made up parameters can't help.
    glutbitmapstring(3) - Linux man page

    As mentioned here, as well as the manual page, you need to set the raster position.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    May 2017
    Posts
    2
    May I express my gratitude for your time and help.
    Also by mistake, I learned that order is important.
    glColor3f
    glRasterPos2i
    glutBitmapString
    It fixed my black font rendering as white problem.
    I enjoy learning C code so much.
    Thanks again

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 10-04-2015, 07:32 AM
  2. Replies: 14
    Last Post: 07-01-2011, 12:29 PM
  3. show() method does not show...
    By kocika73 in forum C++ Programming
    Replies: 12
    Last Post: 04-09-2006, 09:27 PM
  4. font & font color in edit control
    By XRIC++ in forum Windows Programming
    Replies: 2
    Last Post: 10-27-2003, 09:07 PM

Tags for this Thread