Thread: Text on Graphics screen

  1. #1
    Registered User
    Join Date
    Mar 2002

    Text on Graphics screen

    Nearing completion on a graduate C++ project (using borland C++ ver 3.1 ----a DOS version) that gprahically displays a graph algorithm (maximum flow). I've created structures that hold values of the verticies and edges. I would like to display them on the graphic screen during the execution of the program.
    Because most of the screen is taken up by the action of the graphics, I have only about a third of the screen on the right side of the screen to use for this. I am able to display the text using gotoxy( ), but am looking for a better way. Since these values are changing during the running of the program, they must be able to change dynamically. Any help would be appreciated.

  2. #2
    Registered User biosx's Avatar
    Join Date
    Aug 2001
    What graphics library are you using?

  3. #3
    Registered User
    Join Date
    Mar 2002
    I am using graphics.h

  4. #4
    Registered User biosx's Avatar
    Join Date
    Aug 2001
    outtextxy(int x, int y, char *string) does the trick

    I figure you can combine this with the getmaxx() and getmaxy() functions to make it change dynamically. Or you can write your own functions for that.

    Here is an example usage:
    #include <graphics.h>
    int main()
       int max_x, max_y;
       // initialize your graphics whatever way
       max_x = getmaxx();
       max_y = getmaxy();
       settextjustify(CENTER_TEXT, CENTER_TEXT);
       settextstyle(SANS_SERIF_FONT, HORIZ_DIR, 5);
       outtextxy(max_x/2, max_y/2, "Hello There");
       // Close your graphics whatever way
       return 0;
    That should display the text in the middle of the screen.

    Good luck

  5. #5
    Registered User
    Join Date
    Mar 2002

    Unhappy Text on Graphics screen updated

    I've posted a message a few days ago about putting text on a graphic screen using Borland C++ 3.1. Here's my problem:
    I've drawn an area on the screen (I am using graphics.h) using the following functions:

    setfillstyle(SOLID_FILL, BROWN);

    This puts up a box on the upper right side of the screen. I want to display text in the 3d box. The problem is that the text is not a string, but values from a structure. In another version of the program (a purely text version), I used cout to display the data on the screen like this:

    for (int z=0; z<num_vertices; z++)

    vertex[0] is an array.

    I've tried using outtextxy( ), but it only outputs a string. I want to write several lines in the box that display the current array values. As the program runs and the values change, I plan on redrawing over the 3d bar and re-writting the new text. Any suggestions?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DirectX | Drawing text
    By gavra in forum Game Programming
    Replies: 4
    Last Post: 06-08-2009, 12:23 AM
  2. Text adventure engine idea. thoughts?
    By suzakugaiden in forum Game Programming
    Replies: 16
    Last Post: 01-15-2006, 05:13 AM
  3. Graphics Devices and Cprintf clash
    By etnies in forum C Programming
    Replies: 6
    Last Post: 05-09-2002, 11:14 AM
  4. Moving to the next structure array
    By mattz in forum C Programming
    Replies: 2
    Last Post: 11-30-2001, 03:43 PM
  5. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 07:35 PM