亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? t3dlib1.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
?? 第 1 頁 / 共 5 頁
字號:
       // adjust the error term
       error+=dy2;

       // move to the next pixel
       vb_start+=x_inc;

       } // end for

   } // end if |slope| <= 1
else
   {
   // initialize error term
   error = dx2 - dy; 

   // draw the line
   for (index=0; index <= dy; index++)
       {
       // set the pixel
       *vb_start = color;

       // test if error overflowed
       if (error >= 0)
          {
          error-=dy2;

          // move to next line
          vb_start+=x_inc;

          } // end if error overflowed

       // adjust the error term
       error+=dx2;

       // move to the next pixel
       vb_start+=y_inc;

       } // end for

   } // end else |slope| > 1

// return success
return(1);

} // end Draw_Line

///////////////////////////////////////////////////////////

int Draw_Line16(int x0, int y0, // starting position 
                int x1, int y1, // ending position
                int color,     // color index
                UCHAR *vb_start, int lpitch) // video buffer and memory pitch
{
// this function draws a line from xo,yo to x1,y1 using differential error
// terms (based on Bresenahams work)

int dx,             // difference in x's
    dy,             // difference in y's
    dx2,            // dx,dy * 2
    dy2, 
    x_inc,          // amount in pixel space to move during drawing
    y_inc,          // amount in pixel space to move during drawing
    error,          // the discriminant i.e. error i.e. decision variable
    index;          // used for looping

int lpitch_2 = lpitch >> 1; // USHORT strided lpitch

// pre-compute first pixel address in video buffer based on 16bit data
USHORT *vb_start2 = (USHORT *)vb_start + x0 + y0*lpitch_2;

// compute horizontal and vertical deltas
dx = x1-x0;
dy = y1-y0;

// test which direction the line is going in i.e. slope angle
if (dx>=0)
   {
   x_inc = 1;

   } // end if line is moving right
else
   {
   x_inc = -1;
   dx    = -dx;  // need absolute value

   } // end else moving left

// test y component of slope

if (dy>=0)
   {
   y_inc = lpitch_2;
   } // end if line is moving down
else
   {
   y_inc = -lpitch_2;
   dy    = -dy;  // need absolute value

   } // end else moving up

// compute (dx,dy) * 2
dx2 = dx << 1;
dy2 = dy << 1;

// now based on which delta is greater we can draw the line
if (dx > dy)
   {
   // initialize error term
   error = dy2 - dx; 

   // draw the line
   for (index=0; index <= dx; index++)
       {
       // set the pixel
       *vb_start2 = (USHORT)color;

       // test if error has overflowed
       if (error >= 0) 
          {
          error-=dx2;

          // move to next line
          vb_start2+=y_inc;

	   } // end if error overflowed

       // adjust the error term
       error+=dy2;

       // move to the next pixel
       vb_start2+=x_inc;

       } // end for

   } // end if |slope| <= 1
else
   {
   // initialize error term
   error = dx2 - dy; 

   // draw the line
   for (index=0; index <= dy; index++)
       {
       // set the pixel
       *vb_start2 = (USHORT)color;

       // test if error overflowed
       if (error >= 0)
          {
          error-=dy2;

          // move to next line
          vb_start2+=x_inc;

          } // end if error overflowed

       // adjust the error term
       error+=dx2;

       // move to the next pixel
       vb_start2+=y_inc;

       } // end for

   } // end else |slope| > 1

// return success
return(1);

} // end Draw_Line16

///////////////////////////////////////////////////////////

int Draw_Pixel(int x, int y,int color,
               UCHAR *video_buffer, int lpitch)
{
// this function plots a single pixel at x,y with color

video_buffer[x + y*lpitch] = color;

// return success
return(1);

} // end Draw_Pixel

///////////////////////////////////////////////////////////   
   
int Draw_Pixel16(int x, int y,int color,
                        UCHAR *video_buffer, int lpitch)
{
// this function plots a single pixel at x,y with color

((USHORT *)video_buffer)[x + y*(lpitch >> 1)] = color;

// return success
return(1);

} // end Draw_Pixel16

///////////////////////////////////////////////////////////   


int Draw_Rectangle(int x1, int y1, int x2, int y2, int color,
                   LPDIRECTDRAWSURFACE7 lpdds)
{
// this function uses directdraw to draw a filled rectangle

DDBLTFX ddbltfx; // this contains the DDBLTFX structure
RECT fill_area;  // this contains the destination rectangle

// clear out the structure and set the size field 
DDRAW_INIT_STRUCT(ddbltfx);

// set the dwfillcolor field to the desired color
ddbltfx.dwFillColor = color; 

// fill in the destination rectangle data (your data)
fill_area.top    = y1;
fill_area.left   = x1;
fill_area.bottom = y2;
fill_area.right  = x2;

// ready to blt to surface, in this case blt to primary
lpdds->Blt(&fill_area, // ptr to dest rectangle
           NULL,       // ptr to source surface, NA            
           NULL,       // ptr to source rectangle, NA
           DDBLT_COLORFILL | DDBLT_WAIT,   // fill and wait                   
           &ddbltfx);  // ptr to DDBLTFX structure

// return success
return(1);

} // end Draw_Rectangle

///////////////////////////////////////////////////////////
   
int Set_Palette_Entry(int color_index, LPPALETTEENTRY color)
{
// this function sets a palette color in the palette
lpddpal->SetEntries(0,color_index,1,color);

// set data in shadow palette
memcpy(&palette[color_index],color,sizeof(PALETTEENTRY));

// return success
return(1);
} // end Set_Palette_Entry

///////////////////////////////////////////////////////////   
   
int Get_Palette_Entry(int color_index,LPPALETTEENTRY color)
{
// this function retrieves a palette entry from the color
// palette

// copy data out from shadow palette
memcpy(color, &palette[color_index],sizeof(PALETTEENTRY));

// return success
return(1);
} // end Get_Palette_Entry

///////////////////////////////////////////////////////////
   
int Load_Palette_From_File(char *filename, LPPALETTEENTRY palette)
{
// this function loads a palette from disk into a palette
// structure, but does not set the pallette

FILE *fp_file; // working file

// try and open file
if ((fp_file = fopen(filename,"r"))==NULL)
   return(0);

// read in all 256 colors RGBF
for (int index=0; index<MAX_COLORS_PALETTE; index++)
    {
    // read the next entry in
    fscanf(fp_file,"%d %d %d %d",&palette[index].peRed,
                                 &palette[index].peGreen,
                                 &palette[index].peBlue,                                
                                 &palette[index].peFlags);
    } // end for index

// close the file
fclose(fp_file);

// return success
return(1);
} // end Load_Palette_From_Disk

///////////////////////////////////////////////////////////   
   
int Save_Palette_To_File(char *filename, LPPALETTEENTRY palette)
{
// this function saves a palette to disk

FILE *fp_file; // working file

// try and open file
if ((fp_file = fopen(filename,"w"))==NULL)
   return(0);

// write in all 256 colors RGBF
for (int index=0; index<MAX_COLORS_PALETTE; index++)
    {
    // read the next entry in
    fprintf(fp_file,"\n%d %d %d %d",palette[index].peRed,
                                    palette[index].peGreen,
                                    palette[index].peBlue,                                
                                    palette[index].peFlags);
    } // end for index

// close the file
fclose(fp_file);

// return success
return(1);

} // end Save_Palette_To_Disk

///////////////////////////////////////////////////////////

int Save_Palette(LPPALETTEENTRY sav_palette)
{
// this function saves the current palette 

memcpy(sav_palette, palette,MAX_COLORS_PALETTE*sizeof(PALETTEENTRY));

// return success
return(1);
} // end Save_Palette

///////////////////////////////////////////////////////////   
   
int Set_Palette(LPPALETTEENTRY set_palette)
{
// this function writes the sent palette

// first save the new palette in shadow
memcpy(palette, set_palette,MAX_COLORS_PALETTE*sizeof(PALETTEENTRY));

// now set the new palette
lpddpal->SetEntries(0,0,MAX_COLORS_PALETTE,palette);

// return success
return(1);
} // end Set_Palette

///////////////////////////////////////////////////////////

int Rotate_Colors(int start_index, int end_index)
{
// this function rotates the color between start and end

int colors = end_index - start_index + 1;

PALETTEENTRY work_pal[MAX_COLORS_PALETTE]; // working palette

// get the color palette
lpddpal->GetEntries(0,start_index,colors,work_pal);

// shift the colors
lpddpal->SetEntries(0,start_index+1,colors-1,work_pal);

// fix up the last color
lpddpal->SetEntries(0,start_index,1,&work_pal[colors - 1]);

// update shadow palette
lpddpal->GetEntries(0,0,MAX_COLORS_PALETTE,palette);

// return success
return(1);

} // end Rotate_Colors

///////////////////////////////////////////////////////////   
   
