How to get simple graphics in TP 6.0 ?? 
Author Message
 How to get simple graphics in TP 6.0 ??


Quote:

>What is this "grDriver := detect;" business? I'm running vanilla VGA.
>Why can't the darn program simply show a line on the screen?

A well written program does not assume that the card is a VGA. Instead
it tests the card. The testing can be done two ways: by setting detect
as the value of the variable that has the graphics driver:

gd:=detect;
initgraph(gd,gm,getenv('bgi'));

or by using detectgraph:

detectgraph(gd,gm);
initgraph(gd,gm,getenv('bgi'));

If you want to support only one or some specific cards then the latter
is better as you can test the card before it goes to graphics mode.

You can test for example:

if gd<>VGA then runerror(255);

after the detectgraph.

Quote:

>Any help in setting up this InitGraph (grDriver, grMode, ' ' );  stuff
>would be greatly appreciated!

Note that you should not assume anything about where the drivers are,
especially you should not assume that they are in a directory named
space, like on your case. A better way is to provide the place with an
environment variable like BGI above. If the variable is not set then
default directory will be used. You could also search for the driver
with either fsearch or recursively with findfirst/findnext. (remember
uses dos)

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 How to get simple graphics in TP 6.0 ??
Quote:

> Thanks,

> Sorry to bother you all, but I changed my program to say:

> {*******************************************************************************
> *
>                       Main program begins here
> ********************************************************************************
> }
> BEGIN
>   DirectVideo := false;
>   ClrScr;
>   grDriver := Detect;
>   InitGraph (grDriver, grMode, Getenv('bgi'));
>   ErrCode := GraphResult;
>   if ErrCode = grOk then
>   begin
>      Greeting (client);
> ****************************
> etc.
> **************************
> and now when I try to run it I get the message:

> Graphics error: Invalid device drive file (EGAVGA.BGI)

> Any suggestions appreciated!

I'm not sure (anymore) but shouldn't you give grMode a certain variable?

Though it's true what Osmo says that you shouldn't hardcode the graphics stuff I
always did so, assuming a program whas run on a VGA-compatible system. That way
I could just link in the EGAVGA-driver and set the graphics mode as I wished.
Not very nice for those with no VGA 8-(. Anyway, that's what my SMGRAF-unit (you
mentioned downloading it) does.

Good luck,

Remco



Wed, 18 Jun 1902 08:00:00 GMT  
 How to get simple graphics in TP 6.0 ??
In comp.lang.Pascal.borland,  uttered:

Quote:
>Thanks.

>>I'm not sure (anymore) but shouldn't you give grMode a certain variable?

>I don't know. I have no idea what grMode is or does. The only reference to
>it, that I can find in the Borland manuals (p75 Library Reference TP6.0), is
>in a bit of code that is the example for InitGraph procedure.  grMode is
>initialised as Integer, then appears once in the line:

>InitGraph(grDriver, grMode, '');

>Anybody know more about it?

grMode allows you to set other than the highest resolution your graphics
card is capable of.

For a full list of the constants see the help file
graph.tpu --> constants and types --> graphics mode for each driver

--
Pedt Scragg

No-one is completely useless, they can always be a bad example.



Wed, 18 Jun 1902 08:00:00 GMT  
 How to get simple graphics in TP 6.0 ??


Quote:

>I hadn't bother to notice it, but it looks like, because you don't give the
>variable any value it's just a dummy, _until_ you DO give it some value. But
>whether it defaults to the highest possible value and how it does I don't know.
>I've always used driver #9 (VGA) and most of the time I'd use mode 2 (640x480).
>I've done _some_ things in the other modes (0-640x200 and 1-640x350) because of
>the virtual pages. I've always had to control these values for the things I made
>(small graphics games). So never bothered with "detect".

That is very bad programming. One should always detect the hardware.
Assuming that it is what it is not could at worst destroy the monitor.
(No, not in this case, but [ like assuming that CGA or MDA is Hercules
could cause such problems)

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 How to get simple graphics in TP 6.0 ??

Quote:



> >I hadn't bother to notice it, but it looks like, because you don't give the
> >variable any value it's just a dummy, _until_ you DO give it some value. But
> >whether it defaults to the highest possible value and how it does I don't know.
> >I've always used driver #9 (VGA) and most of the time I'd use mode 2 (640x480).
> >I've done _some_ things in the other modes (0-640x200 and 1-640x350) because of
> >the virtual pages. I've always had to control these values for the things I made
> >(small graphics games). So never bothered with "detect".

> That is very bad programming. One should always detect the hardware.
> Assuming that it is what it is not could at worst destroy the monitor.
> (No, not in this case, but [ like assuming that CGA or MDA is Hercules
> could cause such problems)

> Osmo

I had to think this one over for a couple of days.
Of course you are right. It is very bad programming. I've been fooled into
thinking it should work by looking at the wrong examples - intro and demo-stuff
etc. - mostly in modeX or mode13h were nobody bothered about hardware...
As you so gently pointed out I'm using hazardous constructions, which is typical
for the uneducated programmer (which I am).
I don't want to be responsible for any damage to anybody's hardware, so I'll
remove all the stuff from my webpage. Thanks for pointing this out.

Regards,

Remco



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 12 post ] 

 Relevant Pages 

1. Question: Backward compatibility TP 7.0 & TP 6.0

2. Q: Incompatibilities between TP 6.0 and TP 7.0

3. TP 6.0 Source -> TP 7.0 Error

4. Help: adapting graphics from TP DOS to TP Windows

5. TCP/IP with DOS and TP 6.0 ?

6. TP 6.0 Sound

7. TP 6.0 TPU to 7.0 without original source?

8. TP 6.0 Manual/Help File

9. trig1.zip TP 6.0 trigonometry and math functions TPU, S.O'Malley

10. TP 6.0, NT Workstation and didappearing mouse

11. TP 6.0 Compiler: Out of memory

12. convert UNITS form TP 6.0 to 7.0

 

 
Powered by phpBB® Forum Software