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

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

?? blackbox.cpp

?? windows游戲編程大師源代碼
?? CPP
字號(hào):
// BLACKBOX.CPP - Game Engine 
 
// INCLUDES ///////////////////////////////////////////////////

#define WIN32_LEAN_AND_MEAN  // make sure all macros are included

#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>           // directX includes
#include "blackbox.h"        // game library includes
                                   
// DEFINES ////////////////////////////////////////////////////

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

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

// EXTERNALS //////////////////////////////////////////////////

extern HWND main_window_handle; // save the window handle
extern HINSTANCE main_instance; // save the instance

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

LPDIRECTDRAW4         lpdd         = NULL;   // dd object
LPDIRECTDRAWSURFACE4  lpddsprimary = NULL;   // dd primary surface
LPDIRECTDRAWSURFACE4  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

// these defined the general clipping rectangle
int min_clip_x = 0,                          // clipping rectangle 
    max_clip_x = SCREEN_WIDTH-1,
    min_clip_y = 0,
    max_clip_y = SCREEN_HEIGHT-1;

// these are overwritten globally by DD_Init()
int screen_width  = SCREEN_WIDTH,            // width of screen
    screen_height = SCREEN_HEIGHT,           // height of screen
    screen_bpp    = SCREEN_BPP;              // bits per pixel

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

