for (int i = x; i < x + width; i++ ) {
videoPtr = (char far *) MK_FP (pageBase, (i » 2)+y*80); writeReg ( EGA_SEQUENCER, EGA_MAP_MASK, 1 « (i & 3 ));
for (int j = 0; j < height; j++, videoPtr += 80 )
* videoPtr = * dataPtr++;
}
}
void drawString (int x, int y, char * str, int color)
for (; *str != \0'; str++, x+= 8 )
for (int j = 0; j < 16;j++)
{
char byte = font [16 * (*str) + j];
for (int i = 0; i < 8; i++, byte «= 1 ) if ( byte & 0x80 )
writePixel (x+i, y+j, color);
> >
main ()

ерная графика. Полигональные модели

if (IfindVGA ()) {
printf ("\nVGA compatible card not found."); return -1;
}
void *buf = malloc( 100*50 );
if ( buf == NULL ) t
v
printf ( Yimalloc failure."); return -1;
}
setX (); // set 320x200 256 colors X-mode
font = findROMFont ( 16 );
for (int i = 0; i < 256; i++ )
writePixel (i, 0, i);
for (i = 5; i < 140; i++ )
bar(2*i,i,2*i+30, i+30, i);
getlmage ( 1, 1, 100, 50, buf); drawstring (110, 100, "Page 0", 70 ); getch ();
setActivePage ( 1 ); setVisualPage (1 ); bar ( 10, 20, 300,200, 33 ); drawString ( 110, 100, "Page 1", 75 ); getch ();
setActivePage (2 ); setVisualPage (2 ); bar ( 10, 20, 300, 200, 39 ); drawString ( 110, 100, "Page 2", 80 ); getch ();
setActivePage ( 3 ); setVisualPage ( 3 ); bar ( 10, 20, 300,200,44 ); drawString ( 110, 100, "Page 3M, 85 ); getch ();
setVisualPage ( 0 ); setActivePage (0 ); getch ();
putlmage ( 151, 3, 100, 50, buf); getch ();
setVisualPage ( 1 ); getch ();
setVisualPage (2 ); getch ();
setVideoMode ( 3 );

4. Работа с основными графическими устройствами Опишем процедуры, устанавливающие этот режим с нестандартными разреше-ми 320 на 240 пикселов и 360 на 480 пикселов.

// File example3.cpp #include <alloc.h> #include <conio.h> #include <mem.h> #jnclude <stdio.h> #include "Ega.h"
unsigned pageBase = 0;
jnt bytesPerLine;
char leftPlaneMask 0 = {OxOF, OxOE, OxOC, 0x08 };
char hghtPlaneMask [] = {0x01, 0x03, 0x07, OxOF };

⇐ Предыдущая| |Следующая ⇒