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

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

?? t3dlib1.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
?? 第 1 頁 / 共 5 頁
字號:
int Load_Frame_BOB(BOB_PTR bob, // bob to load with data
                   BITMAP_FILE_PTR bitmap, // bitmap to scan image data from
                   int frame,       // frame to load
                   int cx,int cy,   // cell or absolute pos. to scan image from
                   int mode)        // if 0 then cx,cy is cell position, else 
                                    // cx,cy are absolute coords
{
// this function extracts a bitmap out of a bitmap file

DDSURFACEDESC2 ddsd;  //  direct draw surface description 

// is this a valid bob
if (!bob)
   return(0);

UCHAR *source_ptr,   // working pointers
      *dest_ptr;

// test the mode of extraction, cell based or absolute
if (mode==BITMAP_EXTRACT_MODE_CELL)
   {
   // re-compute x,y
   cx = cx*(bob->width+1) + 1;
   cy = cy*(bob->height+1) + 1;
   } // end if

// extract bitmap data
source_ptr = bitmap->buffer + cy*bitmap->bitmapinfoheader.biWidth+cx;

// get the addr to destination surface memory

// set size of the structure
ddsd.dwSize = sizeof(ddsd);

// lock the display surface
(bob->images[frame])->Lock(NULL,
                           &ddsd,
                           DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR,
                           NULL);

// assign a pointer to the memory surface for manipulation
dest_ptr = (UCHAR *)ddsd.lpSurface;

// iterate thru each scanline and copy bitmap
for (int index_y=0; index_y<bob->height; index_y++)
    {
    // copy next line of data to destination
    memcpy(dest_ptr, source_ptr,bob->width);

    // advance pointers
    dest_ptr   += (ddsd.lPitch); // (bob->width+bob->width_fill);
    source_ptr += bitmap->bitmapinfoheader.biWidth;
    } // end for index_y

// unlock the surface 
(bob->images[frame])->Unlock(NULL);

// set state to loaded
bob->attr |= BOB_ATTR_LOADED;

// return success
return(1);

} // end Load_Frame_BOB

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

int Load_Frame_BOB16(BOB_PTR bob, // bob to load with data
                     BITMAP_FILE_PTR bitmap, // bitmap to scan image data from
                     int frame,       // frame to load
                     int cx,int cy,   // cell or absolute pos. to scan image from
                     int mode)        // if 0 then cx,cy is cell position, else 
                                    // cx,cy are absolute coords
{
// this function extracts a 16-bit bitmap out of a 16-bit bitmap file

DDSURFACEDESC2 ddsd;  //  direct draw surface description 

// is this a valid bob
if (!bob)
   return(0);

USHORT *source_ptr,   // working pointers
       *dest_ptr;

// test the mode of extraction, cell based or absolute
if (mode==BITMAP_EXTRACT_MODE_CELL)
   {
   // re-compute x,y
   cx = cx*(bob->width+1) + 1;
   cy = cy*(bob->height+1) + 1;
   } // end if

// extract bitmap data
source_ptr = (USHORT *)bitmap->buffer + cy*bitmap->bitmapinfoheader.biWidth+cx;

// get the addr to destination surface memory

// set size of the structure
ddsd.dwSize = sizeof(ddsd);

// lock the display surface
(bob->images[frame])->Lock(NULL,
                           &ddsd,
                           DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR,
                           NULL);

// assign a pointer to the memory surface for manipulation
dest_ptr = (USHORT *)ddsd.lpSurface;

// iterate thru each scanline and copy bitmap
for (int index_y=0; index_y<bob->height; index_y++)
    {
    // copy next line of data to destination
    memcpy(dest_ptr, source_ptr,(bob->width*2));

    // advance pointers
    dest_ptr   += (ddsd.lPitch >> 1); 
    source_ptr += bitmap->bitmapinfoheader.biWidth;
    } // end for index_y

// unlock the surface 
(bob->images[frame])->Unlock(NULL);

// set state to loaded
bob->attr |= BOB_ATTR_LOADED;

// return success
return(1);

} // end Load_Frame_BOB16

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

