亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
国产欧美日韩一区二区三区在线观看| 91亚洲资源网| 日韩一本二本av| 免费日本视频一区| 天涯成人国产亚洲精品一区av| 亚洲另类中文字| 国产三级精品视频| 中文字幕一区二区三区在线不卡| 久久久久久日产精品| 欧美一区二区在线视频| 91福利国产成人精品照片| 精品成人在线观看| 在线观看免费成人| 精品精品欲导航| 一区二区三区蜜桃网| 国产69精品久久久久777| 亚洲视频一区二区在线| 在线观看一区二区精品视频| 免费看日韩a级影片| 久久久亚洲国产美女国产盗摄| 懂色av一区二区在线播放| 国产精品二区一区二区aⅴ污介绍| 色综合久久久久综合体| 日韩高清在线观看| 精品成人一区二区三区| 国产.欧美.日韩| 亚洲成人精品一区二区| 精品久久人人做人人爰| www.欧美精品一二区| 午夜日韩在线电影| 久久婷婷综合激情| 国产精品一区二区在线播放 | 久久人人爽人人爽| 亚洲另类在线视频| 日韩美女精品在线| 一区二区理论电影在线观看| 日韩精品一区二区三区视频播放 | 在线不卡欧美精品一区二区三区| 在线看一区二区| 欧美性大战久久久久久久| 日韩午夜精品视频| 亚洲人成精品久久久久| 免费视频一区二区| 欧美日韩精品二区第二页| 久久久亚洲精品一区二区三区| 五月婷婷另类国产| 99久久精品情趣| 亚洲欧洲综合另类| 日韩午夜电影av| 99久精品国产| 天堂久久久久va久久久久| 国产精品亚洲专一区二区三区 | 欧美国产欧美综合| 日韩国产欧美一区二区三区| 欧美一级在线视频| 亚洲大片免费看| 日韩欧美国产wwwww| 免费高清不卡av| 久久久久国产精品麻豆ai换脸| 一区二区三区在线观看动漫| 成人午夜精品一区二区三区| 日韩欧美一二三| 国产精品一级片在线观看| 日韩欧美亚洲国产另类| 国产精品1区2区| 欧美精三区欧美精三区| 首页欧美精品中文字幕| 五月天欧美精品| 国产丝袜美腿一区二区三区| 懂色av中文一区二区三区| 亚洲www啪成人一区二区麻豆| 欧美绝品在线观看成人午夜影视| 日日摸夜夜添夜夜添亚洲女人| 国产欧美视频在线观看| 欧美在线色视频| 精品999久久久| bt欧美亚洲午夜电影天堂| 国产综合久久久久久久久久久久| 麻豆精品国产91久久久久久| 日本亚洲一区二区| 日韩有码一区二区三区| 日韩不卡免费视频| 免费人成网站在线观看欧美高清| 青椒成人免费视频| 麻豆国产欧美日韩综合精品二区| 日本欧美久久久久免费播放网| 日本中文字幕不卡| 久久精品国产99久久6| 精品一区二区三区的国产在线播放| 久久精品99国产国产精| 国产一区二区女| 成人中文字幕电影| 91欧美一区二区| 欧美午夜影院一区| 8v天堂国产在线一区二区| 欧美一级日韩一级| 久久久久九九视频| 日韩理论电影院| 亚洲成年人网站在线观看| 日韩精品色哟哟| 国产麻豆成人精品| 99久久精品免费看| 欧美精三区欧美精三区| 久久久久久久综合色一本| 国产精品久久午夜| 夜夜操天天操亚洲| 美女在线视频一区| 成人av免费观看| 欧美日韩精品一区二区三区四区| 日韩欧美中文一区| 国产精品妹子av| 五月激情综合婷婷| 国产一区二区三区香蕉| 91在线国内视频| 日韩一级精品视频在线观看| 中文一区在线播放| 亚洲国产精品一区二区久久| 九九精品视频在线看| 99久久精品国产一区| 91精品国产色综合久久不卡电影| 欧美精彩视频一区二区三区| 亚洲成人高清在线| 国产高清一区日本| 欧美日韩一卡二卡| 国产亚洲一区二区三区四区 | 色婷婷精品大视频在线蜜桃视频| 欧美日韩三级视频| 欧美经典一区二区| 日本欧美一区二区| 色综合久久综合| 久久久99精品久久| 午夜久久电影网| 丁香婷婷综合五月| 日韩一区二区免费电影| 一区二区三区在线播放| 国产精品99久久久久久久女警| 欧美在线你懂得| 最新久久zyz资源站| 国产又黄又大久久| 7777精品伊人久久久大香线蕉的| 亚洲欧洲三级电影| 国产九色精品成人porny| 7777精品伊人久久久大香线蕉经典版下载| 综合电影一区二区三区 | 亚洲欧美在线视频观看| 久久精品99国产精品日本| 欧美日韩国产综合一区二区| 日韩一区欧美小说| 成人污污视频在线观看| 精品裸体舞一区二区三区| 五月天激情综合| 欧美日韩美少妇| 亚洲福利一二三区| 色乱码一区二区三区88| 国产精品剧情在线亚洲| 国产精品主播直播| 精品国产1区二区| 免费成人小视频| 精品日韩一区二区三区| 免费的国产精品| 精品免费日韩av| 久久国产精品72免费观看| 欧美一卡二卡三卡| 麻豆精品蜜桃视频网站| 日韩欧美激情一区| 久久97超碰国产精品超碰| 日韩欧美国产电影| 国产主播一区二区| 久久视频一区二区| 国产精品影视在线| 欧美极品少妇xxxxⅹ高跟鞋| 丁香亚洲综合激情啪啪综合| 中文字幕不卡三区| 成人a免费在线看| 亚洲日本韩国一区| 色综合久久中文综合久久97 | 日韩欧美亚洲国产精品字幕久久久 | 久久影音资源网| 国产成人丝袜美腿| 国产精品福利一区二区三区| 91麻豆视频网站| 天天操天天色综合| 日韩一区二区不卡| 国产伦精品一区二区三区视频青涩 | 国产亚洲欧美一区在线观看| 国产激情一区二区三区四区| 欧美国产激情二区三区| 一本色道亚洲精品aⅴ| 亚洲成av人片在www色猫咪| 91麻豆精品国产91久久久久久久久 | 99综合影院在线| 亚洲综合男人的天堂| 日韩午夜小视频| 不卡视频在线看| 亚洲高清视频在线| 精品成人免费观看| 91视频你懂的| 免费人成在线不卡| 国产精品久久久久久久久免费桃花 | 91视频国产资源|