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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? demo7_14.cpp

?? 一本外國人寫的關(guān)于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

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
洋洋av久久久久久久一区| 欧美国产精品中文字幕| 香蕉影视欧美成人| 欧美日韩精品免费| 青青草91视频| 久久亚洲欧美国产精品乐播 | 日韩午夜在线观看视频| 久久国产精品免费| 国产性色一区二区| 99国产精品国产精品毛片| 亚洲日本丝袜连裤袜办公室| 色狠狠色狠狠综合| 美女网站在线免费欧美精品| 久久嫩草精品久久久精品| www.欧美日韩| 视频一区在线视频| 国产亚洲视频系列| 欧美性猛片aaaaaaa做受| 蜜臀av性久久久久av蜜臀妖精| 欧美videofree性高清杂交| 成人午夜又粗又硬又大| 一区二区不卡在线视频 午夜欧美不卡在| 欧美疯狂性受xxxxx喷水图片| 久久av老司机精品网站导航| 中文一区二区在线观看| 欧美日韩黄色一区二区| 韩国一区二区三区| 一区二区在线免费观看| 日韩欧美一区在线| aaa亚洲精品| 美美哒免费高清在线观看视频一区二区| www久久精品| 欧美视频一区二区三区四区| 韩国视频一区二区| 亚洲图片自拍偷拍| 日本一区二区在线不卡| 欧美日韩不卡视频| www.亚洲激情.com| 久久精品国产亚洲高清剧情介绍 | 国产精品天美传媒| 欧美精品在欧美一区二区少妇| 国产成人综合精品三级| 天堂成人国产精品一区| 亚洲欧洲三级电影| 精品国产91九色蝌蚪| 欧美日韩国产片| 北岛玲一区二区三区四区| 国内偷窥港台综合视频在线播放| 亚洲综合一区在线| 国产日韩精品一区二区三区在线| 欧美伦理视频网站| 91视频观看免费| 成人性生交大片免费看在线播放| 麻豆国产精品视频| 午夜在线成人av| 亚洲色图欧洲色图婷婷| 国产午夜精品一区二区三区视频 | 亚洲成人在线免费| 亚洲欧洲色图综合| 欧美国产日韩亚洲一区| 欧美mv日韩mv国产网站app| 欧美日韩精品综合在线| 一本一本久久a久久精品综合麻豆| 国产精品一级片| 久久精品国产成人一区二区三区| 午夜精品久久久久影视| 依依成人综合视频| 日韩理论片中文av| 中文字幕色av一区二区三区| 国产视频在线观看一区二区三区 | 午夜精品一区二区三区电影天堂 | 懂色av中文一区二区三区| 国产在线精品一区在线观看麻豆| 婷婷激情综合网| 亚洲成人av电影| 亚洲第一综合色| 日韩影院免费视频| 日本美女一区二区三区视频| 日韩精品久久理论片| 亚洲va中文字幕| 五月婷婷久久丁香| 免费av网站大全久久| 免费精品99久久国产综合精品| 亚洲图片一区二区| 日韩1区2区日韩1区2区| 蜜臀久久久久久久| 国内一区二区在线| 国产盗摄精品一区二区三区在线| 国产suv精品一区二区6| 99久久精品国产一区二区三区| aaa亚洲精品一二三区| 在线观看区一区二| 欧美一区二区在线观看| 欧美成人vps| 中文字幕的久久| 亚洲欧美日韩人成在线播放| 亚洲午夜精品久久久久久久久| 亚洲成a人v欧美综合天堂下载| 午夜精品久久久久久不卡8050| 日韩电影在线一区| 国产一区二区三区精品视频| 高清不卡一区二区在线| 91亚洲男人天堂| 欧美日韩国产bt| 精品国产1区二区| 中文字幕欧美一区| 午夜欧美大尺度福利影院在线看| 久久成人羞羞网站| av网站一区二区三区| 在线观看国产91| 欧美tk—视频vk| 亚洲丝袜另类动漫二区| 日本美女视频一区二区| 成人av小说网| 欧美二区三区的天堂| 久久免费视频色| 亚洲午夜久久久久久久久电影院| 久久精品国产在热久久| 91一区二区在线| 精品av久久707| 亚洲高清视频在线| 国产精品一卡二| 欧美日韩国产一级二级| 日本一区二区成人| 青娱乐精品视频| 91老师片黄在线观看| 精品久久久久99| 午夜影院久久久| 97成人超碰视| 久久精品视频一区二区三区| 亚洲愉拍自拍另类高清精品| 精品一区二区av| 欧美色网站导航| 国产精品视频免费| 久久国产精品一区二区| 在线观看一区日韩| 国产精品国产三级国产a| 蜜臀av在线播放一区二区三区 | 9191国产精品| 中文字幕一区视频| 国产一区欧美二区| 欧美一区二区三区四区在线观看| 1024成人网| 高清不卡一区二区| 国产欧美日韩综合| 老鸭窝一区二区久久精品| 在线免费不卡视频| 亚洲日本在线看| 成人精品电影在线观看| 久久综合成人精品亚洲另类欧美| 五月开心婷婷久久| 欧美中文字幕一区二区三区亚洲| 国产精品久久久久婷婷| 国产九色精品成人porny| 精品日韩在线观看| 久久97超碰色| 欧美一级黄色片| 亚洲第一狼人社区| 欧美日韩一区二区三区高清| 亚洲视频你懂的| 91日韩精品一区| 最新国产精品久久精品| 99久久久精品| 亚洲欧美福利一区二区| 91在线视频观看| 亚洲精品高清在线观看| 一本大道久久a久久综合婷婷| 亚洲欧洲韩国日本视频| 99精品国产视频| 亚洲精品一卡二卡| 欧美视频自拍偷拍| 日韩av电影免费观看高清完整版| 欧美日韩另类一区| 免费在线观看成人| 欧美精品一区二区三区一线天视频| 蜜桃一区二区三区在线| 精品人伦一区二区色婷婷| 蜜桃av一区二区在线观看| 欧美大片在线观看一区二区| 麻豆精品一区二区综合av| 久久久久青草大香线综合精品| 国产成人精品三级| 亚洲色大成网站www久久九九| 91美女片黄在线观看91美女| 亚洲一区二区三区激情| 在线播放欧美女士性生活| 久久精品国产精品亚洲红杏| 国产日韩影视精品| 99精品欧美一区二区三区综合在线| 亚洲美女精品一区| 欧美精品国产精品| 久久99精品一区二区三区| 日本一区二区三区在线不卡| 99re这里都是精品| 亚洲一区二区三区四区在线观看| 欧美乱妇15p| 国产99久久久国产精品潘金| 亚洲综合色成人| 欧美一个色资源| www.亚洲激情.com|