int DD_Init(int width, int height, int bpp)
{
// this function initializes directdraw
int index; // looping variable

LPDIRECTDRAW lpdd1 = NULL; // used to query for the latest interface


// create object and test for error
if (DirectDrawCreate(NULL,&lpdd1,NULL)!=DD_OK)
   return(0);

// query for the latest version of the interface (4)
if (lpdd1->QueryInterface(IID_IDirectDraw4,(LPVOID *)&lpdd)!=DD_OK) 
    return(0);

// set cooperation level to windowed mode normal
if (lpdd->SetCooperativeLevel(main_window_handle,
           DDSCL_ALLOWMODEX | DDSCL_FULLSCREEN | 
           DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT)!=DD_OK)
    return(0);

// set the display mode
if (lpdd->SetDisplayMode(width,height,bpp,0,0)!=DD_OK)
   return(0);

// set globals
screen_height = height;
screen_width  = width;
screen_bpp    = bpp;

// Create the primary surface
memset(&ddsd,0,sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;

// we need to let dd know that we want a complex 
// flippable surface structure, set flags for that
ddsd.ddsCaps.dwCaps = 
  DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;

// set the backbuffer count to 1
ddsd.dwBackBufferCount = 1;

// create the primary surface
lpdd->CreateSurface(&ddsd,&lpddsprimary,NULL);

// query for the backbuffer i.e the secondary surface
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
lpddsprimary->GetAttachedSurface(&ddscaps,&lpddsback);

// create and attach palette

// create palette data
// clear all entries defensive programming
memset(palette,0,256*sizeof(PALETTEENTRY));

// create a R,G,B,GR gradient palette
for (index=0; index < 256; index++)
    {
    // set each entry
    if (index < 64) 
        palette[index].peRed = index*4; 
    else           // shades of green
    if (index >= 64 && index < 128) 
        palette[index].peGreen = (index-64)*4;
    else           // shades of blue
    if (index >= 128 && index < 192) 
       palette[index].peBlue = (index-128)*4;
    else           // shades of grey
    if (index >= 192 && index < 256) 
        palette[index].peRed = palette[index].peGreen = 
        palette[index].peBlue = (index-192)*4;
    
    // set flags
    palette[index].peFlags = PC_NOCOLLAPSE;
    } // end for index

// now create the palette object
if (lpdd->CreatePalette(DDPCAPS_8BIT | DDPCAPS_INITIALIZE | DDPCAPS_ALLOW256,
                         palette,&lpddpal,NULL)!=DD_OK)
   return(0);

// attach the palette to the primary
if (lpddsprimary->SetPalette(lpddpal)!=DD_OK)
   return(0);

// clear out both primary and secondary surfaces
DD_Fill_Surface(lpddsprimary,0);
DD_Fill_Surface(lpddsback,0);

// attach a clipper to the screen
RECT screen_rect = {0,0,screen_width,screen_height};
lpddclipper = DD_Attach_Clipper(lpddsback,1,&screen_rect);

// return success
return(1);
} // end DD_Init

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

int DD_Shutdown(void)
{
// this function release all the resources directdraw
// allocated, mainly to com objects

// release the clipper first
if (lpddclipper)
    lpddclipper->Release();

// release the palette
if (lpddpal)
   lpddpal->Release();

// release the secondary surface
if (lpddsback)
    lpddsback->Release();

// release the primary surface
if (lpddsprimary)
   lpddsprimary->Release();

// finally, the main dd object
if (lpdd)
    lpdd->Release();

// return success
return(1);
} // end DD_Shutdown

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

LPDIRECTDRAWCLIPPER DD_Attach_Clipper(LPDIRECTDRAWSURFACE4 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 ((lpdd->CreateClipper(0,&lpddclipper,NULL))!=DD_OK)
   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 ((lpddclipper->SetClipList(region_data, 0))!=DD_OK)
   {
   // release memory and return error
   free(region_data);
   return(NULL);
   } // end if

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

// all is well, so release memory and send back the pointer to the new clipper
free(region_data);
return(lpddclipper);

} // end DD_Attach_Clipper

///////////////////////////////////////////////////////////////
   
int DD_Flip(void)
{
// this function flip the primary surface with the secondary surface

// flip pages
while(lpddsprimary->Flip(NULL, DDFLIP_WAIT)!=DD_OK);

// flip the surface

// return success
return(1);

} // end DD_Flip

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

DWORD Start_Clock(void)
{
// this function starts the clock, that is, saves the current
// count, use in conjunction with Wait_Clock()

return(start_clock_count = Get_Clock());

} // end Start_Clock

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

DWORD Get_Clock(void)
{
// this function returns the current tick count

// return time
return(GetTickCount());

} // end Get_Clock

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

DWORD Wait_Clock(DWORD count)
{
// this function is used to wait for a specific number of clicks
// since the call to Start_Clock

while((Get_Clock() - start_clock_count) < count);
return(Get_Clock());

} // end Wait_Clock

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

int DD_Fill_Surface(LPDIRECTDRAWSURFACE4 lpdds,int color)
{
DDBLTFX ddbltfx; // this contains the DDBLTFX structure

// clear out the structure and set the size field 
DD_INIT_STRUCT(ddbltfx);

// set the dwfillcolor field to the desired color
ddbltfx.dwFillColor = color; 

// ready to blt to surface
lpdds->Blt(NULL,       // ptr to dest rectangle
           NULL,       // ptr to source surface, NA            
           NULL,       // ptr to source rectangle, NA
           DDBLT_COLORFILL | DDBLT_WAIT | DDBLT_ASYNC,   // fill and wait                   
           &ddbltfx);  // ptr to DDBLTFX structure

// return success
return(1);
} // end DD_Fill_Surface

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

int Draw_Rectangle(int x1, int y1, int x2, int y2, int color,
                   LPDIRECTDRAWSURFACE4 lpdds)
{
// this function uses directdraw to draw a filled rectangle

DDBLTFX ddbltfx; // this contains the DDBLTFX structure
RECT fill_area;  // this contains the destination rectangle

// clear out the structure and set the size field 
DD_INIT_STRUCT(ddbltfx);

// set the dwfillcolor field to the desired color
ddbltfx.dwFillColor = color; 

// fill in the destination rectangle data (your data)
fill_area.top    = y1;
fill_area.left   = x1;
fill_area.bottom = y2+1;
fill_area.right  = x2+1;

// ready to blt to surface, in this case blt to primary
lpdds->Blt(&fill_area, // ptr to dest rectangle
           NULL,       // ptr to source surface, NA            
           NULL,       // ptr to source rectangle, NA
           DDBLT_COLORFILL | DDBLT_WAIT | DDBLT_ASYNC,   // fill and wait                   
           &ddbltfx);  // ptr to DDBLTFX structure

// return success
return(1);

} // end Draw_Rectangle

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

int Draw_Text_GDI(char *text, int x,int y,int color, LPDIRECTDRAWSURFACE4 lpdds)
{
// this function draws the sent text on the sent surface 
// using color index as the color in the palette

HDC xdc; // the working dc

// get the dc from surface
if (lpdds->GetDC(&xdc)!=DD_OK)
   return(0);

// set the colors for the text up
SetTextColor(xdc,RGB(palette[color].peRed,palette[color].peGreen,palette[color].peBlue) );

// set background mode to transparent so black isn't copied
SetBkMode(xdc, TRANSPARENT);

// draw the text a
TextOut(xdc,x,y,text,strlen(text));

// release the dc
lpdds->ReleaseDC(xdc);

// return success
return(1);
} // end Draw_Text_GDI

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

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91在线视频网址| 成人免费高清视频在线观看| 亚洲婷婷在线视频| 中文字幕免费观看一区| 日韩一级精品视频在线观看| 91久久一区二区| av在线不卡观看免费观看| 激情综合五月婷婷| 精品一区二区免费看| 青青草国产成人av片免费| 日韩va亚洲va欧美va久久| 亚洲国产成人91porn| 亚洲男同1069视频| 亚洲地区一二三色| 一区二区成人在线| 国产午夜亚洲精品理论片色戒 | 一区二区三区日韩精品| wwwwxxxxx欧美| 国产精品一区在线| 久久精品国产第一区二区三区| 麻豆免费精品视频| 奇米色一区二区| 毛片av一区二区| 国产精品一区二区三区网站| 国产精品一区二区黑丝 | 极品美女销魂一区二区三区免费| 老鸭窝一区二区久久精品| 经典三级一区二区| 国产不卡视频在线播放| 国产99精品视频| 色综合 综合色| 在线视频国产一区| 91精品一区二区三区久久久久久| 欧美一区二区三区男人的天堂| 欧美一区二区三区免费| 国产欧美一区二区在线| 欧美国产日韩一二三区| 国产精品婷婷午夜在线观看| 亚洲一区中文在线| 日本午夜精品一区二区三区电影| 亚洲小少妇裸体bbw| 黑人巨大精品欧美黑白配亚洲| 国产福利视频一区二区三区| 91在线观看污| 91.com在线观看| 精品国产区一区| 亚洲免费在线观看视频| 午夜精品久久久久久久99樱桃| 亚洲蜜臀av乱码久久精品| 美女视频第一区二区三区免费观看网站| 久久99国产精品久久99果冻传媒| av一区二区不卡| 欧美片在线播放| 久久久久久免费网| 亚洲精品乱码久久久久久黑人| 亚洲成av人片| 天堂va蜜桃一区二区三区漫画版| 亚洲va中文字幕| 国产一区二区三区免费播放| 91碰在线视频| 91精品国产综合久久精品图片| 久久综合色之久久综合| 亚洲欧美偷拍另类a∨色屁股| 婷婷久久综合九色国产成人| 国产九九视频一区二区三区| av爱爱亚洲一区| 欧美日韩国产美女| 国产人久久人人人人爽| 亚洲国产中文字幕在线视频综合| 国内成人精品2018免费看| 99国产欧美久久久精品| 91精品国产色综合久久久蜜香臀| 久久久精品影视| 五月天一区二区| 国产精品亚洲午夜一区二区三区| 色狠狠综合天天综合综合| 欧美日韩高清在线| 国产三级欧美三级日产三级99 | 久久久噜噜噜久噜久久综合| 亚洲日本在线天堂| 久久99精品国产麻豆婷婷 | 555夜色666亚洲国产免| 国产精品沙发午睡系列990531| 午夜精品久久久久久久久久| 成人国产精品免费观看动漫| 91精品国产色综合久久ai换脸| 精品国产免费人成电影在线观看四季| 国产午夜精品一区二区三区视频| 日日夜夜一区二区| 99久久精品国产网站| 日韩一区二区在线播放| 亚洲亚洲精品在线观看| 99免费精品在线| 国产婷婷色一区二区三区在线| 日韩成人免费电影| 色欧美片视频在线观看在线视频| 国产亚洲综合性久久久影院| 日韩国产精品久久| 欧美私模裸体表演在线观看| 国产视频一区二区在线观看| 欧美aaaaa成人免费观看视频| 欧美日韩午夜精品| 国产精品麻豆一区二区| 国产精品一区二区在线观看不卡| 日韩欧美国产午夜精品| 亚洲国产精品嫩草影院| 成人av电影免费在线播放| 久久众筹精品私拍模特| 美腿丝袜在线亚洲一区| 欧美视频一区二区三区在线观看| 亚洲色图色小说| eeuss鲁片一区二区三区在线观看| 久久美女艺术照精彩视频福利播放| 蜜乳av一区二区三区| 欧美日韩激情一区二区| 亚洲精品欧美在线| 91亚洲精品久久久蜜桃| 亚洲视频香蕉人妖| 91玉足脚交白嫩脚丫在线播放| 国产精品福利av| a级高清视频欧美日韩| 国产一区亚洲一区| 91啪九色porn原创视频在线观看| 国产欧美精品一区| 国产白丝网站精品污在线入口| wwwwxxxxx欧美| 欧美a一区二区| 9191久久久久久久久久久| 亚洲精品国产一区二区三区四区在线 | 亚洲精品中文字幕在线观看| 99久久久国产精品| 一区二区三区在线不卡| 色94色欧美sute亚洲13| 亚洲综合男人的天堂| 欧美在线观看一区| 尤物av一区二区| 欧美日韩中字一区| 美女视频一区二区三区| 久久久欧美精品sm网站| 成人精品在线视频观看| 亚洲乱码国产乱码精品精的特点| 色婷婷亚洲精品| 日韩精品免费视频人成| 欧美一区二区视频在线观看 | 中文字幕乱码日本亚洲一区二区| 色婷婷亚洲一区二区三区| 蜜臀av性久久久久蜜臀aⅴ四虎| 中文字幕av资源一区| 欧美日韩你懂的| 国产高清亚洲一区| 亚洲电影中文字幕在线观看| 久久影院午夜片一区| 欧美色图激情小说| 国产91对白在线观看九色| 亚洲成人777| 国产精品乱子久久久久| 日韩一区二区在线看| 91丝袜国产在线播放| 蜜桃精品视频在线| 亚洲在线观看免费视频| 久久精品在线免费观看| 91精品国产一区二区三区香蕉| a4yy欧美一区二区三区| 极品瑜伽女神91| 亚洲成a人片综合在线| 亚洲欧洲一区二区在线播放| 精品国产乱码久久久久久浪潮| 在线观看欧美黄色| 国产成人日日夜夜| 老色鬼精品视频在线观看播放| 亚洲国产综合人成综合网站| 国产精品丝袜一区| 久久影视一区二区| 欧美老肥妇做.爰bbww| 91免费版在线看| 国产成人亚洲精品狼色在线| 久久精品72免费观看| 亚洲午夜在线观看视频在线| 国产精品伦理在线| 久久九九99视频| 精品国产欧美一区二区| 制服.丝袜.亚洲.中文.综合| 日本道色综合久久| 972aa.com艺术欧美| 国产精品一区二区视频| 久久精品国产精品青草| 免费成人在线观看视频| 视频一区中文字幕| 亚洲成va人在线观看| 亚洲一区二区三区免费视频| 自拍av一区二区三区| 国产精品久线观看视频| 日本一区二区三区dvd视频在线| 欧美zozo另类异族| 日韩一区二区三区在线视频| 91精品国产综合久久精品图片| 欧美另类z0zxhd电影| 欧美日韩国产色站一区二区三区| 欧美综合一区二区| 欧美怡红院视频|