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

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

?? demo7_13.cpp

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

// 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
 
        } 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);    

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;   // dd4 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;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲高清中文字幕| 99在线精品视频| 国产99精品在线观看| 日本高清不卡视频| 欧美不卡在线视频| 亚洲免费观看在线视频| 精品一区二区三区香蕉蜜桃| 91免费在线看| 国产精品私人影院| 麻豆久久久久久| 欧美另类久久久品| 亚洲精品视频在线看| 成人久久久精品乱码一区二区三区| 欧美女孩性生活视频| 亚洲视频狠狠干| 东方欧美亚洲色图在线| 欧美白人最猛性xxxxx69交| 亚洲va韩国va欧美va| 色综合久久综合网欧美综合网 | 亚洲视频一区二区免费在线观看| 韩国欧美国产1区| 欧美精品v国产精品v日韩精品 | 国产欧美日韩激情| 久久99九九99精品| 日韩视频一区二区三区| 三级一区在线视频先锋 | 精品久久人人做人人爰| 亚洲成人av福利| 色美美综合视频| 亚洲精品国产第一综合99久久 | 自拍偷自拍亚洲精品播放| 国产一区二区成人久久免费影院| 日韩一区二区电影| 美国毛片一区二区三区| 欧美精品在线观看播放| 日本视频一区二区| 制服丝袜av成人在线看| 婷婷六月综合亚洲| 91精品国产福利| 精品在线一区二区三区| 亚洲视频在线观看一区| av电影天堂一区二区在线| 国产精品久久久久久久蜜臀| 成人自拍视频在线| 亚洲人被黑人高潮完整版| 色婷婷久久久综合中文字幕 | 欧美亚洲愉拍一区二区| 一个色综合网站| 欧美高清www午色夜在线视频| 毛片一区二区三区| 亚洲精品一区二区三区在线观看 | 欧美综合在线视频| 亚洲国产成人porn| 精品久久一区二区三区| 不卡一区在线观看| 亚洲一区二区三区四区的| 欧美精品一卡两卡| 国产激情视频一区二区在线观看| 国产精品成人免费在线| 欧美视频你懂的| 久久99国产乱子伦精品免费| 中文字幕欧美区| 欧美日韩亚洲另类| 国产一区999| 亚洲自拍偷拍欧美| 精品国产一区二区三区久久久蜜月 | 成人亚洲一区二区一| 一区二区三区四区在线播放| 91精品国产全国免费观看| 国产高清成人在线| 亚洲成人av在线电影| 国产亚洲精品资源在线26u| 一本色道久久加勒比精品| 另类人妖一区二区av| 综合av第一页| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 26uuu国产日韩综合| 成人a区在线观看| 日韩精品色哟哟| 国产精品色呦呦| 日韩一区二区不卡| 欧美在线三级电影| 高清不卡一区二区| 美女脱光内衣内裤视频久久网站| 国产精品白丝在线| 精品国一区二区三区| 在线免费观看视频一区| 国产成人精品1024| 午夜精品久久久久久久蜜桃app| 日本一区二区三区视频视频| 日韩欧美国产一区二区在线播放 | 亚洲欧美自拍偷拍色图| 日韩一级片在线播放| 91福利在线看| bt7086福利一区国产| 韩国成人精品a∨在线观看| 视频一区二区中文字幕| 亚洲美女免费视频| 中文字幕在线观看不卡| 久久影音资源网| 日韩欧美一区二区视频| 欧美日韩精品综合在线| 91高清视频免费看| 色婷婷av一区二区三区gif| 成人国产亚洲欧美成人综合网| 精品一区二区三区免费观看| 奇米精品一区二区三区在线观看一| 亚洲欧美偷拍卡通变态| 中文字幕永久在线不卡| 国产精品美女www爽爽爽| 久久久久亚洲综合| 国产午夜精品一区二区三区嫩草 | 在线免费不卡视频| 91亚洲资源网| 91免费版pro下载短视频| 成人精品高清在线| jizz一区二区| 成人av影视在线观看| 高清av一区二区| 成人精品免费看| 99视频国产精品| 91污片在线观看| 欧美性高清videossexo| 欧美日韩一区二区电影| 777亚洲妇女| 日韩女优制服丝袜电影| 337p日本欧洲亚洲大胆色噜噜| 日韩欧美国产系列| 国产亚洲美州欧州综合国| 中文字幕国产精品一区二区| 亚洲欧美在线视频| 亚洲第一激情av| 美腿丝袜一区二区三区| 狠狠色综合播放一区二区| 国产激情一区二区三区四区 | 一区二区三区日韩精品| 一二三区精品视频| 午夜激情综合网| 国产成人免费视频一区| 91视视频在线直接观看在线看网页在线看| 91社区在线播放| 91精品国产丝袜白色高跟鞋| www国产精品av| 亚洲欧美区自拍先锋| 日韩影院免费视频| 国v精品久久久网| 欧美亚洲动漫制服丝袜| 精品国产露脸精彩对白| 中文字幕在线不卡视频| 日韩和欧美一区二区三区| 国产精品资源在线| 精品视频一区二区不卡| 精品久久久久久久久久久院品网 | 欧美日韩国产精选| 国产片一区二区三区| 午夜天堂影视香蕉久久| 国产一区二区0| 91福利视频网站| 久久久久久免费毛片精品| 亚洲一区二区三区自拍| 久草这里只有精品视频| 欧洲精品在线观看| 国产日韩欧美精品综合| 日韩不卡一二三区| 99re亚洲国产精品| 久久综合成人精品亚洲另类欧美 | 国产成人亚洲综合a∨猫咪| 在线看一区二区| 国产精品视频麻豆| 免费一级欧美片在线观看| 91老师片黄在线观看| 久久久久久久网| 日韩高清电影一区| 91久久香蕉国产日韩欧美9色| 精品88久久久久88久久久| 亚洲国产裸拍裸体视频在线观看乱了| 国产99久久久久久免费看农村| 8x8x8国产精品| 亚洲精品免费一二三区| 国产+成+人+亚洲欧洲自线| 91精品国产色综合久久久蜜香臀| 亚洲精品免费在线播放| 99麻豆久久久国产精品免费| 精品国产污污免费网站入口 | proumb性欧美在线观看| 久久美女艺术照精彩视频福利播放| 日本免费新一区视频| 欧美日韩一区 二区 三区 久久精品| 国产精品久久久久aaaa樱花| 韩国女主播一区| 精品sm在线观看| 蜜臀av性久久久久蜜臀aⅴ流畅 | 日本视频一区二区三区| 欧美网站一区二区| 亚洲一区在线观看免费 | 91福利精品视频| 亚洲欧美色综合| 色综合夜色一区| 亚洲激情男女视频| 欧美性色黄大片|