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

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

?? demo7_14.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
// DEMO7_14.CPP 8-bit blitting demo with scaling

// INCLUDES ///////////////////////////////////////////////

#define WIN32_LEAN_AND_MEAN  // just say no to MFC

#define INITGUID

#include <windows.h>   // include important windows stuff
#include <windowsx.h> 
#include <mmsystem.h>
#include <iostream.h> // include important C/C++ stuff
#include <conio.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h> 
#include <math.h>
#include <io.h>
#include <fcntl.h>

#include <ddraw.h> // include directdraw

// DEFINES ////////////////////////////////////////////////

// defines for windows 
#define WINDOW_CLASS_NAME "WINCLASS1"

// default screen size
#define SCREEN_WIDTH    640  // size of screen
#define SCREEN_HEIGHT   480
#define SCREEN_BPP      8    // bits per pixel

#define BITMAP_ID            0x4D42 // universal id for a bitmap
#define MAX_COLORS_PALETTE   256

// TYPES //////////////////////////////////////////////////////

// basic unsigned types
typedef unsigned short USHORT;
typedef unsigned short WORD;
typedef unsigned char  UCHAR;
typedef unsigned char  BYTE;

// container structure for bitmaps .BMP file
typedef struct BITMAP_FILE_TAG
        {
        BITMAPFILEHEADER bitmapfileheader;  // this contains the bitmapfile header
        BITMAPINFOHEADER bitmapinfoheader;  // this is all the info including the palette
        PALETTEENTRY     palette[256];      // we will store the palette here
        UCHAR            *buffer;           // this is a pointer to the data

        } BITMAP_FILE, *BITMAP_FILE_PTR;

// this will hold our little alien
typedef struct ALIEN_OBJ_TYP
        {
        LPDIRECTDRAWSURFACE7 frames[3]; // 3 frames of animation for complete walk cycle
        int x,y;                        // position of alien
        int velocity;                   // x-velocity
        int current_frame;              // current frame of animation
        int counter;                    // used to time animation
        int width; 
        int height;                     // size of surface
        float scale;                    // scale of object
 
        } ALIEN_OBJ, *ALIEN_OBJ_PTR;

// PROTOTYPES  //////////////////////////////////////////////

int Flip_Bitmap(UCHAR *image, int bytes_per_line, int height);

int Load_Bitmap_File(BITMAP_FILE_PTR bitmap, char *filename);

int Unload_Bitmap_File(BITMAP_FILE_PTR bitmap);

int DDraw_Fill_Surface(LPDIRECTDRAWSURFACE7 lpdds,int color);

int Scan_Image_Bitmap(BITMAP_FILE_PTR bitmap, LPDIRECTDRAWSURFACE7 lpdds, int cx,int cy);

LPDIRECTDRAWSURFACE7 DDraw_Create_Surface(int width, int height, int mem_flags, int color_key);

int DDraw_Draw_Surface(LPDIRECTDRAWSURFACE7 source, int x, int y, 
                      int width, int height, LPDIRECTDRAWSURFACE7 dest, 
                      int transparent);    

int DDraw_Draw_Surface_Scaled(LPDIRECTDRAWSURFACE7 source, int x, int y, 
                      int width_src, int height_src, int width_dest, int height_dest, 
                      LPDIRECTDRAWSURFACE7 dest,  int transparent);   

LPDIRECTDRAWCLIPPER DDraw_Attach_Clipper(LPDIRECTDRAWSURFACE7 lpdds,
                                         int num_rects,
                                         LPRECT clip_list);

int Draw_Text_GDI(char *text, int x,int y,COLORREF color, LPDIRECTDRAWSURFACE7 lpdds);

// MACROS /////////////////////////////////////////////////

// tests if a key is up or down
#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
#define KEYUP(vk_code)   ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)

// initializes a direct draw struct
#define DDRAW_INIT_STRUCT(ddstruct) { memset(&ddstruct,0,sizeof(ddstruct)); ddstruct.dwSize=sizeof(ddstruct); }

