Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Free Pascal + initgraph goes ape

NordquistNordquist Member Posts: 49

grDriver := Detect;
InitGraph(grDriver,grMode,'');
ErrCode := GraphResult;
if ErrCode<>grOk then halt(1);

That's my "initgraph"-code. I've worked with pascal in school for about two months now, and in school we use TurboP and a procedure included in a home-made unit. Instead of writing those four lines of code, we just type:
GraphicStart;
and it works well.

At home I use Free Pascal, and I don't have this unit we use in school so I made the procedure myself: these 4 lines of code above.

[Wow... that was alot of explaining before I've even got to the problem... Well, here's the problem...]

-->> After compiling my Pong-clone and running the exe, I get 2 windows (I'm using WinME, maybe this is the problem?). One is titled 'Pong', just like it should, but doesn't contain anything else than the output I got before calling initgraph.
The other window pops up when initgraph is called, and my drawings (circle, rectangle and such) appears and look well.

The worst thing is that this new window can't catch any input from the keyboard, the other CAN!
In order to play I have to select the old window, move it aside so I can see the play-area (the new window) beneath, and THEN steer the objects with the keys. If I only have the new 'graph'-window selected nothing happens when I press the keys.

FINISHED!
Lot's of text just to explain one little problem, I know.

So, what I wan't is just ONE WINDOW! Everything printed in the same window!
Any help is appreciated!

Comments

  • NordquistNordquist Member Posts: 49
    grDriver := Detect;
    InitGraph(grDriver,grMode,'');
    ErrCode := GraphResult;
    if ErrCode<>grOk then halt(1);

    Don't know if this extra bit of info is needed to solve the problem, but here goes...

    Both grDriver and grMode is declared integer variables, just as I've read it should be.
    You see that grDriver assumes a value (I don't know which and I don't care), but grMode hasn't been set to anything at all since it was declared.
    Maybe something is missing here...

Sign In or Register to comment.