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

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

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

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

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
午夜精品福利一区二区蜜股av| 一区二区三区蜜桃| av成人免费在线观看| 亚洲国产一区二区三区青草影视| 欧美大片国产精品| 一本色道综合亚洲| 精品一区二区三区欧美| 亚洲精选视频在线| 国产亚洲欧美一区在线观看| 欧美在线看片a免费观看| 久久99国产精品麻豆| 一区二区三区欧美亚洲| 国产日韩精品一区| 日韩欧美在线观看一区二区三区| 91在线视频播放地址| 国产一区二区三区四区五区入口 | 一区2区3区在线看| 久久九九全国免费| 91精品国产综合久久国产大片 | 日本午夜精品一区二区三区电影| 国产精品久久久久影院色老大| 日韩一级精品视频在线观看| 在线国产亚洲欧美| 91视频免费观看| 国产白丝网站精品污在线入口| 日本中文一区二区三区| 亚洲一二三区视频在线观看| 亚洲视频免费在线观看| 国产色综合久久| 精品成人a区在线观看| 欧美精品粉嫩高潮一区二区| 欧美自拍偷拍午夜视频| 99麻豆久久久国产精品免费优播| 国产精品一区免费在线观看| 久久av资源网| 老司机精品视频一区二区三区| 亚洲mv在线观看| 一区二区三区在线高清| 综合久久久久久久| 日韩毛片视频在线看| 国产精品久久午夜| 国产精品久久久久永久免费观看 | 亚洲一线二线三线视频| 自拍偷拍国产精品| 亚洲蜜臀av乱码久久精品| 亚洲日穴在线视频| 亚洲精品久久久久久国产精华液| 亚洲欧洲日韩在线| 亚洲人xxxx| 一二三区精品福利视频| 亚洲国产va精品久久久不卡综合| 亚洲香肠在线观看| 婷婷久久综合九色综合伊人色| 亚洲v日本v欧美v久久精品| 亚洲国产精品久久人人爱| 亚洲国产aⅴ成人精品无吗| 同产精品九九九| 蜜臀精品一区二区三区在线观看| 欧美aaa在线| 国产一区二区三区综合| www.欧美亚洲| 欧美亚洲综合一区| 91精品国产丝袜白色高跟鞋| 欧美www视频| 亚洲国产精品成人综合| 日韩美女啊v在线免费观看| 亚洲国产综合91精品麻豆| 日韩激情中文字幕| 国产乱妇无码大片在线观看| 成人免费电影视频| 欧美亚洲日本国产| 日韩视频在线永久播放| 国产性做久久久久久| 亚洲视频一区二区在线| 同产精品九九九| 国产精品一区二区久激情瑜伽| 99精品黄色片免费大全| 欧美日韩一区二区电影| 精品久久久久久最新网址| 国产精品天美传媒沈樵| 亚洲综合色区另类av| 美腿丝袜亚洲三区| 成人福利视频网站| 欧美日韩国产精品成人| 久久久综合视频| 亚洲综合视频在线| 国内精品嫩模私拍在线| 一本大道久久a久久综合| 日韩欧美一区二区免费| 国产精品看片你懂得| 日韩和欧美的一区| av在线一区二区三区| 欧美一三区三区四区免费在线看 | 91在线观看下载| 777久久久精品| 欧美国产禁国产网站cc| 亚洲成av人**亚洲成av**| 国产精品一区三区| 在线不卡免费av| 亚洲欧美一区二区视频| 99久久久国产精品| 日韩久久久精品| 亚洲日本在线天堂| 国产成人免费网站| 欧美三级电影在线看| 国产精品欧美精品| 老司机精品视频导航| 欧美在线色视频| 国产精品美女视频| 韩国一区二区视频| 欧美精品xxxxbbbb| 亚洲精品欧美专区| 丰满岳乱妇一区二区三区| 日韩一级完整毛片| 亚洲国产精品久久艾草纯爱| 成人永久免费视频| 精品免费日韩av| 午夜私人影院久久久久| 色综合久久中文字幕综合网| 久久久不卡网国产精品一区| 日本不卡一区二区| 欧美日韩高清不卡| 一区二区三区在线观看视频| 成人激情黄色小说| 久久夜色精品一区| 久久精品二区亚洲w码| 欧美精品高清视频| 五月婷婷综合在线| 欧美天天综合网| 一区二区三区毛片| 色拍拍在线精品视频8848| 1024成人网| 成人动漫av在线| 欧美国产欧美综合| 福利一区二区在线| 美女免费视频一区| 欧美一区二区成人| 日本色综合中文字幕| 欧美欧美午夜aⅴ在线观看| 亚洲图片欧美色图| 欧美日本一区二区| 日日噜噜夜夜狠狠视频欧美人| 欧美午夜视频网站| 香蕉成人伊视频在线观看| 欧美日本一区二区| 天涯成人国产亚洲精品一区av| 精品视频免费看| 婷婷夜色潮精品综合在线| 欧美一区二区三区婷婷月色| 蜜臀av一级做a爰片久久| 欧美一区二区日韩| 精品一区二区三区免费视频| 2024国产精品| 盗摄精品av一区二区三区| 国产精品成人一区二区艾草 | 欧美专区在线观看一区| 亚洲狠狠丁香婷婷综合久久久| 色综合欧美在线视频区| 亚洲午夜激情网页| 91精品国产综合久久久蜜臀图片| 美日韩一区二区| 亚洲国产精品av| 91黄色激情网站| 天堂影院一区二区| 久久影院电视剧免费观看| 国产激情91久久精品导航| 国产精品国产三级国产aⅴ中文 | 国产精品黄色在线观看| 色诱亚洲精品久久久久久| 午夜私人影院久久久久| 2023国产精品| 色偷偷久久人人79超碰人人澡| 午夜私人影院久久久久| 久久伊人蜜桃av一区二区| 色综合激情五月| 麻豆视频观看网址久久| 国产精品毛片大码女人| 欧美日韩国产大片| 国产乱淫av一区二区三区 | 青青草精品视频| 国产视频视频一区| 欧美三级日韩在线| 蜜臀a∨国产成人精品| 国产精品久久影院| 欧美一区二区三区四区视频| 丰满少妇久久久久久久| 五月激情综合婷婷| 国产精品系列在线| 7777精品伊人久久久大香线蕉经典版下载| 久久av资源网| 一区二区不卡在线播放| 国产性色一区二区| 制服丝袜在线91| 99在线热播精品免费| 免费高清在线一区| 亚洲精品国产成人久久av盗摄 | 国产精品视频免费| 3751色影院一区二区三区| av亚洲精华国产精华精| 欧美a级理论片|