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

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

?? demo7_15.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
// DEMO7_15.CPP 8-bit color animation 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

// defines for Blink_Colors
#define BLINKER_ADD           0    // add a light to database  
#define BLINKER_DELETE        1    // delete a light from database
#define BLINKER_UPDATE        2    // update a light
#define BLINKER_RUN           3    // run normal

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

// blinking light structure
typedef struct BLINKER_TYP
               {
               // user sets these
               int color_index;         // index of color to blink
               PALETTEENTRY on_color;   // RGB value of "on" color
               PALETTEENTRY off_color;  // RGB value of "off" color
               int on_time;             // number of frames to keep "on" 
               int off_time;            // number of frames to keep "off"

               // internal member
               int counter;             // counter for state transitions
               int state;               // state of light, -1 off, 1 on, 0 dead
               } BLINKER, *BLINKER_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 Blink_Colors(int command, BLINKER_PTR new_light, int id);

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

char buffer[80];                             // general printing buffer

int green_id = -1, red_id = -1;              // these hold the ids of blinkers

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

int Blink_Colors(int command, BLINKER_PTR new_light, int id)
{
// this function blinks a set of lights

static BLINKER lights[256]; // supports up to 256 blinking lights
static int initialized = 0; // tracks if function has initialized

// test if this is the first time function has ran
if (!initialized)
   {
   // set initialized
   initialized = 1;

   // clear out all structures
   memset((void *)lights,0, sizeof(lights));

   } // end if

// now test what command user is sending
switch (command)
       {
       case BLINKER_ADD: // add a light to the database
            {
            // run thru database and find an open light
            for (int index=0; index < 256; index++)
                {
                // is this light available?
                if (lights[index].state == 0)
                   {
                   // set light up
                   lights[index] = *new_light;

                   // set internal fields up
                   lights[index].counter =  0;
                   lights[index].state   = -1; // off

                   // update palette entry
                   lpddpal->SetEntries(0,lights[index].color_index,1,&lights[index].off_color);
 
                   // return id to caller
                   return(index);

                   } // end if

                } // end for index

            } break;

       case BLINKER_DELETE: // delete the light indicated by id
            {
            // delete the light sent in id 
            if (lights[id].state != 0)
               {
               // kill the light
               memset((void *)&lights[id],0,sizeof(BLINKER));

               // return id
               return(id);
 
               } // end if
            else
                return(-1); // problem


            } break;

       case BLINKER_UPDATE: // update the light indicated by id
            { 
            // make sure light is active
            if (lights[id].state != 0)
               {
               // update on/off parms only
               lights[id].on_color  = new_light->on_color; 
               lights[id].off_color = new_light->off_color;
               lights[id].on_time   = new_light->on_time;
               lights[id].off_time  = new_light->off_time; 

               // update palette entry
               if (lights[id].state == -1)
                  lpddpal->SetEntries(0,lights[id].color_index,1,&lights[id].off_color);
               else
                  lpddpal->SetEntries(0,lights[id].color_index,1,&lights[id].on_color);

               // return id
               return(id);
 
               } // end if
            else
                return(-1); // problem

            } break;

       case BLINKER_RUN: // run the algorithm
            {
            // run thru database and process each light
            for (int index=0; index < 256; index++)
                {
                // is this active?
                if (lights[index].state == -1)
                   {
                   // update counter
                   if (++lights[index].counter >= lights[index].off_time)
                      {
                      // reset counter
                      lights[index].counter = 0;

                      // change states 
                      lights[index].state = -lights[index].state;               
 
                      // update color
                      lpddpal->SetEntries(0,lights[index].color_index,1,&lights[index].on_color);
 
                      } // end if
                 
                   } // end if
                else
                if (lights[index].state == 1)
                   {
                   // update counter
                   if (++lights[index].counter >= lights[index].on_time)
                      {
                      // reset counter
                      lights[index].counter = 0;

                      // change states 
                      lights[index].state = -lights[index].state;               
 
                      // update color
                      lpddpal->SetEntries(0,lights[index].color_index,1,&lights[index].off_color);
 
                      } // end if
                   } // end else if
                 
                } // end for index

            } break;

       default: break;

       } // end switch

// return success
return(1);

} // end Blink_Colors

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

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

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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区调教| jizz一区二区| 欧美少妇性性性| 成人欧美一区二区三区| youjizz久久| 不卡的电视剧免费网站有什么| 亚洲色图欧美在线| 精品日韩av一区二区| 九九九久久久精品| 中文字幕亚洲欧美在线不卡| 久久蜜桃一区二区| 91在线精品一区二区| 美国欧美日韩国产在线播放| 国产三级精品三级在线专区| 欧美亚日韩国产aⅴ精品中极品| 色综合天天狠狠| 久久国内精品视频| 亚洲国产精品一区二区www| 日韩亚洲电影在线| 在线看一区二区| 不卡电影一区二区三区| 91影院在线免费观看| 国产精品1区2区3区| 久久国产夜色精品鲁鲁99| 狠狠色2019综合网| 日本午夜一本久久久综合| 国产精品福利影院| 久久久国产精品不卡| 亚洲三级在线免费| 日本女人一区二区三区| 国产精品一区二区在线观看不卡 | 午夜精品在线看| 国产精品久久久久精k8| 亚洲va天堂va国产va久| 亚洲一区二区三区免费视频| 久久综合狠狠综合久久激情 | 中文文精品字幕一区二区| 91香蕉视频污| 日韩欧美中文字幕一区| 亚洲色图在线视频| 亚洲成人免费在线| 成人国产精品免费| 欧美一区二区三区四区视频| 色婷婷av一区二区三区gif| 日韩美一区二区三区| 日韩色视频在线观看| 中文字幕日本乱码精品影院| 久久99精品久久久久久久久久久久| www.色精品| 欧美xxxxx裸体时装秀| 亚洲精品成a人| 夜夜亚洲天天久久| 亚洲大片一区二区三区| proumb性欧美在线观看| 亚洲精品一区二区三区福利 | 欧美无乱码久久久免费午夜一区| 精品乱人伦一区二区三区| 一区二区在线电影| 成人av免费在线观看| 久久这里只有精品视频网| 日日夜夜免费精品| 美国三级日本三级久久99| 91福利在线播放| 欧美高清视频不卡网| 日韩一区二区三区精品视频| 亚洲欧美二区三区| 日本中文字幕一区二区有限公司| 91视频.com| 亚洲日本免费电影| 欧美日韩亚洲国产综合| 7777精品伊人久久久大香线蕉| 91精品国产aⅴ一区二区| 亚洲在线视频一区| 色哟哟精品一区| 亚洲日本在线视频观看| 91色porny蝌蚪| 一区二区视频免费在线观看| 一本高清dvd不卡在线观看| 亚洲人成7777| 91久久一区二区| 香蕉久久一区二区不卡无毒影院| 欧美最新大片在线看| 亚洲国产另类av| 欧美美女直播网站| 国产欧美视频在线观看| 成人黄色av电影| 亚洲欧洲av在线| 色综合天天综合在线视频| 91精品国产色综合久久不卡蜜臀| 亚洲成人动漫在线免费观看| 欧美午夜精品久久久久久孕妇| 亚洲大片精品永久免费| 日韩一级二级三级| 国产一区二区三区在线看麻豆| 国产亚洲一区二区三区在线观看| 亚洲va韩国va欧美va| 91麻豆精品国产自产在线观看一区| 日本在线不卡一区| 久久久国际精品| 色婷婷av一区二区三区软件 | 久久久久久9999| 91亚洲国产成人精品一区二区三 | 欧美成人综合网站| 国产很黄免费观看久久| 91精品免费观看| 国内不卡的二区三区中文字幕 | 欧美刺激午夜性久久久久久久| 久久精品国产99国产精品| 国产精品国产自产拍高清av王其 | 热久久一区二区| 在线视频你懂得一区| 五月综合激情网| 国产欧美1区2区3区| 9191成人精品久久| 成人禁用看黄a在线| 秋霞成人午夜伦在线观看| 国产精品久久久久久久久晋中 | 成人美女在线观看| 欧美韩国日本不卡| 欧美日本免费一区二区三区| 国产精品亚洲а∨天堂免在线| 亚洲第一激情av| 国产精品成人免费 | 丰满亚洲少妇av| 国产精品每日更新| 日韩一级免费观看| 欧美色爱综合网| 99视频精品全部免费在线| 久久国产精品免费| 亚洲成人自拍一区| 国产精品久久久久久久岛一牛影视| 欧美一区二区三区免费视频| 99精品视频在线播放观看| 国产乱人伦精品一区二区在线观看| 亚洲国产一区二区在线播放| 亚洲国产高清不卡| 久久精子c满五个校花| 欧美一区二区三区不卡| 欧美日韩精品欧美日韩精品| 色综合色狠狠综合色| 国产精品一区二区三区四区| 美女www一区二区| 免费三级欧美电影| 奇米色一区二区三区四区| 亚洲国产欧美日韩另类综合 | 在线综合视频播放| 欧美日韩国产首页在线观看| 在线免费亚洲电影| 欧美日本一区二区三区| 欧美日韩国产在线观看| 欧美色网站导航| 在线观看国产日韩| 欧美日韩亚洲不卡| 欧美挠脚心视频网站| 欧美久久高跟鞋激| 日韩三区在线观看| 欧美精品一区二区在线观看| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | 国产精品456| 成人av资源站| 色菇凉天天综合网| 欧美日韩国产首页在线观看| 欧美丰满嫩嫩电影| 日韩免费视频一区| 久久久综合九色合综国产精品| 欧美激情综合五月色丁香| 国产精品另类一区| 一区二区三区中文免费| 图片区小说区国产精品视频 | 国产精品无人区| 亚洲视频一二区| 亚洲18女电影在线观看| 美女视频黄免费的久久| 懂色av一区二区三区蜜臀| 日本高清不卡在线观看| 欧美一区二区三区免费观看视频 | 亚洲一二三区视频在线观看| 一区二区三区四区亚洲| 美女在线观看视频一区二区| 国产精品一二三四区| 欧美亚洲日本一区| 26uuu另类欧美亚洲曰本| 自拍偷拍亚洲欧美日韩| 蜜桃av噜噜一区| 99久久99久久综合| 日韩一区二区在线看| 国产精品久久久久精k8| 男男gaygay亚洲| 色香蕉成人二区免费| 久久综合丝袜日本网| 亚洲综合网站在线观看| 久久99精品久久久久久国产越南| 91免费观看在线| 欧美精品一区二区三区在线| 伊人夜夜躁av伊人久久| 国产精品888| 日韩欧美成人一区二区| 一区二区在线观看视频 | 色成人在线视频| 久久影院视频免费|