int Blink_Colors(int command, BLINKER_PTR new_light, int id)
{
// this function blinks a set of lights

static BLINKER lights[256]; // supports up to 256 blinking lights
static int initialized = 0; // tracks if function has initialized

// test if this is the first time function has ran
if (!initialized)
   {
   // set initialized
   initialized = 1;

   // clear out all structures
   memset((void *)lights,0, sizeof(lights));

   } // end if

// now test what command user is sending
switch (command)
       {
       case BLINKER_ADD: // add a light to the database
            {
            // run thru database and find an open light
            for (int index=0; index < 256; index++)
                {
                // is this light available?
                if (lights[index].state == 0)
                   {
                   // set light up
                   lights[index] = *new_light;

                   // set internal fields up
                   lights[index].counter =  0;
                   lights[index].state   = -1; // off

                   // update palette entry
                   lpddpal->SetEntries(0,lights[index].color_index,1,&lights[index].off_color);
 
                   // return id to caller
                   return(index);

                   } // end if

                } // end for index

            } break;

       case BLINKER_DELETE: // delete the light indicated by id
            {
            // delete the light sent in id 
            if (lights[id].state != 0)
               {
               // kill the light
               memset((void *)&lights[id],0,sizeof(BLINKER));

               // return id
               return(id);
 
               } // end if
            else
                return(-1); // problem


            } break;

       case BLINKER_UPDATE: // update the light indicated by id
            { 
            // make sure light is active
            if (lights[id].state != 0)
               {
               // update on/off parms only
               lights[id].on_color  = new_light->on_color; 
               lights[id].off_color = new_light->off_color;
               lights[id].on_time   = new_light->on_time;
               lights[id].off_time  = new_light->off_time; 

               // update palette entry
               if (lights[id].state == -1)
                  lpddpal->SetEntries(0,lights[id].color_index,1,&lights[id].off_color);
               else
                  lpddpal->SetEntries(0,lights[id].color_index,1,&lights[id].on_color);

               // return id
               return(id);
 
               } // end if
            else
                return(-1); // problem

            } break;

       case BLINKER_RUN: // run the algorithm
            {
            // run thru database and process each light
            for (int index=0; index < 256; index++)
                {
                // is this active?
                if (lights[index].state == -1)
                   {
                   // update counter
                   if (++lights[index].counter >= lights[index].off_time)
                      {
                      // reset counter
                      lights[index].counter = 0;

                      // change states 
                      lights[index].state = -lights[index].state;               
 
                      // update color
                      lpddpa

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产酒店精品激情| 亚洲综合视频在线观看| 日韩欧美一级精品久久| 精品日韩一区二区三区| 亚洲国产精品二十页| 国产精品国产精品国产专区不片 | 亚洲电影一区二区三区| 一区二区三区四区视频精品免费 | 五月天一区二区| 亚洲高清视频在线| 日韩av不卡一区二区| 国产精品77777| 成人免费av网站| 欧美伊人久久久久久午夜久久久久| 欧美精品少妇一区二区三区| 久久蜜桃av一区精品变态类天堂 | 91久久精品一区二区三区| 国产精品久久久久久亚洲伦| 久久综合狠狠综合久久综合88| 国产精品99久久久| 日本亚洲一区二区| 精品一区二区免费看| 国产盗摄视频一区二区三区| 91原创在线视频| 91精品国产欧美日韩| 26uuu精品一区二区在线观看| 久久久五月婷婷| 亚洲大片在线观看| 国产毛片精品国产一区二区三区| av电影在线观看完整版一区二区| 欧洲一区二区三区在线| 国产午夜精品理论片a级大结局| 国产精品欧美一区二区三区| 午夜av电影一区| 91污在线观看| 精品人在线二区三区| 中日韩免费视频中文字幕| 亚洲乱码国产乱码精品精的特点 | 4438成人网| 亚洲一区二区在线播放相泽 | 99re成人在线| 久久综合九色综合97婷婷| 天天影视涩香欲综合网| 在线影视一区二区三区| 国产精品美女久久福利网站| 精品一区二区三区免费观看| 欧洲中文字幕精品| 亚洲夂夂婷婷色拍ww47| 97久久精品人人爽人人爽蜜臀| 亚洲国产精品精华液2区45| 九九九久久久精品| 国产亚洲人成网站| 99久久精品免费| 亚洲一区二区三区自拍| 在线观看视频欧美| 爽爽淫人综合网网站| 欧美日韩国产综合久久| 日本不卡一区二区三区| 在线播放日韩导航| 美腿丝袜亚洲一区| 久久久久久免费| 91年精品国产| 日韩成人伦理电影在线观看| 精品国产一二三区| 成人黄色大片在线观看| 亚洲福利国产精品| 欧美xxxxx牲另类人与| 波多野结衣亚洲| 日本亚洲视频在线| 亚洲欧美色一区| 欧美成人video| 一本一道综合狠狠老| 美国欧美日韩国产在线播放| 日本乱人伦aⅴ精品| 91在线一区二区三区| 成人精品一区二区三区中文字幕| 视频一区中文字幕国产| 性久久久久久久久久久久| 日韩二区在线观看| 激情另类小说区图片区视频区| 日韩av电影一区| 国产综合久久久久久久久久久久| 日韩 欧美一区二区三区| 亚洲精品ww久久久久久p站| 国产区在线观看成人精品| 日韩久久精品一区| 日韩三级免费观看| 欧美一区二区三区视频免费 | 亚洲视频电影在线| 国产欧美日韩亚州综合| 久久久久国产精品厨房| 中文字幕精品一区二区三区精品| 国产日韩一级二级三级| 亚洲视频在线一区观看| 亚洲成人中文在线| 国产精品中文有码| 国内一区二区在线| 成人免费视频一区二区| 精品在线视频一区| 91免费精品国自产拍在线不卡| 成人av网站大全| 狠狠久久亚洲欧美| 国产一区久久久| av一区二区三区在线| 欧美日韩一区二区三区在线看| 欧美电影一区二区| 国产精品久久久久桃色tv| 亚洲国产乱码最新视频| 久久精品国内一区二区三区| 国产一区欧美二区| 91久久精品一区二区三区| 在线观看欧美日本| 欧美精品tushy高清| 亚洲激情成人在线| 国产精品亚洲第一区在线暖暖韩国| 欧美视频一区在线| 亚洲综合在线免费观看| 精品视频一区三区九区| 日韩一区欧美小说| 国产a区久久久| 91麻豆精品国产自产在线| 亚洲已满18点击进入久久| 国产福利91精品一区二区三区| 欧美日韩久久一区| 精品美女在线播放| 亚洲小少妇裸体bbw| 色综合久久久久网| 中文字幕亚洲一区二区va在线| 国产成人免费在线观看| 欧美大黄免费观看| 琪琪一区二区三区| 欧美体内she精高潮| 一区二区三区在线高清| 中文字幕一区二区三区av| 激情综合网激情| 亚洲精品福利视频网站| 无码av中文一区二区三区桃花岛| 国产主播一区二区三区| 国产情人综合久久777777| 国产不卡视频一区二区三区| 一片黄亚洲嫩模| 国产日本欧洲亚洲| 欧美日韩一级二级三级| 国产传媒欧美日韩成人| 一片黄亚洲嫩模| 国产麻豆一精品一av一免费| 成人av在线看| 欧美日韩五月天| 国产欧美一区视频| 久久99久久精品| 日韩一区二区三区电影在线观看 | 天天综合色天天| 豆国产96在线|亚洲| 制服丝袜一区二区三区| 一区二区三区日韩欧美精品| 国产激情精品久久久第一区二区| 91.com视频| 亚洲成av人片观看| 在线看国产日韩| 一区二区三区在线免费观看| 成人激情小说网站| 欧美日韩国产经典色站一区二区三区| 欧美xxxxxxxx| 亚洲黄色av一区| 色av成人天堂桃色av| 亚洲三级久久久| 欧美专区亚洲专区| 蜜桃视频在线一区| 6080午夜不卡| 奇米色一区二区三区四区| 国产精品久久看| 成人涩涩免费视频| 懂色av一区二区三区蜜臀| 国产视频一区二区三区在线观看| 激情五月播播久久久精品| 久久女同性恋中文字幕| 国产精品乱码一区二三区小蝌蚪| 艳妇臀荡乳欲伦亚洲一区| 成人精品视频一区| 亚洲欧美日韩国产综合| 欧美日韩一级大片网址| 美女免费视频一区二区| 日韩毛片在线免费观看| 91精品国产综合久久久久久久| 日韩中文字幕一区二区三区| 欧美人与性动xxxx| 91成人网在线| 日本欧美韩国一区三区| 中文一区在线播放| 91精品国产日韩91久久久久久| 日韩福利电影在线观看| 91美女片黄在线观看91美女| 一区二区三区四区在线免费观看| 欧美一区二区三区成人| 91在线免费看| 国产大片一区二区| 亚洲欧美日韩系列| 国产日韩欧美精品综合| 日韩精品一区二区三区视频| 日本精品视频一区二区|