|
|||||||
Home
Books
SimTel
C/C++
|
Home / C Tutorials SciTech MGL 4.05 Step by step Written by Ryan Wahle Tuesday, May 25, 1999 In this tutorial, this will show you how to make a program that will display the words "Hi Dorks" on the screen. It was a program that I wrote for my friends about 2-3 weeks ago when I just started learning MGL. :)
Step 1
#include <mgraph.h>
Step 2
int main (void) { MGLDC *dc; event_t evt;
Step 3 int driver = grDETECT; int mode = grDETECT; MGL_registerDriver(MGL_VGA4NAME, VGA4_driver); MGL_init (&driver, &mode, ".");
Step 4
dc = MGL_createDisplayDC(1); MGL_makeCurrentDC(dc);
Step 5
MGL_setColorCI(MGL_RED);
Step 6
MGL_lineCoord(x1, y1, x2, y2); Now the coord 0,0 starts in the upper left hand corner of your screen. If you have ever taken algebra, you will know about the graph system. There are essentially four parts to a 2D graph. We will be using quadrant 4 of the graph. (I may be wrong, but who cares). But there is only one problem. All points in quadrant 4 are negative. That's fine though. Just take the negative signs off and forget they were even there. :)
Step 7>
// H MGL_lineCoord(20,20,20,40); MGL_lineCoord(20,30,30,30); MGL_lineCoord(30,20,30,40); // I MGL_lineCoord(40,20,40,40); // D MGL_lineCoord(25,60,25,80); MGL_lineCoord(25,60,35,60); MGL_lineCoord(35,60,40,70); MGL_lineCoord(40,70,35,80); MGL_lineCoord(35,80,25,80); // O MGL_lineCoord(50,60,60,60); MGL_lineCoord(60,60,60,80); MGL_lineCoord(60,80,50,80); MGL_lineCoord(50,80,50,60); // R MGL_lineCoord(70,60,70,80); MGL_lineCoord(70,60,80,60); MGL_lineCoord(80,60,80,70); MGL_lineCoord(80,70,70,70); MGL_lineCoord(70,70,80,80); // K MGL_lineCoord(90,60,90,80); MGL_lineCoord(100,60,90,70); MGL_lineCoord(90,70,100,80); // S MGL_lineCoord(120,60,110,65); MGL_lineCoord(110,65,120,75); MGL_lineCoord(120,75,110,80); Step 8 Since we displayed the words "Hi Dorks", we want our friends to see this before it disappears so we can all get a good laugh. He we send this command to halt the program until an event of a keydown occurs. This will pretty much just wait until a key has been pressed. We will learn more on events later.
EVT_halt (&evt, EVT_KEYDOWN);
Step 9
MGL_exit(); return 0; }
Finishing Up See ya |
This Article Installation Configuration Step by step Move bitmaps Troubleshooting
Downloads
See Also
NetLinks
|
|||||
Next:
Move bitmaps around the screen
|