Results 1 to 9 of 9

Thread: two questions concerning fonts and glClear

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2002
    Location
    Swansea, Wales, UK
    Posts
    20

    two questions concerning fonts and glClear

    Hi!

    I am programming a project in C++ with OpenGL and have been using the nehe.gamedev.net tutorials as a basis for my code. I have been having a couple of difficulties and would appreciate help with them please!

    Firsty, I have 4 buttons on my screen at the moment (these are basically 4 quads and I am detecting where the mouse is clicked). On clicking on the topmost 3 buttons the user should be taken to a new screen (a different screen for each one). However, I do not have a different screen I am going to totally change my current screen instead. At the moment I am trying to get the top button working. The main screen has a black background and the screen which the top button leads to has a white background. My problem is that when I click on this button when the program is running, nothing happens. I have a variable, called screen, which refers to which screen the user is on.
    This is my DrawGLScene function:

    int DrawGLScene(GLvoid) //Here's Where We Do All The Drawing
    {
    switch (screen)
    {
    case 0:
    {
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    ........ then some text and quad code

    return 0;
    }
    case 1:
    {
    glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();

    return 0;
    }
    }
    return TRUE; //Everything Went OK
    }

    The idea being that at the moment I just want to check that it is clearing the screen when the mouse is clicked. I know that the mouse code is correct as I am able to exit the program by clicking on the bottom button.


    My second problem is that I am unsure how to use more than one different font in my program. I used the NeHe font tutorial and can now easily put text on the screen with one font but am not sure how to change the fonts as it seems to link the font to the hDC.

    If anyone can help with either or both of these problems I would be very grateful!

    Thanks
    Gareth

  2. #2
    Member Contributor
    Join Date
    Feb 2002
    Location
    Wiesbaden, Germany
    Posts
    95

    Re: two questions concerning fonts and glClear

    Hi,

    if you are using the 3D-Font-Example, all you have to do is to setup a display list for each font. Then it should work fine. I will have a look at the 2D-Font stuff in a second, then I will post again.

    Cheers,

    Martin

  3. #3
    Member Contributor
    Join Date
    Feb 2002
    Location
    Wiesbaden, Germany
    Posts
    95

    Re: two questions concerning fonts and glClear

    Hi again,

    from my point of view this should be solved with two display lists to. I'm out of office at the moment, but thursday I will be home, by then I will have a closer look at this. If you haven't solved all this by then send me a mail.


    Cheers,

    Martin

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,633

    Re: two questions concerning fonts and glClear

    Regarding problem 1:
    You sure swap buffers after drawing? And you sure draw at least after every mouse event?
    Add something like this to your DrawScene to help you track it down:
    Code :
    new global variables:
    int screen0=0;
    int screen1=0;
    ...
    in drawing funtion:
     
    switch(screen)
    {
    case(0):
       ++screen0;
       //your stuff
    case(1):
       ++screen1;
       //your stuff
    }
    Then you can log screen0 and screen1 at shutdown and see how often you went through the rendering of screen 0 and screen 1 respectively. If both numbers are very small, you're not continuously redrawing. If the sum of both is smaller than the amount of mouse events+ a few (maybe 1 ), you're not redrawing after mouse events.
    If you do sufficient redraws and screen1 is still zero even though you click on the right button, your mouse event handler is broken.

  5. #5
    Junior Member Newbie
    Join Date
    Mar 2002
    Location
    Swansea, Wales, UK
    Posts
    20

    Re: two questions concerning fonts and glClear

    Hurrah, I've got the fonts working. Thanks for your help on that one Martin

    now to work on this glClear problem...

  6. #6
    Junior Member Newbie
    Join Date
    Mar 2002
    Location
    Swansea, Wales, UK
    Posts
    20

    Re: two questions concerning fonts and glClear

    zeckensack - thanks for your help, good idea. my current problem is that I don't know how to look at the value of a variable after the program has ended
    sorry for my newbie-ness!

    please help!

    Gareth
    <><

  7. #7

    Re: two questions concerning fonts and glClear

    Write the variable to a log file, say log.txt. Then inspect the log file for the value of the variable. As long as the file is closed before the program terminates, you are OK. I think that is what Zeckensack suggested.

  8. #8
    Senior Member OpenGL Pro
    Join Date
    Dec 2007
    Posts
    1,077

    Re: two questions concerning fonts and glClear

    Run the application in debug-mode and put a breakpoint at the end of the program. In my eyes that is the most comfortable way.

  9. #9
    Junior Member Newbie
    Join Date
    Mar 2002
    Location
    Swansea, Wales, UK
    Posts
    20

    Re: two questions concerning fonts and glClear

    Thanks. I used JP's log.txt idea and the value for screen0 was 315 and the value for screen1 was 0 even tho I did click on the case 1 button.
    Thanks, now I know where the problem is, sort of!

    Gareth
    <><

Similar Threads

  1. Nehe lesson 43 questions (freetype fonts)
    By wwuster in forum OpenGL: Advanced Coding
    Replies: 10
    Last Post: 12-30-2009, 07:48 AM
  2. glClear for FBO
    By V-man in forum OpenGL: Advanced Coding
    Replies: 11
    Last Post: 06-25-2007, 06:29 PM
  3. glClear()
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-22-2005, 10:51 PM
  4. bitmap fonts vs texture fonts
    By ehsan2004 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-31-2005, 03:24 AM
  5. Questions on TrueType fonts
    By MickeyMouse in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 06-09-2003, 04:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean