[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3500
  • Last Modified:

Graphics in Borland C++ 5.02

I'm using Borland C++ 5.02. I have no experience with graphics. And I checked out the help file, and got an example for graphics


#include <graphics.h>
#include <io.h>
#include <fcntl.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <process.h>
#include <alloc.h>

main()
{
 void  *gothic_fontp; /* points to font buffer in memory */
 int handle;          /* file handle used for I/O */
   unsigned fsize;    /* size of file (and buffer) */

   int errorcode;
   int graphdriver;
   int graphmode;

     /* open font file */

   handle = open("GOTH.CHR", O_RDONLY|O_BINARY);
   if (handle == -1)
   {
     printf("unable to open font file 'GOTH.CHR'\n");
     exit(1);
   }
     /* find out size of the file */
   fsize = filelength(handle);
     /* allocate buffer */
   gothic_fontp = malloc(fsize);
   if (gothic_fontp == NULL)
   {
     printf("unable to allocate memory for font file 'GOTH.CHR'\n");
     exit(1);
   }
     /* read font into memory */
   if (read(handle, gothic_fontp, fsize) != fsize)

   {
     printf("unable to read font file 'GOTH.CHR'\n");
     exit(1);
   }
     /* close font file */
   close(handle);
     /* register font */
   if (registerfarbgifont(gothic_fontp) != GOTHIC_FONT)
   {
     printf("unable to register font file 'GOTH.CHR'\n");
     exit(1);
   }
     /* detect and initialize graphix */
   graphdriver = DETECT;
   initgraph(&graphdriver, &graphmode, "..");
   errorcode = graphresult();
   if (errorcode != grOk)
   {

     printf("graphics error: %s\n",grapherrormsg(errorcode));
     exit(1);
   }

   settextjustify(CENTER_TEXT, CENTER_TEXT);
   settextstyle(GOTHIC_FONT, HORIZ_DIR, 4);
   outtextxy(getmaxx()/2,getmaxy()/2, "Borland Graphics Interface (BGI)");
    /* press a key to terminate */
   getch();
    /* shut down graphics system */
   closegraph();
   return(0);
}


But i get an error :  BGI graphics not supported under windows
What should i do to make it work properly?
0
bijuabraham
Asked:
bijuabraham
2 Solutions
 
grg99Commented:
I'd forget about using the old BGI graphics...  BGI was barely passable under DOS.   And if you're writing a real windows 32-bit application, in it you're not allowed to write directly to the screen buffer, so BGI is impossible.

Real windows graphics are about 10,000% spiffier.  



0
 
DawafflemanCommented:
to make it work you should compile it as a console program with the -tC (target console) switch and then start in dos and see if it works.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now