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

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

?? demo8_7.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
xe = (float)x2+(float)0.5;

// perform y clipping
if (y1 < min_clip_y)
   {
   // compute new xs and ys
   xs = xs+dx_left*(float)(-y1+min_clip_y);
   xe = xe+dx_right*(float)(-y1+min_clip_y);

   // reset y1
   y1=min_clip_y;

   } // end if top is off screen

if (y3>max_clip_y)
   y3=max_clip_y;

// compute starting address in video memory
dest_addr = dest_buffer+y1*mempitch;

// test if x clipping is needed
if (x1>=min_clip_x && x1<=max_clip_x &&
    x2>=min_clip_x && x2<=max_clip_x &&
    x3>=min_clip_x && x3<=max_clip_x)
    {
    // draw the triangle
    for (temp_y=y1; temp_y<=y3; temp_y++,dest_addr+=mempitch)
        {
        memset((UCHAR *)dest_addr+(unsigned int)xs,
                color,(unsigned int)(xe-xs+1));

        // adjust starting point and ending point
        xs+=dx_left;
        xe+=dx_right;

        } // end for

    } // end if no x clipping needed
else
   {
   // clip x axis with slower version

   // draw the triangle
   for (temp_y=y1; temp_y<=y3; temp_y++,dest_addr+=mempitch)
       {
       // do x clip
       left  = (int)xs;
       right = (int)xe;

       // adjust starting point and ending point
       xs+=dx_left;
       xe+=dx_right;

       // clip line
       if (left < min_clip_x)
          {
          left = min_clip_x;

          if (right < min_clip_x)
             continue;
          }

       if (right > max_clip_x)
          {
          right = max_clip_x;

          if (left > max_clip_x)
             continue;
          }

       memset((UCHAR  *)dest_addr+(unsigned int)left,
              color,(unsigned int)(right-left+1));

       } // end for

   } // end else x clipping needed

} // end Draw_Top_Tri

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

void Draw_Bottom_Tri(int x1,int y1, 
                     int x2,int y2, 
                     int x3,int y3,
                     int color,
                     UCHAR *dest_buffer, int mempitch)
{
// this function draws a triangle that has a flat bottom

float dx_right,    // the dx/dy ratio of the right edge of line
      dx_left,     // the dx/dy ratio of the left edge of line
      xs,xe,       // the starting and ending points of the edges
      height;      // the height of the triangle

int temp_x,        // used during sorting as temps
    temp_y,
    right,         // used by clipping
    left;

// destination address of next scanline
UCHAR  *dest_addr;

// test order of x1 and x2
if (x3 < x2)
   {
   temp_x = x2;
   x2     = x3;
   x3     = temp_x;
   } // end if swap

// compute delta's
height = y3-y1;

dx_left  = (x2-x1)/height;
dx_right = (x3-x1)/height;

// set starting points
xs = (float)x1;
xe = (float)x1; // +(float)0.5;

// perform y clipping
if (y1<min_clip_y)
   {
   // compute new xs and ys
   xs = xs+dx_left*(float)(-y1+min_clip_y);
   xe = xe+dx_right*(float)(-y1+min_clip_y);

   // reset y1
   y1=min_clip_y;

   } // end if top is off screen

if (y3>max_clip_y)
   y3=max_clip_y;

// compute starting address in video memory
dest_addr = dest_buffer+y1*mempitch;

// test if x clipping is needed
if (x1>=min_clip_x && x1<=max_clip_x &&
    x2>=min_clip_x && x2<=max_clip_x &&
    x3>=min_clip_x && x3<=max_clip_x)
    {
    // draw the triangle
    for (temp_y=y1; temp_y<=y3; temp_y++,dest_addr+=mempitch)
        {
        memset((UCHAR  *)dest_addr+(unsigned int)xs,
                color,(unsigned int)(xe-xs+1));

        // adjust starting point and ending point
        xs+=dx_left;
        xe+=dx_right;

        } // end for

    } // end if no x clipping needed
else
   {
   // clip x axis with slower version

   // draw the triangle

   for (temp_y=y1; temp_y<=y3; temp_y++,dest_addr+=mempitch)
       {
       // do x clip
       left  = (int)xs;
       right = (int)xe;

       // adjust starting point and ending point
       xs+=dx_left;
       xe+=dx_right;

       // clip line
       if (left < min_clip_x)
          {
          left = min_clip_x;

          if (right < min_clip_x)
             continue;
          }

       if (right > max_clip_x)
          {
          right = max_clip_x;

          if (left > max_clip_x)
             continue;
          }

       memset((UCHAR  *)dest_addr+(unsigned int)left,
              color,(unsigned int)(right-left+1));

       } // end for

   } // end else x clipping needed

} // end Draw_Bottom_Tri

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