int Animate_BOB(BOB_PTR bob)
{
// this function animates a bob, basically it takes a look at
// the attributes of the bob and determines if the bob is 
// a single frame, multiframe, or multi animation, updates
// the counters and frames appropriately

// is this a valid bob
if (!bob)
   return(0);

// test the level of animation
if (bob->attr & BOB_ATTR_SINGLE_FRAME)
    {
    // current frame always = 0
    bob->curr_frame = 0;
    return(1);
    } // end if
else
if (bob->attr & BOB_ATTR_MULTI_FRAME)
   {
   // update the counter and test if its time to increment frame
   if (++bob->anim_counter >= bob->anim_count_max)
      {
      // reset counter
      bob->anim_counter = 0;

      // move to next frame
      if (++bob->curr_frame >= bob->num_frames)
         bob->curr_frame = 0;

      } // end if
  
   } // end elseif
else
if (bob->attr & BOB_ATTR_MULTI_ANIM)
   {
   // this is the most complex of the animations it must look up the
   // next frame in the animation sequence

   // first test if its time to animate
   if (++bob->anim_counter >= bob->anim_count_max)
      {
      // reset counter
      bob->anim_counter = 0;

      // increment the animation frame index
      bob->anim_index++;
      
      // extract the next frame from animation list 
      bob->curr_frame = bob->animations[bob->curr_animation][bob->anim_index];
     
      // is this and end sequence flag -1
      if (bob->curr_frame == -1)
         {
         // test if this is a single shot animation
         if (bob->attr & BOB_ATTR_ANIM_ONE_SHOT)
            {
            // set animation state message to done
            bob->anim_state = BOB_STATE_ANIM_DONE;
            
            // reset frame back one
            bob->anim_index--;

            // extract animation frame
            bob->curr_frame = bob->animations[bob->curr_animation][bob->anim_index];    

            } // end if
        else
           {
           // reset animation index
           bob->anim_index = 0;

           // extract first animation frame
           bob->curr_frame = bob->animations[bob->curr_animation][bob->anim_index];
           } // end else

         }  // end if
      
      } // end if

   } // end elseif

// return success
return(1);

} // end Amimate_BOB

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