// GLOBALS ////////////////////////////////////////////////

HWND      main_window_handle = NULL; // globally track main window
int       window_closed      = 0;    // tracks if window is closed
HINSTANCE hinstance_app      = NULL; // globally track hinstance

// directdraw stuff

LPDIRECTDRAW7         lpdd         = NULL;   // dd object
LPDIRECTDRAWSURFACE7  lpddsprimary = NULL;   // dd primary surface
LPDIRECTDRAWSURFACE7  lpddsback    = NULL;   // dd back surface
LPDIRECTDRAWPALETTE   lpddpal      = NULL;   // a pointer to the created dd palette
LPDIRECTDRAWCLIPPER   lpddclipper  = NULL;   // dd clipper
PALETTEENTRY          palette[256];          // color palette
PALETTEENTRY          save_palette[256];     // used to save palettes
DDSURFACEDESC2        ddsd;                  // a direct draw surface description struct
DDBLTFX               ddbltfx;               // used to fill
DDSCAPS2              ddscaps;               // a direct draw surface capabilities struct
HRESULT               ddrval;                // result back from dd calls
DWORD                 start_clock_count = 0; // used for timing

BITMAP_FILE           bitmap;                // holds the bitmap

ALIEN_OBJ             aliens[3];             // 3 aliens, one on each level

LPDIRECTDRAWSURFACE7  lpddsbackground = NULL;// this will hold the background image

char buffer[80];                             // general printing buffer

int gwidth  = -1;
int gheight = -1;

// FUNCTIONS ////////////////////////////////////////////////

int Load_Bitmap_File(BITMAP_FILE_PTR bitmap, char *filename)
{
// this function opens a bitmap file and loads the data into bitmap

int file_handle,  // the file handle
    index;        // looping index

UCHAR   *temp_buffer = NULL; // used to convert 24 bit images to 16 bit
OFSTRUCT file_data;          // the file data information

// open the file if it exists
if ((file_handle = OpenFile(filename,&file_data,OF_READ))==-1)
   return(0);

// now load the bitmap file header
_lread(file_handle, &bitmap->bitmapfileheader,sizeof(BITMAPFILEHEADER));

// test if this is a bitmap file
if (bitmap->bitmapfileheader.bfType!=BITMAP_ID)
   {
   // close the file
   _lclose(file_handle);

   // return error
   return(0);
   } // end if

// now we know this is a bitmap, so read in all the sections

// first the bitmap infoheader

// now load the bitmap file header
_lread(file_handle, &bitmap->bitmapinfoheader,sizeof(BITMAPINFOHEADER));

// now load the color palette if there is one
if (bitmap->bitmapinfoheader.biBitCount == 8)
   {
   _lread(file_handle, &bitmap->palette,MAX_COLORS_PALETTE*sizeof(PALETTEENTRY));

   // now set all the flags in the palette correctly and fix the reversed 
   // BGR RGBQUAD data format
   for (index=0; index < MAX_COLORS_PALETTE; index++)
       {
       // reverse the red and green fields
       int temp_color                = bitmap->palette[index].peRed;
       bitmap->palette[index].peRed  = bitmap->palette[index].peBlue;
       bitmap->palette[index].peBlue = temp_color;
       
       // always set the flags word to this
       bitmap->palette[index].peFlags = PC_NOCOLLAPSE;
       } // end for index

    } // end if

// finally the image data itself
_lseek(file_handle,-(int)(bitmap->bitmapinfoheader.biSizeImage),SEEK_END);

// now read in the image, if the image is 8 or 16 bit then simply read it
// but if its 24 bit then read it into a temporary area and then convert
// it to a 16 bit image

if (bitmap->bitmapinfoheader.biBitCount==8 || bitmap->bitmapinfoheader.biBitCount==16 || 
    bitmap->bitmapinfoheader.biBitCount==24)
   {
   // delete the last image if there was one
   if (bitmap->buffer)
       free(bitmap->buffer);

   // allocate the memory for the image
   if (!(bitmap->buffer = (UCHAR *)malloc(bitmap->bitmapinfoheader.biSizeImage)))
      {
      // close the file
      _lclose(file_handle);

      // return error
      return(0);
      } // end if

   // now read it in
   _lread(file_handle,bitmap->buffer,bitmap->bitmapinfoheader.biSizeImage);

   } // end if
else
   {
   // serious problem
   return(0);

   } // end else

#if 0
// write the file info out 
printf("\nfilename:%s \nsize=%d \nwidth=%d \nheight=%d \nbitsperpixel=%d \ncolors=%d \nimpcolors=%d",
        filename,
        bitmap->bitmapinfoheader.biSizeImage,
        bitmap->bitmapinfoheader.biWidth,
        bitmap->bitmapinfoheader.biHeight,
		bitmap->bitmapinfoheader.biBitCount,
        bitmap->bitmapinfoheader.biClrUsed,
        bitmap->bitmapinfoheader.biClrImportant);
#endif

// close the file
_lclose(file_handle);

// flip the bitmap
Flip_Bitmap(bitmap->buffer, 
            bitmap->bitmapinfoheader.biWidth*(bitmap->bitmapinfoheader.biBitCount/8), 
            bitmap->bitmapinfoheader.biHeight);

// return success
return(1);

} // end Load_Bitmap_File

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