void Draw_TriangleFP_2D(int x1,int y1,
                        int x2,int y2,
                        int x3,int y3,
                        int color,
    	   			    UCHAR *dest_buffer, int mempitch)
{
// this function draws a triangle on the destination buffer using fixed point
// it decomposes all triangles into a pair of flat top, flat bottom

int temp_x, // used for sorting
    temp_y,
    new_x;

// test for h lines and v lines
if ((x1==x2 && x2==x3)  ||  (y1==y2 && y2==y3))
   return;

// sort p1,p2,p3 in ascending y order
if (y2<y1)
   {
   temp_x = x2;
   temp_y = y2;
   x2     = x1;
   y2     = y1;
   x1     = temp_x;
   y1     = temp_y;
   } // end if

// now we know that p1 and p2 are in order
if (y3<y1)
   {
   temp_x = x3;
   temp_y = y3;
   x3     = x1;
   y3     = y1;
   x1     = temp_x;
   y1     = temp_y;
   } // end if

// finally test y3 against y2
if (y3<y2)
   {
   temp_x = x3;
   temp_y = y3;
   x3     = x2;
   y3     = y2;
   x2     = temp_x;
   y2     = temp_y;

   } // end if

// do trivial rejection tests for clipping
if ( y3<min_clip_y || y1>max_clip_y ||
    (x1<min_clip_x && x2<min_clip_x && x3<min_clip_x) ||
    (x1>max_clip_x && x2>max_clip_x && x3>max_clip_x) )
   return;

// test if top of triangle is flat
if (y1==y2)
   {
   Draw_Top_TriFP(x1,y1,x2,y2,x3,y3,color, dest_buffer, mempitch);
   } // end if
else
if (y2==y3)
   {
   Draw_Bottom_TriFP(x1,y1,x2,y2,x3,y3,color, dest_buffer, mempitch);
   } // end if bottom is flat
else
   {
   // general triangle that's needs to be broken up along long edge
   new_x = x1 + (int)(0.5+(float)(y2-y1)*(float)(x3-x1)/(float)(y3-y1));

   // draw each sub-triangle
   Draw_Bottom_TriFP(x1,y1,new_x,y2,x2,y2,color, dest_buffer, mempitch);
   Draw_Top_TriFP(x2,y2,new_x,y2,x3,y3,color, dest_buffer, mempitch);

   } // end else

} // end Draw_TriangleFP_2D

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

void Draw_Triangle_2D(int x1,int y1,
                      int x2,int y2,
                      int x3,int y3,
                      int color,
					  UCHAR *dest_buffer, int mempitch)
{
// this function draws a triangle on the destination buffer
// it decomposes all triangles into a pair of flat top, flat bottom

int temp_x, // used for sorting
    temp_y,
    new_x;

// test for h lines and v lines
if ((x1==x2 && x2==x3)  ||  (y1==y2 && y2==y3))
   return;

// sort p1,p2,p3 in ascending y order
if (y2<y1)
   {
   temp_x = x2;
   temp_y = y2;
   x2     = x1;
   y2     = y1;
   x1     = temp_x;
   y1     = temp_y;
   } // end if

// now we know that p1 and p2 are in order
if (y3<y1)
   {
   temp_x = x3;
   temp_y = y3;
   x3     = x1;
   y3     = y1;
   x1     = temp_x;
   y1     = temp_y;
   } // end if

// finally test y3 against y2
if (y3<y2)
   {
   temp_x = x3;
   temp_y = y3;
   x3     = x2;
   y3     = y2;
   x2     = temp_x;
   y2     = temp_y;

   } // end if

// do trivial rejection tests for clipping
if ( y3<min_clip_y || y1>max_clip_y ||
    (x1<min_clip_x && x2<min_clip_x && x3<min_clip_x) ||
    (x1>max_clip_x && x2>max_clip_x && x3>max_clip_x) )
   return;

// test if top of triangle is flat
if (y1==y2)
   {
   Draw_Top_Tri(x1,y1,x2,y2,x3,y3,color, dest_buffer, mempitch);
   } // end if
else
if (y2==y3)
   {
   Draw_Bottom_Tri(x1,y1,x2,y2,x3,y3,color, dest_buffer, mempitch);
   } // end if bottom is flat
else
   {
   // general triangle that's needs to be broken up along long edge
   new_x = x1 + (int)(0.5+(float)(y2-y1)*(float)(x3-x1)/(float)(y3-y1));

   // draw each sub-triangle
   Draw_Bottom_Tri(x1,y1,new_x,y2,x2,y2,color, dest_buffer, mempitch);
   Draw_Top_Tri(x2,y2,new_x,y2,x3,y3,color, dest_buffer, mempitch);

   } // end else

} // end Draw_Triangle_2D

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