int Scroll_BOB(void)
{
// this function scrolls a bob 
// not implemented

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

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

int Move_BOB(BOB_PTR bob)
{
// this function moves the bob based on its current velocity
// also, the function test for various motion attributes of the'
// bob and takes the appropriate actions
   

// is this a valid bob
if (!bob)
   return(0);

// translate the bob
bob->x+=bob->xv;
bob->y+=bob->yv;

// test for wrap around
if (bob->attr & BOB_ATTR_WRAPAROUND)
   {
   // test x extents first
   if (bob->x > max_clip_x)
       bob->x = min_clip_x - bob->width;
   else
   if (bob->x < min_clip_x-bob->width)
       bob->x = max_clip_x;
   
   // now y extents
   if (bob->x > max_clip_x)
       bob->x = min_clip_x - bob->width;
   else
   if (bob->x < min_clip_x-bob->width)
       bob->x = max_clip_x;

   } // end if
else
// test for bounce
if (bob->attr & BOB_ATTR_BOUNCE)
   {
   // test x extents first
   if ((bob->x > max_clip_x - bob->width) || (bob->x < min_clip_x) )
       bob->xv = -bob->xv;
    
   // now y extents 
   if ((bob->y > max_clip_y - bob->height) || (bob->y < min_clip_y) )
       bob->yv = -bob->yv;

   } // end if

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

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

int Load_Animation_BOB(BOB_PTR bob, 
                       int anim_index, 
                       int num_frames, 
                       int *sequence)
{
// this function load an animation sequence for a bob
// the sequence consists of frame indices, the function
// will append a -1 to the end of the list so the display
// software knows when to restart the animation sequence

// is this bob valid
if (!bob)
   return(0);

// allocate memory for bob animation
if (!(bob->animations[anim_index] = (int *)malloc((num_frames+1)*sizeof(int))))
   return(0);

// load data into 
for (int index=0; index<num_frames; index++)
    bob->animations[anim_index][index] = sequence[index];

// set the end of the list to a -1
bob->animations[anim_index][index] = -1;

// return success
return(1);

} // end Load_Animation_BOB

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

int Set_Pos_BOB(BOB_PTR bob, int x, int y)
{
// this functions sets the postion of a bob

// is this a valid bob
if (!bob)
   return(0);

// set positin
bob->x = x;
bob->y = y;

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

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

int Set_Anim_Speed_BOB(BOB_PTR bob,int speed)
{
// this function simply sets the animation speed of a bob
    
// is this a valid bob
if (!bob)
   return(0);

// set speed
bob->anim_count_max = speed;

// return success
return(1);

} // end Set_Anim_Speed

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

int Set_Animation_BOB(BOB_PTR bob, int anim_index)
{
// this function sets the animation to play

// is this a valid bob
if (!bob)
   return(0);

// set the animation index
bob->curr_animation = anim_index;

// reset animation 
bob->anim_index = 0;

// return success
return(1);

} // end Set_Animation_BOB

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

int Set_Vel_BOB(BOB_PTR bob,int xv, int yv)
{
// this function sets the velocity of a bob

// is this a valid bob
if (!bob)
   return(0);

// set velocity
bob->xv = xv;
bob->yv = yv;

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

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

int Hide_BOB(BOB_PTR bob)
{
// this functions hides bob 

// is this a valid bob
if (!bob)
   return(0);

// reset the visibility bit
RESET_BIT(bob->attr, BOB_ATTR_VISIBLE);

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

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

int Show_BOB(BOB_PTR bob)
{
// this function shows a bob

// is this a valid bob
if (!bob)
   return(0);

// set the visibility bit
SET_BIT(bob->attr, BOB_ATTR_VISIBLE);

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

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

int Collision_BOBS(BOB_PTR bob1, BOB_PTR bob2)
{
// are these a valid bobs
if (!bob1 || !bob2)
   return(0);

// get the radi of each rect
int width1  = (bob1->width>>1) - (bob1->width>>3);
int height1 = (bob1->height>>1) - (bob1->height>>3);

int width2  = (bob2->width>>1) - (bob2->width>>3);
int height2 = (bob2->height>>1) - (bob2->height>>3);

// compute center of each rect
int cx1 = bob1->x + width1;
int cy1 = bob1->y + height1;

int cx2 = bob2->x + width2;
int cy2 = bob2->y + height2;

// compute deltas
int dx = abs(cx2 - cx1);
int dy = abs(cy2 - cy1);

// test if rects overlap
if (dx < (width1+width2) && dy < (height1+height2))
   return(1);
else
// else no collision
return(0);

} // end Collision_BOBS

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

int DDraw_Init(int width, int height, int bpp, int windowed)
{
// this function initializes directdraw
int index; // looping variable

// create IDirectDraw interface 7.0 object and test for error
if (FAILED(DirectDrawCreateEx(NULL, (void **)&lpdd, IID_IDirectDraw7, NULL)))
   return(0);

// based on windowed or fullscreen set coorperation level
if (windowed)
   {
   // set cooperation level to windowed mode 
   if (FAILED(lpdd->SetCooperativeLevel(main_window_handle,DDSCL_NORMAL)))
       return(0);

   } // end if
else
   {
   // set cooperation level to fullscreen mode 
   if (FAILED(lpdd->SetCooperativeLevel(main_window_handle,
              DDSCL_ALLOWMODEX | DDSCL_FULLSCREEN | 
              DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT | DDSCL_MULTITHREADED )))
       return(0);

   // set the display mode
   if (FAILED(lpdd->SetDisplayMode(width,height,bpp,0,0)))
      return(0);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品家庭影院| 国产校园另类小说区| 国产一区二区精品久久| 免费在线观看日韩欧美| 午夜电影久久久| 日本va欧美va精品发布| 亚洲在线中文字幕| 日韩二区三区四区| 美女脱光内衣内裤视频久久网站| 伊人婷婷欧美激情| 亚洲一区电影777| 美女www一区二区| 国产伦精品一区二区三区在线观看| 日本不卡中文字幕| 国产成人亚洲综合a∨婷婷图片| 激情五月婷婷综合| av激情成人网| 制服丝袜成人动漫| 国产女人18毛片水真多成人如厕| 久久免费视频色| 亚洲久本草在线中文字幕| 亚洲综合一二三区| 激情综合色综合久久| 国产激情偷乱视频一区二区三区| 国产成人亚洲精品青草天美 | 成人精品小蝌蚪| 97se亚洲国产综合自在线| 91免费看片在线观看| 欧美日韩亚洲高清一区二区| 色综合久久久久综合体| 91片在线免费观看| 日韩欧美一级二级| 一区二区视频在线| 久久成人羞羞网站| 在线亚洲免费视频| 国产女人aaa级久久久级| 亚洲欧美日韩国产另类专区| 一区二区三区中文字幕电影| 亚洲综合一区在线| 大白屁股一区二区视频| 欧美丝袜第三区| 国产欧美一区二区三区鸳鸯浴| 亚洲欧洲性图库| 国产在线一区观看| 欧美日韩五月天| 亚洲免费伊人电影| 成人午夜av影视| 2017欧美狠狠色| 日韩av不卡一区二区| 成人在线视频一区| 2020国产精品| 久久激情五月激情| 欧美肥大bbwbbw高潮| 亚洲欧洲成人自拍| 成人精品视频一区二区三区尤物| 制服丝袜av成人在线看| 综合久久给合久久狠狠狠97色| 日本特黄久久久高潮 | 综合网在线视频| 国产一区二区三区观看| 欧美日韩一二三区| 一区二区理论电影在线观看| 久久99国产精品久久99| 在线观看亚洲a| 亚洲黄色小视频| 91啪九色porn原创视频在线观看| 欧美成人三级在线| 麻豆国产欧美一区二区三区| 99re热视频这里只精品| www亚洲一区| 激情欧美一区二区三区在线观看| 精品视频色一区| 亚洲va韩国va欧美va精品| 成人app网站| 亚洲视频在线一区| 在线观看91视频| 亚洲www啪成人一区二区麻豆| 91久久精品网| 午夜激情久久久| 日韩午夜中文字幕| 黑人精品欧美一区二区蜜桃| 欧美日韩一级二级三级| 五月天亚洲精品| 日韩欧美亚洲一区二区| 美女高潮久久久| 国产免费成人在线视频| 不卡视频一二三| 综合精品久久久| 在线播放日韩导航| 精品一区二区免费| 国产精品免费丝袜| 一本大道久久a久久综合婷婷| 亚洲欧美日韩精品久久久久| 成人动漫一区二区三区| 亚洲女厕所小便bbb| 欧美视频一区二区在线观看| 亚洲色图19p| 在线中文字幕一区二区| 日韩激情视频在线观看| 欧美zozo另类异族| 99视频精品在线| 免费在线观看视频一区| 国产亚洲成aⅴ人片在线观看 | 激情综合色综合久久综合| 久久噜噜亚洲综合| 在线观看视频一区二区欧美日韩| 亚洲成人免费观看| 国产精品三级av在线播放| 欧美又粗又大又爽| 国产精品一级在线| 亚洲激情男女视频| 国产亚洲欧美一区在线观看| 国产成人av一区| 秋霞电影一区二区| 亚洲黄一区二区三区| 日韩欧美一区二区不卡| 岛国精品一区二区| 另类欧美日韩国产在线| 国产午夜精品美女毛片视频| 成人免费毛片app| 玖玖九九国产精品| 一区二区免费在线播放| 久久理论电影网| 日韩一区二区精品在线观看| 国产一区二区看久久| 亚洲国产美女搞黄色| 久久伊99综合婷婷久久伊| 在线精品视频免费播放| 国产成人精品www牛牛影视| 婷婷六月综合亚洲| 亚洲精品免费播放| 国产欧美日本一区二区三区| 色猫猫国产区一区二在线视频| 久久99精品国产.久久久久 | 在线观看精品一区| jiyouzz国产精品久久| 久久se精品一区二区| 亚洲一区二区三区自拍| 国产精品久久久久久福利一牛影视 | 中文字幕高清不卡| 欧美xxxxx牲另类人与| 欧美伊人久久久久久久久影院 | 亚洲一区二区三区中文字幕| 2欧美一区二区三区在线观看视频| 色综合天天综合色综合av| 国产91丝袜在线观看| 久久国产婷婷国产香蕉| 午夜精品视频在线观看| 一区二区三区在线影院| 亚洲欧美一区二区三区极速播放 | 美洲天堂一区二卡三卡四卡视频| 亚洲欧美日韩久久精品| 国产精品久久久久久久久免费丝袜 | 国产精品亚洲视频| 国产精品1区2区| 国产成人精品亚洲日本在线桃色 | 国产精品天天看| 中文字幕一区二| 亚洲精品成人在线| 一区二区三区精品| 亚洲v中文字幕| 毛片不卡一区二区| 国产精品911| 99精品欧美一区| 在线精品视频一区二区三四| 国产成人精品亚洲777人妖| 国产成人精品午夜视频免费| 国产一区二区看久久| 丁香婷婷深情五月亚洲| 成人午夜激情视频| 在线视频你懂得一区二区三区| 色8久久精品久久久久久蜜| 色激情天天射综合网| 欧美日韩在线一区二区| 欧美高清一级片在线| 日韩女同互慰一区二区| 久久久久9999亚洲精品| 国产精品欧美久久久久无广告| 亚洲免费观看高清| 男女性色大片免费观看一区二区| 六月丁香综合在线视频| 国产丶欧美丶日本不卡视频| 国产一区二区0| 在线中文字幕一区| 久久在线观看免费| 一区二区三区美女| 国产一区999| 欧美色图免费看| 久久亚洲捆绑美女| 亚洲成人av在线电影| 久久成人久久鬼色| 色综合 综合色| 久久久精品免费网站| 国产精品成人一区二区艾草| 日韩理论电影院| 国产精品伊人色| 日韩小视频在线观看专区| 亚洲私人黄色宅男| 国产美女久久久久| 欧美精品丝袜中出|