int Unload_Bitmap_File(BITMAP_FILE_PTR bitmap)
{
// this function releases all memory associated with "bitmap"
if (bitmap->buffer)
   {
   // release memory
   free(bitmap->buffer);

   // reset pointer
   bitmap->buffer = NULL;

   } // end if

// return success
return(1);

} // end Unload_Bitmap_File

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

int Flip_Bitmap(UCHAR *image, int bytes_per_line, int height)
{
// this function is used to flip bottom-up .BMP images

UCHAR *buffer; // used to perform the image processing
int index;     // looping index

// allocate the temporary buffer
if (!(buffer = (UCHAR *)malloc(bytes_per_line*height)))
   return(0);

// copy image to work area
memcpy(buffer,image,bytes_per_line*height);

// flip vertically
for (index=0; index < height; index++)
    memcpy(&image[((height-1) - index)*bytes_per_line],
           &buffer[index*bytes_per_line], bytes_per_line);

// release the memory
free(buffer);

// return success
return(1);

} // end Flip_Bitmap

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

LPDIRECTDRAWCLIPPER DDraw_Attach_Clipper(LPDIRECTDRAWSURFACE7 lpdds,
                                         int num_rects,
                                         LPRECT clip_list)

{
// this function creates a clipper from the sent clip list and attaches
// it to the sent surface

int index;                         // looping var
LPDIRECTDRAWCLIPPER lpddclipper;   // pointer to the newly created dd clipper
LPRGNDATA region_data;             // pointer to the region data that contains
                                   // the header and clip list

// first create the direct draw clipper
if (FAILED(lpdd->CreateClipper(0,&lpddclipper,NULL)))
   return(NULL);

// now create the clip list from the sent data

// first allocate memory for region data
region_data = (LPRGNDATA)malloc(sizeof(RGNDATAHEADER)+num_rects*sizeof(RECT));

// now copy the rects into region data
memcpy(region_data->Buffer, clip_list, sizeof(RECT)*num_rects);

// set up fields of header
region_data->rdh.dwSize          = sizeof(RGNDATAHEADER);
region_data->rdh.iType           = RDH_RECTANGLES;
region_data->rdh.nCount          = num_rects;
region_data->rdh.nRgnSize        = num_rects*sizeof(RECT);

region_data->rdh.rcBound.left    =  64000;
region_data->rdh.rcBound.top     =  64000;
region_data->rdh.rcBound.right   = -64000;
region_data->rdh.rcBound.bottom  = -64000;

// find bounds of all clipping regions
for (index=0; index<num_rects; index++)
    {
    // test if the next rectangle unioned with the current bound is larger
    if (clip_list[index].left < region_data->rdh.rcBound.left)
       region_data->rdh.rcBound.left = clip_list[index].left;

    if (clip_list[index].right > region_data->rdh.rcBound.right)
       region_data->rdh.rcBound.right = clip_list[index].right;

    if (clip_list[index].top < region_data->rdh.rcBound.top)
       region_data->rdh.rcBound.top = clip_list[index].top;

    if (clip_list[index].bottom > region_data->rdh.rcBound.bottom)
       region_data->rdh.rcBound.bottom = clip_list[index].bottom;

    } // end for index

// now we have computed the bounding rectangle region and set up the data
// now let's set the clipping list

if (FAILED(lpddclipper->SetClipList(region_data, 0)))
   {
   // release memory and return error
   free(region_data);
   return(NULL);
   } // end if

// now attach the clipper to the surface
if (FAILED(lpdds->SetClipper(lpddclipper)))
   {
   // release memory and return error
   free(region_data);
   return(NULL);
   } // end if

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品精品亚洲| 99久久精品国产精品久久| 懂色av一区二区夜夜嗨| 欧美在线一区二区| 亚洲天堂网中文字| 国产成人自拍网| 精品国产乱码久久久久久免费| 1000精品久久久久久久久| 精品一区二区av| 91精品国产一区二区三区| 亚洲免费资源在线播放| 国产成人高清视频| 精品国产一区二区三区不卡| 午夜精品久久久久久久| 色欧美片视频在线观看| 中文字幕一区免费在线观看| 国产成人免费xxxxxxxx| 精品国产91九色蝌蚪| 轻轻草成人在线| 在线播放欧美女士性生活| 一区二区三区在线观看国产| 波多野结衣一区二区三区| 久久亚洲综合色一区二区三区 | 欧美男生操女生| 亚洲蜜臀av乱码久久精品蜜桃| 成人av资源站| 国产欧美日韩在线看| 国产在线播精品第三| 精品日韩在线一区| 国产一区二区三区四| 久久九九久久九九| 成人激情图片网| 亚洲欧美日韩在线不卡| 在线免费不卡视频| 天涯成人国产亚洲精品一区av| 91精品国产综合久久久蜜臀粉嫩 | 色婷婷久久一区二区三区麻豆| 国产精品色呦呦| 99综合电影在线视频| 亚洲欧美经典视频| 欧美日韩一二三| 日本亚洲欧美天堂免费| 2021国产精品久久精品| 国产成人精品综合在线观看 | 性欧美疯狂xxxxbbbb| 在线观看欧美精品| 日韩高清在线一区| 久久尤物电影视频在线观看| 岛国av在线一区| 一区二区激情小说| 91精品国产色综合久久不卡电影| 韩国视频一区二区| 最新成人av在线| 6080国产精品一区二区| 国产一区二区三区免费播放| 亚洲四区在线观看| 欧美日韩高清一区二区不卡| 国产精品一区二区在线观看不卡| 一区免费观看视频| 91精品国产综合久久精品app| 国内精品久久久久影院色| 综合激情成人伊人| 717成人午夜免费福利电影| 国内精品久久久久影院一蜜桃| 亚洲欧美一区二区三区极速播放| 欧美一级片免费看| 91麻豆视频网站| 九色综合国产一区二区三区| 国产精品久久久久婷婷二区次| 欧美日韩一二三区| 成人综合婷婷国产精品久久| 午夜精品久久久久久久蜜桃app| 久久精品人人做| 欧美区一区二区三区| 不卡的av网站| 激情综合五月婷婷| 午夜伊人狠狠久久| 亚洲视频中文字幕| 久久久不卡影院| 欧美一区二区日韩一区二区| av爱爱亚洲一区| 国产精品一级片| 日韩高清中文字幕一区| 亚洲免费av网站| 国产精品视频线看| 久久久青草青青国产亚洲免观| 欧美高清www午色夜在线视频| 91在线一区二区三区| 国产激情精品久久久第一区二区| 亚洲一区二区三区四区在线观看 | 国产欧美日韩视频一区二区 | 中文字幕亚洲电影| 国产午夜精品一区二区三区嫩草| 制服丝袜日韩国产| 欧美午夜影院一区| 在线观看国产一区二区| 波多野结衣91| 丁香天五香天堂综合| 精品一区二区三区在线观看国产| 亚洲成人激情自拍| 亚洲不卡在线观看| 亚洲国产裸拍裸体视频在线观看乱了 | 欧美大黄免费观看| 欧美日韩成人在线一区| 91激情在线视频| 在线亚洲高清视频| 在线观看精品一区| 欧美视频一区二区在线观看| 色乱码一区二区三区88| 97精品久久久午夜一区二区三区| 成人美女视频在线观看18| 成人性生交大片免费看中文网站| 国产一区二区精品久久91| 国内精品免费在线观看| 国产精品888| 成人爽a毛片一区二区免费| 成人性生交大片| 99riav一区二区三区| 99精品视频免费在线观看| 色88888久久久久久影院野外| 在线观看日韩毛片| 欧美精品一二三| 日韩欧美国产精品一区| 久久亚洲捆绑美女| 国产精品久久久久婷婷| 亚洲精品乱码久久久久久久久| 亚洲一区二区在线视频| 日本在线不卡视频一二三区| 久久se这里有精品| 成人av免费在线| 色系网站成人免费| 欧美一区二区人人喊爽| 久久精品亚洲精品国产欧美kt∨ | 在线视频欧美精品| 欧美日韩免费一区二区三区| 欧美一区二区三区在线看| www久久精品| 一本一道久久a久久精品综合蜜臀 一本一道综合狠狠老 | 成人一区二区三区视频在线观看| 国产91高潮流白浆在线麻豆| 99久久精品国产网站| 在线视频你懂得一区| 日韩欧美国产一区二区三区| 欧美国产精品一区| 一区二区三区在线观看网站| 久久精品国产在热久久| 91在线免费播放| 欧美一区永久视频免费观看| 国产精品无码永久免费888| 亚洲精品国产第一综合99久久 | 国产视频亚洲色图| 亚洲在线观看免费| 国产精品一二三区在线| 欧美午夜精品一区二区蜜桃| 久久精品亚洲乱码伦伦中文| 亚洲国产成人va在线观看天堂| 国产福利一区在线观看| 欧美日韩成人综合| 日韩毛片视频在线看| 韩国女主播成人在线| 欧美色图免费看| 亚洲欧洲国产专区| 精品在线免费观看| 欧美日韩亚洲综合在线| 国产精品免费网站在线观看| 免费观看日韩av| 欧美在线啊v一区| 亚洲国产经典视频| 国产自产视频一区二区三区| 欧美怡红院视频| 亚洲丝袜制服诱惑| 国产成人精品综合在线观看 | 欧美一区二区三区播放老司机| 亚洲视频你懂的| 国产精品伊人色| 在线综合+亚洲+欧美中文字幕| 综合在线观看色| 国产乱子伦视频一区二区三区| 欧美年轻男男videosbes| 亚洲欧美福利一区二区| 国产91精品久久久久久久网曝门 | caoporn国产精品| 久久久精品影视| 狠狠色丁香婷婷综合久久片| 欧美高清www午色夜在线视频| 亚洲一级二级三级| 色狠狠一区二区| 亚洲免费观看在线视频| 岛国精品在线观看| 国产精品美女久久久久久2018| 国内精品国产三级国产a久久| 日韩亚洲欧美一区| 日本网站在线观看一区二区三区| 欧美日韩亚洲综合一区二区三区| 亚洲影视资源网| 欧美日韩在线亚洲一区蜜芽| 午夜一区二区三区在线观看| 337p亚洲精品色噜噜| 全部av―极品视觉盛宴亚洲| 精品久久人人做人人爱|