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

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

?? demo7_12.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
// DEMO7_12.CPP 24-bit bitmap loading 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      32   // 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;

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

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

// this builds a 16 bit color value in 5.5.5 format (1-bit alpha mode)
#define _RGB16BIT555(r,g,b) ((b & 31) + ((g & 31) << 5) + ((r & 31) << 10))

// this builds a 16 bit color value in 5.6.5 format (green dominate mode)
#define _RGB16BIT565(r,g,b) ((b & 31) + ((g & 63) << 5) + ((r & 31) << 11))

// this builds a 32 bit color value in A.8.8.8 format (8-bit alpha mode)
#define _RGB32BIT(a,r,g,b) ((b) + ((g) << 8) + ((r) << 16) + ((a) << 24))

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

char buffer[80];                             // general printing buffer

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

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

LRESULT CALLBACK WindowProc(HWND hwnd, 
						    UINT msg, 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美一区二区三区在线| 性感美女极品91精品| 一区二区在线电影| 狠狠久久亚洲欧美| 欧美视频精品在线观看| 久久精品视频一区二区三区| 亚洲成av人片在线观看| 成人三级伦理片| 日韩女优毛片在线| 亚洲丰满少妇videoshd| www.一区二区| 国产欧美一区二区三区沐欲| 蜜臀精品久久久久久蜜臀| 欧美性猛片xxxx免费看久爱| 国产精品女同一区二区三区| 狠狠色丁香婷婷综合久久片| 7777女厕盗摄久久久| 亚洲图片欧美一区| 91成人国产精品| 亚洲美女视频在线观看| 国产成人午夜高潮毛片| 久久一二三国产| 免费久久精品视频| 91精品中文字幕一区二区三区| 亚洲激情中文1区| 欧美亚洲愉拍一区二区| 亚洲精品乱码久久久久| 色8久久精品久久久久久蜜| 国产精品素人一区二区| 高清在线不卡av| 中文字幕精品综合| 成人午夜电影网站| 国产精品久久午夜夜伦鲁鲁| 国产成人av一区| 国产精品免费av| 91免费观看国产| 一区二区三区在线播放| 欧美色窝79yyyycom| 亚洲福利一区二区| 91精品国产高清一区二区三区蜜臀 | 亚洲天堂免费看| 色婷婷综合久久久中文一区二区| 亚洲精品国产第一综合99久久| 色8久久精品久久久久久蜜| 亚洲国产欧美在线人成| 欧美一区二区三区爱爱| 精品一区二区影视| 中文字幕欧美日本乱码一线二线| 丁香婷婷综合五月| 亚洲精品成人天堂一二三| 欧美日韩国产在线观看| 精品一区二区在线观看| 国产精品美女一区二区在线观看| 99久久精品国产导航| 午夜视频在线观看一区| 久久先锋影音av| 色综合久久综合网97色综合| 亚洲成人av电影| 久久精品免费在线观看| 欧美中文字幕不卡| 国产一区999| 一区二区日韩av| 久久综合久色欧美综合狠狠| 99国产精品久久久久久久久久久| 亚洲精品欧美激情| 久久婷婷色综合| 欧美视频自拍偷拍| 国产原创一区二区| 亚洲国产一区二区视频| 久久久久久久久久久久电影| 色香色香欲天天天影视综合网| 日韩高清电影一区| 亚洲欧洲www| 欧美成人在线直播| 99re视频精品| 国内精品久久久久影院一蜜桃| 亚洲三级免费观看| 久久久久久久久蜜桃| 色av一区二区| jlzzjlzz亚洲日本少妇| 美国三级日本三级久久99| 亚洲免费观看高清完整版在线观看 | 久久久不卡网国产精品一区| 欧美丝袜丝交足nylons| 粉嫩嫩av羞羞动漫久久久| 日韩国产精品久久久| 中文字幕欧美一| 久久免费电影网| 日韩女优av电影在线观看| 日本韩国欧美一区| 不卡大黄网站免费看| 狠狠色丁香婷婷综合| 日本 国产 欧美色综合| 亚洲国产中文字幕| 亚洲自拍都市欧美小说| 1024成人网| 中文av一区二区| 日本一二三四高清不卡| 日韩欧美一区中文| 在线观看亚洲精品| 色综合久久99| 色一情一乱一乱一91av| 成人性视频免费网站| 国产乱对白刺激视频不卡| 看片网站欧美日韩| 久热成人在线视频| 麻豆91免费观看| 久久99久久久欧美国产| 久久精品国产亚洲aⅴ| 日本欧美一区二区在线观看| 亚洲第一主播视频| 日韩中文字幕不卡| 久久精品噜噜噜成人av农村| 久久99精品久久久久婷婷| 精品一区二区三区日韩| 久久国产尿小便嘘嘘尿| 国产制服丝袜一区| 国产成人精品亚洲777人妖 | 欧美性猛片aaaaaaa做受| 欧洲一区二区三区在线| 欧美日韩一二三区| 日韩欧美美女一区二区三区| 日韩欧美国产一区二区在线播放| 精品裸体舞一区二区三区| www精品美女久久久tv| 久久女同互慰一区二区三区| 久久先锋影音av鲁色资源| 欧美国产日韩一二三区| 综合激情成人伊人| 三级精品在线观看| 国产最新精品精品你懂的| 成人综合日日夜夜| 欧美三区免费完整视频在线观看| 欧美日韩精品综合在线| 日韩精品最新网址| 欧美激情一区在线| 亚洲影视资源网| 精品午夜久久福利影院| 成人免费看片app下载| 色久综合一二码| 日韩欧美国产系列| 中文字幕五月欧美| 亚洲一区二区综合| 国产尤物一区二区| 色先锋aa成人| 精品三级在线看| 亚洲欧美日韩中文播放 | 成人听书哪个软件好| 在线观看日产精品| 久久影视一区二区| 亚洲已满18点击进入久久| 麻豆国产精品官网| 91亚洲精品乱码久久久久久蜜桃| 欧美乱熟臀69xxxxxx| 国产日韩欧美不卡在线| 亚洲综合自拍偷拍| 国产精品2024| 欧美日韩国产成人在线91| 久久久久久黄色| 亚洲成av人片一区二区三区| 国产成人精品免费在线| 欧美精品1区2区3区| 国产精品不卡视频| 国产精品一区二区在线播放 | 亚洲福利一区二区三区| 国产精品自拍av| 9191久久久久久久久久久| 国产女人18毛片水真多成人如厕 | 国产丝袜美腿一区二区三区| 一区二区三区蜜桃| 成人免费av网站| 精品99999| 日韩国产高清影视| 在线欧美小视频| 亚洲视频狠狠干| 国产米奇在线777精品观看| 在线成人高清不卡| 午夜视频在线观看一区二区三区| 97se亚洲国产综合自在线不卡| 欧美精品一区男女天堂| 美女视频一区二区| 911精品国产一区二区在线| 亚洲美女屁股眼交3| 成人高清在线视频| 欧美国产1区2区| 国产成人福利片| 久久品道一品道久久精品| 美女视频免费一区| 欧美成人精品福利| 久久99最新地址| 精品国偷自产国产一区| 美日韩一区二区| 欧美电影免费提供在线观看| 日本不卡一区二区三区高清视频| 在线观看不卡一区| 午夜国产不卡在线观看视频| 欧美视频三区在线播放| 婷婷久久综合九色综合绿巨人| 欧美午夜不卡视频| 日日夜夜免费精品视频|