Text on Graphics screen

This is a discussion on Text on Graphics screen within the C++ Programming forums, part of the General Programming Boards category; Nearing completion on a graduate C++ project (using borland C++ ver 3.1 ----a DOS version) that gprahically displays a graph ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    7

    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
    Posts
    230
    What graphics library are you using?

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

  4. #4
    Registered User biosx's Avatar
    Join Date
    Aug 2001
    Posts
    230
    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:
    Code:
    #include <graphics.h>
    
    int main()
    {
       int max_x, max_y;
    
       // initialize your graphics whatever way
    
       max_x = getmaxx();
       max_y = getmaxy();
    
       setcolor(BLUE);
       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
    Posts
    7

    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);
    bar3d(450,200,600,50,20,1);

    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++)
    cout<<"vertex["<<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, 01: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, 12:14 PM
  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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21