* videoPtr-- = picData [fixed2lnt ( u ) + (fixed2lnt ( v ) « widthShift)];
u = ( u - du ) & widthMask; v = ( v - dv ) & heightMask;
}
videoPtr += 160;
for ( col = 160, u = uO, v = vO; col < 320; col++ ) {
u = ( u + du ) & widthMask; v = ( v + dv ) & heightMask;
* videoPtr++ = picData [ fixed2lnt ( u ) + (fixed2lnt ( v ) « widthShift)];
}
}
}
void setVideoMode (int mode ) {
asm {
mov ax, mode int 10h
}
}
void setPalette ( RGB * palette ) {
for (int i = 0; i < 256; i++ ) // convert from 8-bit to { //6-bit values
palette [i].red »= 2;
palette [ij.green »= 2;
palette [ij.blue »= 2;

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

asm { // really load palette via BIOS
push es mov ax, 1012h
mov bx, 0 // first color to set
mov cx, 256 // # of colors
les dx, palette // ES.DX == table of color values
int 10h popes
}
}
void initTables () {
initFixMath ();
for (int i = 0; i < SCREENJHEIGHT / 2; i++ )
distTable [i] = float2Fixed ( DO / ((i + 1 ) * DELTA )) » 8; for (i = 0; i < 1024; i++ )
{
float x = i * 64.0 * M_PI / 32768;
CSinTable [i] = (long)( C * 65536.0 * sin ( x )); CCosTable [i] = (long)( C * 65536.0 * cos ( x ));
}
}
void draw (int x, int y, char * data, int w ) {
for (int i = 0; i < w; i++ ) for (int j = 0; j < w; j++ )
*(screenPtr + x + i + (y+j)*320) = data [i+j*w];
}
main () {
int done = 0;
angle = 0; locX =0; locY = 0;
setVideoMode (0x13 ); setPalette ( pic -> palette ); initTables ();
draw ( 0, 0, pyr -> data, 64 ); draw ( 70, 0, pyr -> data + pyr -> offs [1], 32 ); draw (110, 0, pyr -> data + pyr -> offs [2], 16 ); draw ( 130, 0, pyr -> data + pyr -> offs [3], 8 ); draw ( 150, 0, pyr -> data + pyr -> offs [4], 4 ); draw ( 160, 0, pyr -> data + pyr -> offs [5], 2 ); draw ( 170, 0, pyr -> data + pyr -> offs [6], 1 ); bioskey ( 0 );
int start = clock ();
while ( Idone ) {

13. Элементы виртуальной реальности

drawView (); if ( bioskey (1 ))

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