int Draw_Text_GDI(char *text, int x,int y,int color, LPDIRECTDRAWSURFACE7 lpdds)
{
// this function draws the sent text on the sent surface 
// using color index as the color in the palette

HDC xdc; // the working dc

// get the dc from surface
if (FAILED(lpdds->GetDC(&xdc)))
   return(0);

// set the colors for the text up
SetTextColor(xdc,RGB(palette[color].peRed,palette[color].peGreen,palette[color].peBlue) );

// set background mode to transparent so black isn't copied
SetBkMode(xdc, TRANSPARENT);

// draw the text a
TextOut(xdc,x,y,text,strlen(text));

// release the dc
lpdds->ReleaseDC(xdc);

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

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


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 Translate_Polygon2D(POLYGON2D_PTR poly, int dx, int dy)
{
// this function translates the center of a polygon

// test for valid pointer
if (!poly)
   return(0);

// translate
poly->x0+=dx;
poly->y0+=dy;

// return success
return(1);

} // end Translate_Polygon2D

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

int Rotate_Polygon2D(POLYGON2D_PTR poly, int theta)
{
// this function rotates the local coordinates of the polygon

// test for valid pointer
if (!poly)
   return(0);

// loop and rotate each point, very crude, no lookup!!!
for (int curr_vert = 0; curr_vert < poly->num_verts; curr_vert++)
    {

    // perform rotation
    float xr = (float)poly->vlist[curr_vert].x*cos_look[theta] - 
                    (float)poly->vlist[curr_vert].y*sin_look[theta];

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成a人在线观看| 午夜精品免费在线观看| 欧美日韩中文字幕一区| 韩国一区二区三区| 亚洲国产精品久久不卡毛片| 亚洲国产精品v| 精品第一国产综合精品aⅴ| 欧美性色欧美a在线播放| 国产成人无遮挡在线视频| 日韩在线a电影| 1024成人网| 欧美国产日韩一二三区| 精品免费国产一区二区三区四区| 色婷婷亚洲婷婷| 成人精品鲁一区一区二区| 国产自产高清不卡| 视频一区二区国产| 亚洲第四色夜色| 18成人在线视频| 国产精品美女www爽爽爽| 欧美精品一区二区三区视频| 欧美美女网站色| 日本乱人伦aⅴ精品| 成人av一区二区三区| 国产精品夜夜爽| 激情五月婷婷综合网| 男女激情视频一区| 日韩精品亚洲专区| 午夜精品一区在线观看| 亚洲大片在线观看| 亚洲福中文字幕伊人影院| 亚洲精品视频在线观看免费| 中文字幕一区三区| 国产精品成人网| 国产精品不卡在线观看| 中文字幕av一区 二区| 国产欧美中文在线| 久久精品欧美日韩| 欧美激情一区二区三区四区| 亚洲国产精品二十页| 国产精品美女久久福利网站| 国产精品欧美一区二区三区| 国产精品久久久久7777按摩| 国产精品久久久久久户外露出| 国产精品家庭影院| 亚洲视频一二区| 亚洲激情校园春色| 亚洲一区二区三区影院| 亚洲高清免费视频| 免费观看在线综合| 国产精品一区二区在线观看不卡| 国产一区二区91| 丰满少妇在线播放bd日韩电影| 成人久久久精品乱码一区二区三区| 国产成人av网站| 91一区在线观看| 欧美视频在线一区| 日韩一区二区影院| 久久久久久亚洲综合影院红桃| 国产精品污污网站在线观看| 综合在线观看色| 亚洲不卡av一区二区三区| 日韩 欧美一区二区三区| 老司机午夜精品99久久| 国产成人自拍网| 色综合中文综合网| 视频一区在线视频| 精品一区二区在线看| 成人中文字幕在线| 欧洲av一区二区嗯嗯嗯啊| 欧美成人性战久久| 亚洲欧洲av一区二区三区久久| 夜夜亚洲天天久久| 激情综合五月天| 色综合天天综合网国产成人综合天| 欧美人牲a欧美精品| 久久青草欧美一区二区三区| 亚洲日本韩国一区| 日本va欧美va精品发布| www.66久久| 欧美一级黄色大片| 亚洲另类春色校园小说| 久草这里只有精品视频| av在线播放一区二区三区| 国产日韩欧美精品一区| 亚洲精品乱码久久久久久| 久久国产乱子精品免费女| 91免费国产在线| 欧美精品一区二区三区在线播放| 中文字幕一区在线| 裸体歌舞表演一区二区| 成+人+亚洲+综合天堂| 日韩欧美一级精品久久| 17c精品麻豆一区二区免费| 美女视频黄频大全不卡视频在线播放| 成人午夜私人影院| 日韩欧美国产三级| 亚洲综合在线免费观看| 国产1区2区3区精品美女| 7777精品伊人久久久大香线蕉 | 色综合久久久久综合| 精品国产自在久精品国产| 亚洲自拍偷拍网站| 成人av免费在线播放| 精品国产乱码91久久久久久网站| 亚洲综合色丁香婷婷六月图片| 成人免费观看视频| 精品不卡在线视频| 日韩 欧美一区二区三区| 日本电影欧美片| 中文字幕不卡在线观看| 国产剧情av麻豆香蕉精品| 欧美一区永久视频免费观看| 亚洲天堂福利av| 成人深夜福利app| 久久综合狠狠综合| 紧缚捆绑精品一区二区| 91精品国产综合久久久久久 | 一区二区三区.www| 成人高清在线视频| 国产日产欧美精品一区二区三区| 久久精品国产一区二区| 在线不卡的av| 五月天欧美精品| 欧美日韩三级一区二区| 亚洲一区av在线| 欧美视频自拍偷拍| 亚洲va国产天堂va久久en| 欧美亚洲综合色| 亚洲一区二区在线免费看| 欧美最新大片在线看| 亚洲一区电影777| 欧美视频一区二区三区| 亚洲国产欧美在线| 欧美日本一道本| 日本不卡视频一二三区| 日韩欧美激情四射| 精品一区二区三区在线播放视频 | www.色综合.com| 国产精品电影一区二区| 99久久免费视频.com| 亚洲欧美日韩中文播放| 欧美亚洲一区三区| 亚洲国产综合色| 91精品在线一区二区| 久久精品国产一区二区三| 久久综合久久99| 成人黄色av网站在线| 亚洲欧美乱综合| 欧美视频在线一区二区三区| 日日夜夜精品视频免费| 国产亚洲综合在线| 91色porny蝌蚪| 亚洲国产裸拍裸体视频在线观看乱了 | 国产午夜精品在线观看| 丰满亚洲少妇av| 亚洲欧美国产三级| 欧美日精品一区视频| 美女视频黄 久久| 国产蜜臀97一区二区三区| 91一区在线观看| 日韩精品欧美精品| 国产欧美日韩麻豆91| 色噜噜狠狠色综合中国| 日本最新不卡在线| 国产日韩欧美制服另类| 91欧美激情一区二区三区成人| 亚洲综合网站在线观看| 日韩精品资源二区在线| 高清beeg欧美| 亚洲777理论| 国产性做久久久久久| 日本丰满少妇一区二区三区| 日韩av不卡一区二区| 国产三级精品三级在线专区| 欧美亚洲丝袜传媒另类| 久久不见久久见免费视频1| 国产精品人妖ts系列视频| 欧美午夜精品久久久久久超碰| 精品在线你懂的| 亚洲综合一二区| 国产人成亚洲第一网站在线播放| 日本乱人伦一区| 国产一区二区三区四区在线观看| 一区二区三区四区视频精品免费| 欧美mv日韩mv国产网站app| 91亚洲精品一区二区乱码| 久久精品理论片| 亚洲综合久久av| 国产精品护士白丝一区av| 91精品国产综合久久久蜜臀图片 | 精品乱码亚洲一区二区不卡| 成人av电影观看| 亚洲成人资源在线| 国产精品美女久久久久高潮| 欧美一区二区三区视频在线观看 | 久久天天做天天爱综合色| 在线免费av一区| 成人福利视频网站| 国产一二三精品|