当前位置: 首页>>代码示例>>C++>>正文


C++ LPDIRECTDRAWSURFACE7::Unlock方法代码示例

本文整理汇总了C++中LPDIRECTDRAWSURFACE7::Unlock方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAWSURFACE7::Unlock方法的具体用法?C++ LPDIRECTDRAWSURFACE7::Unlock怎么用?C++ LPDIRECTDRAWSURFACE7::Unlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LPDIRECTDRAWSURFACE7的用法示例。


在下文中一共展示了LPDIRECTDRAWSURFACE7::Unlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UnLock

//-----------------------------------------------------------------------------
// Name: UnLock()
// Desc: UnLocks entire surface that has been locked
//-----------------------------------------------------------------------------
int UnLock(LPDIRECTDRAWSURFACE7 lpddsSurface)
{
	ddReturnVal  = lpddsSurface->Unlock(NULL);
	if (DDFailedCheck(ddReturnVal, "Unlock(), failed", cpErrorBuf ))
	{	MessageBox(main_window_handle, cpErrorBuf, "UnLock()", MB_ICONEXCLAMATION); return(0); }
	
	return(1);
}
开发者ID:scirelli,项目名称:testForDX7,代码行数:12,代码来源:SurfaceFuncs.cpp

示例2: SurfaceUnlock

void SurfaceUnlock (LPDIRECTDRAWSURFACE7 pSurface)

//	SurfaceUnlock
//
//	Unlocks the surface previously locked by SurfaceLock

	{
	pSurface->Unlock(NULL);
	}
开发者ID:bmer,项目名称:Alchemy,代码行数:9,代码来源:DirectDraw.cpp

示例3: Game_Main

int Game_Main(void *parms = NULL, int num_parms = 0)
{
// this is the main loop of the game, do all your processing
// here

// make sure this isn't executed again
if (window_closed)
   return(0);

// for now test if user is hitting ESC and send WM_CLOSE
if (KEYDOWN(VK_ESCAPE))
   {
   PostMessage(main_window_handle,WM_CLOSE,0,0);
   window_closed = 1;
   } // end if

// copy the bitmap image to the primary buffer line by line
// notice the 24 to 16 bit conversion pixel by pixel

// lock the primary surface
lpddsprimary->Lock(NULL,&ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT,NULL);

// get video pointer to primary surfce
USHORT *primary_buffer = (USHORT *)ddsd.lpSurface;       

// process each line and copy it into the primary buffer
for (int index_y = 0; index_y < SCREEN_HEIGHT; index_y++)
    {
    for (int index_x = 0; index_x < SCREEN_WIDTH; index_x++)
        {
        // get BGR values, note the scaling down of the channels, so that they
        // fit into the 5.6.5 format
        UCHAR blue  = (bitmap.buffer[index_y*SCREEN_WIDTH*3 + index_x*3 + 0]) >> 3,
              green = (bitmap.buffer[index_y*SCREEN_WIDTH*3 + index_x*3 + 1]) >> 3,
              red   = (bitmap.buffer[index_y*SCREEN_WIDTH*3 + index_x*3 + 2]) >> 3;

        // this builds a 16 bit color value in 5.6.5 format (green dominant mode)
        USHORT pixel = _RGB16BIT565(red,green,blue);

        // write the pixel
        primary_buffer[index_x + (index_y*ddsd.lPitch >> 1)] = pixel;

        } // end for index_x

    } // end for index_y

// now unlock the primary surface
if (FAILED(lpddsprimary->Unlock(NULL)))
   return(0);

// do nothing -- look at pretty picture

// return success or failure or your own return code here
return(1);

} // end Game_Main
开发者ID:calyx,项目名称:windows-game-source-code,代码行数:56,代码来源:demo7_11.cpp

示例4: Game_Main

int Game_Main(void *parms = NULL, int num_parms = 0)
{
// this is the main loop of the game, do all your processing
// here

// make sure this isn't executed again
if (window_closed)
   return(0);

// for now test if user is hitting ESC and send WM_CLOSE
if (KEYDOWN(VK_ESCAPE))
   {
   PostMessage(main_window_handle,WM_CLOSE,0,0);
   window_closed = 1;
   } // end if

// clear out the back buffer
DDraw_Fill_Surface(lpddsback, 0);

// lock primary buffer
DDRAW_INIT_STRUCT(ddsd);

if (FAILED(lpddsback->Lock(NULL,&ddsd,
                           DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR,
                           NULL)))
return(0);

// do the graphics
Draw_Polygon2D(&asteroid, (UCHAR *)ddsd.lpSurface, ddsd.lPitch);

// test for scale
if (KEYDOWN('A')) // scale up
   Scale_Polygon2D(&asteroid, 1.1, 1.1);
else
if (KEYDOWN('S')) // scale down
   Scale_Polygon2D(&asteroid, 0.9, 0.9);

// rotate the polygon by 5 degrees
Rotate_Polygon2D(&asteroid, 5);

// unlock primary buffer
if (FAILED(lpddsback->Unlock(NULL)))
   return(0);

// perform the flip
while (FAILED(lpddsprimary->Flip(NULL, DDFLIP_WAIT)));

// wait a sec
Sleep(33);

// return success or failure or your own return code here
return(1);

} // end Game_Main
开发者ID:7er,项目名称:T3DCHAP08,代码行数:54,代码来源:demo8_5.cpp

示例5: Scan_Image_Bitmap

int Scan_Image_Bitmap(BITMAP_FILE_PTR bitmap,     // bitmap file to scan image data from
                      LPDIRECTDRAWSURFACE7 lpdds, // surface to hold data
                      int cx, int cy)             // cell to scan image from
{
// this function extracts a bitmap out of a bitmap file

UCHAR *source_ptr,   // working pointers
      *dest_ptr;

DDSURFACEDESC2 ddsd;  //  direct draw surface description 

// get the addr to destination surface memory

// set size of the structure
ddsd.dwSize = sizeof(ddsd);

// lock the display surface
lpdds->Lock(NULL,
            &ddsd,
            DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR,
            NULL);

// compute position to start scanning bits from
cx = cx*(ddsd.dwWidth+1) + 1;
cy = cy*(ddsd.dwHeight+1) + 1;

gwidth  = ddsd.dwWidth;
gheight = ddsd.dwHeight;

// extract bitmap data
source_ptr = bitmap->buffer + cy*bitmap->bitmapinfoheader.biWidth+cx;

// assign a pointer to the memory surface for manipulation
dest_ptr = (UCHAR *)ddsd.lpSurface;

// iterate thru each scanline and copy bitmap
for (int index_y=0; index_y < ddsd.dwHeight; index_y++)
    {
    // copy next line of data to destination
    memcpy(dest_ptr, source_ptr, ddsd.dwWidth);

    // advance pointers
    dest_ptr   += (ddsd.lPitch);
    source_ptr += bitmap->bitmapinfoheader.biWidth;
    } // end for index_y

// unlock the surface 
lpdds->Unlock(NULL);

// return success
return(1);

} // end Scan_Image_Bitmap
开发者ID:calyx,项目名称:windows-game-source-code,代码行数:53,代码来源:demo7_14.cpp

示例6: UnlockSurface

inline HRESULT STDMETHODCALLTYPE UnlockSurface(LPDIRECTDRAWSURFACE7 surface, LPRECT data)
{
    //logOutput << CurrentTimeString() << "Called UnlockSurface" << endl;

    // standard handler
    if (!bTargetAcquired)
    {
        ddrawSurfaceUnlock.Unhook();
        HRESULT hr = surface->Unlock(data);
        ddrawSurfaceUnlock.Rehook();
        return hr;
    }

    // use mutex lock to prevent memory corruption when calling Unhook/Rehook from multiple threads
    HANDLE mutex = OpenMutex(SYNCHRONIZE, FALSE, mutexName);
    if (!mutex)
    {
        logOutput << CurrentTimeString() << "Could not open mutex - Error(" << GetLastError() << ')' << endl;
        return DDERR_GENERIC;
    }

    DWORD ret = WaitForSingleObject(mutex, INFINITE);
    if (ret == WAIT_OBJECT_0)
    {
        ddrawSurfaceUnlock.Unhook();
        HRESULT hr = surface->Unlock(data);
        ddrawSurfaceUnlock.Rehook();

        ReleaseMutex(mutex);
        CloseHandle(mutex);
        return hr;
    }
    else
    {
        logOutput << CurrentTimeString() << "error while waiting for unlock-mutex to get signaled" << endl;
        logOutput << CurrentTimeString() << "GetLastError: " << GetLastError() << endl;
        CloseHandle(mutex);
        return DDERR_GENERIC;
    }
}
开发者ID:CasperGemini,项目名称:OBS,代码行数:40,代码来源:DDrawCapture.cpp

示例7: Bmp2Surface

int Bmp2Surface(LPDIRECTDRAWSURFACE7 lpdds, int SurfaceWidth, int SurfaceHeight)
{
	// copy the bitmap image to the lpddsback buffer line by line
	// notice the 24 to 32 bit conversion pixel by pixel

	// 一个像素一个像素的逐粒拷贝至表面

	// lock the lpddsback surface
	lpdds->Lock(NULL,&ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT,NULL);

	// get video pointer to primary surfce
	DWORD *back_buffer = (DWORD *)ddsd.lpSurface;       

	// process each line and copy it into the lpddsback buffer
	if (ddsd.lPitch == SurfaceWidth)
	{
	   // copy memory from double buffer to lpddsback buffer
	   memcpy((void *)back_buffer, (void *)bitmap.buffer, SurfaceWidth*SurfaceHeight);
	}
	else
	{


		
		for (int index_y = 0; index_y < SurfaceHeight; index_y++)
		{
			for (int index_x = 0; index_x < SurfaceWidth; index_x++)
			{
				// get BGR values
				UCHAR blue  = (bitmap.buffer[index_y*SurfaceWidth*3 + index_x*3 + 0]),
					  green = (bitmap.buffer[index_y*SurfaceWidth*3 + index_x*3 + 1]),
					  red   = (bitmap.buffer[index_y*SurfaceWidth*3 + index_x*3 + 2]);

				// this builds a 32 bit color value in A.8.8.8 format (8-bit alpha mode)
				DWORD pixel = _RGB32BIT(0,red,green,blue);

				// write the pixel
				back_buffer[index_x + (index_y*ddsd.lPitch >> 2)] = pixel;

			} // end for index_x

		} // end for index_y

		
		
	}

	// now unlock the lpddsback surface
	if (FAILED(lpdds->Unlock(NULL)))
	   return(0);
}  // end Bmp2Surface
开发者ID:klobodnf,项目名称:my_game,代码行数:51,代码来源:demo7_12.cpp

示例8: GameDisplayLoop

HRESULT GameDisplayLoop(HWND hWnd, PFPImage pImage, LONG destX, LONG destY)
{
	HRESULT hResult;
	DDBLTFX ddBltFx;
	memset(&ddBltFx, 0, sizeof(ddBltFx));
	ddBltFx.dwSize = sizeof(ddBltFx);
	ddBltFx.dwROP = SRCCOPY;

	RECT rcMain = { 0 };
	GetClientRect(hWnd, &rcMain);
	ClientToScreen(hWnd, ((LPPOINT)&rcMain) + 0);
	ClientToScreen(hWnd, ((LPPOINT)&rcMain) + 1);
	//FP_DEBUG_MSG(_T("CLINET RECT: (%d, %d) - (%d, %d)\n"), rcMain.top, rcMain.bottom, rcMain.left, rcMain.right);

	RECT rcBack = { 0 };
	DDSURFACEDESC2 ddsd;
	DDRAW_INIT_STRUCT(ddsd);
	if (FAILED(hResult = lpddsBack->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL)))
	{
		FP_DEBUG_MSG(_T("Lock Error: 0x%08x\n"), hResult);
		return E_FAIL;
	}
	LPPALETTEENTRY lpPalet = NULL;
	if (FAILED(gameGraphics->ChangePalette(FP_PALETTE_DAY, &lpPalet)))
	{
		return E_FAIL;
	}
	LPBYTE lpPixel = (LPBYTE)ddsd.lpSurface;
	LPBYTE lpData = (LPBYTE)pImage->data;
	LONG n = 0;
	for (LONG i = 0; i < pImage->height; i++)
	{
		n = (i + destY) * ddsd.lPitch + destX * sizeof(PALETTEENTRY);
		for (LONG j = 0; j < pImage->width; j++, n += 4)
		{
			LPBYTE lpPtr = &lpPixel[n];
			*(lpPtr + 0) = lpPalet[lpData[(pImage->height - i - 1) * pImage->width + j]].peRed;
			*(lpPtr + 1) = lpPalet[lpData[(pImage->height - i - 1) * pImage->width + j]].peGreen;
			*(lpPtr + 2) = lpPalet[lpData[(pImage->height - i - 1) * pImage->width + j]].peBlue;
			*(lpPtr + 3) = 0;
		}
	}
	lpddsBack->Unlock(NULL);

	lpddsMain->Blt(&rcMain, lpddsBack, NULL, DDBLT_WAIT, &ddBltFx);
	return S_OK;
}
开发者ID:FP-GAME-DEV-TEAM,项目名称:FP_Game,代码行数:47,代码来源:GameDisplay.cpp

示例9: Game_Main

int Game_Main(void *parms = NULL, int num_parms = 0)
{
// this is the main loop of the game, do all your processing
// here

// make sure this isn't executed again
if (window_closed)
   return(0);

// for now test if user is hitting ESC and send WM_CLOSE
if (KEYDOWN(VK_ESCAPE))
   {
   PostMessage(main_window_handle,WM_CLOSE,0,0);
   window_closed = 1;
   } // end if


// lock primary buffer
DDRAW_INIT_STRUCT(ddsd);

if (FAILED(lpddsprimary->Lock(NULL,&ddsd,
                              DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR,
                              NULL)))
return(0);

// draw 1000 random lines
for (int index=0; index < 1000; index++)
    {
    Draw_Line(rand()%SCREEN_WIDTH, rand()%SCREEN_HEIGHT,
              rand()%SCREEN_WIDTH, rand()%SCREEN_HEIGHT,
              rand()%256,
              (UCHAR *)ddsd.lpSurface, ddsd.lPitch);

    } // end for index


// unlock primary buffer
if (FAILED(lpddsprimary->Unlock(NULL)))
   return(0);

// wait a sec
Sleep(33);

// return success or failure or your own return code here
return(1);

} // end Game_Main
开发者ID:7er,项目名称:T3DCHAP08,代码行数:47,代码来源:demo8_1.cpp

示例10: dx_AccessMemoire

//-----------------------------------------------------------------------------
// Name: dx_AccessMemoire(...)
// Desc: Vérouille/déverouille l'accès à la mémoire vidéo
//-----------------------------------------------------------------------------
bool dx_AccessMemoire (bool pVerrou)
{
    if (pVerrou)
    {
        SurfaceBack->Lock (NULL, &SurfaceDesc, DDLOCK_WAIT, NULL);

        Pitch = (int)SurfaceDesc.lPitch;
        Ecran = (BVRA*)SurfaceDesc.lpSurface;
    }
    else
    {
        SurfaceBack->Unlock (NULL);

        Pitch = 0;
        Ecran = NULL;
    }

    return dx_Test ();
}
开发者ID:hlemorvan,项目名称:vision-stereo,代码行数:23,代码来源:DirectDraw.cpp

示例11: DDAccurateUpdateDisplay

void DDAccurateUpdateDisplay(bool singlestep)
{
        static int framecounter=0;
        HRESULT hRet;
        RECT rDest;

        if (++framecounter > zx81.frameskip || singlestep)
                framecounter=0;
        else
                return;

        DDFrame->Unlock(NULL);

        POINT p = {0, 0};
        if(!Form1->FullScreen) p=Form1->ClientToScreen(p);

        rDest=rcdest;
        rDest.left += p.x;
        rDest.top += p.y;
        rDest.right += p.x;
        rDest.bottom += p.y;

        //if (Form1->FullScreen) DDDrawBorder();
        while(1)
        {
                hRet = m_pddsFrontBuffer->Blt(&rDest, DDFrame, &rcsource, DDBLT_WAIT, NULL);

                if (hRet == DD_OK) break;
                else
                if(hRet == DDERR_SURFACELOST)
                {
                        m_pddsFrontBuffer->Restore();
                        m_pddsFrame->Restore();
                }
                else if(hRet != DDERR_WASSTILLDRAWING) return;
        }


        DDFrame->Lock(NULL, &DDFrameSurface, DDLOCK_WAIT |  DDLOCK_NOSYSLOCK, NULL);
        dest=buffer= (BYTE*)DDFrameSurface.lpSurface;
}
开发者ID:libretro,项目名称:81-libretro,代码行数:41,代码来源:AccDraw_.cpp

示例12: if

static inline void WINAPI vdraw_ddraw_draw_text(DDSURFACEDESC2* pddsd, LPDIRECTDRAWSURFACE7 lpDDS_Surface, const BOOL lock)
{
	if (lock)
		lpDDS_Surface->Lock(NULL, pddsd, DDLOCK_WAIT, NULL);
	
	// Determine the window size using the scaling factor.
	const int curHPix = vdp_getHPix();
	
	// +(8*bytespp) is needed for the lpSurface pointer because the DDraw module
	// includes the entire 336x240 MD_Screen. The first 8 pixels are offscreen,
	// so they won't show up at all.
	
	uint8_t bytespp = (bppOut == 15 ? 2 : bppOut / 8);
	
	// NOTE: fullW must be (pddsd->lPitch / bytespp).
	// DirectDraw likes to use absurdly large line lengths in full screen mode.
	// (pddsd->lPitch / bytespp) does match pddsd->dwWidth in windowed mode, though.
	uint8_t *start = (uint8_t*)pddsd->lpSurface;
	
	int msg_height;
	int msg_width;
	if (vdraw_ddraw_is_hw_render())
	{
		// Hardware rendering uses 1x internally.
		msg_height = VDP_Lines.Visible.Total;
		msg_width = curHPix;
		start += (pddsd->lPitch * VDP_Lines.Visible.Border_Size);
		if (curHPix < 320)
			start += (vdp_getHPixBegin() * bytespp);
		
		// DirectDraw's hardware rendering uses MD_Screen / MD_Screen32 directly.
		// Thus, it has an invisible 8px column at the beginning.
		start += (8 * bytespp);
	}
	else
	{
		// Software rendering.
		msg_height = VDP_Lines.Visible.Total * vdraw_scale;
		msg_width = curHPix * vdraw_scale;
		start += (pddsd->lPitch * (VDP_Lines.Visible.Border_Size * vdraw_scale));
		if (curHPix < 320)
			start += (vdp_getHPixBegin() * vdraw_scale * bytespp);
	}
	
	if (vdraw_msg_visible)
	{
		// Message is visible.
		draw_text(start, pddsd->lPitch / bytespp,
				msg_width, msg_height,
				vdraw_msg_text, &vdraw_msg_style);
	}
	else if (vdraw_fps_enabled && (Game != NULL) && Settings.Active && !Settings.Paused && !IS_DEBUGGING())
	{
		// FPS is enabled.
		draw_text(start, pddsd->lPitch / bytespp,
				msg_width, msg_height,
				vdraw_msg_text, &vdraw_fps_style);
	}
	
	if (lock)
		lpDDS_Surface->Unlock(NULL);
}
开发者ID:PhilrocWP,项目名称:gens,代码行数:62,代码来源:vdraw_ddraw.cpp

示例13: Game_Main

int Game_Main(void *parms = NULL, int num_parms = 0)
{
// this is the main loop of the game, do all your processing
// here

DDBLTFX ddbltfx; // the blitter fx structure
static int feeling_counter = 0;   // tracks how we feel :)
static int happy = 1;             // let's start off being happy

// make sure this isn't executed again
if (window_closed)
   return(0);

// for now test if user is hitting ESC and send WM_CLOSE
if (KEYDOWN(VK_ESCAPE))
   {
   PostMessage(main_window_handle,WM_CLOSE,0,0);
   window_closed = 1;
   } // end if

// use the blitter to erase the back buffer
// first initialize the DDBLTFX structure
DDRAW_INIT_STRUCT(ddbltfx);

// now set the color word info to the color we desire
ddbltfx.dwFillColor = 0;

// make the blitter call
if (FAILED(lpddsback->Blt(NULL, // pointer to dest RECT, NULL for whole thing
                          NULL, // pointer to source surface
                          NULL, // pointer to source RECT
                          DDBLT_COLORFILL | DDBLT_WAIT, 
                          // do a color fill and wait if you have to
                          &ddbltfx))) // pointer to DDBLTFX holding info
return(0);

// initialize ddsd
DDRAW_INIT_STRUCT(ddsd);

// lock the back buffer surface
if (FAILED(lpddsback->Lock(NULL,&ddsd,
                              DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR,
                              NULL)))
    return(0);


// increment how we feel
if (++feeling_counter > 200)
   {
   feeling_counter = 0; 
   happy = -happy;
   } // end if

// draw all the happy faces
for (int face=0; face < 100; face++)
    {
    // are we happy or sad?
    if (happy==1) // we are happy :)
       Blit_Clipped(happy_faces[face].x, 
                    happy_faces[face].y,
                    8,8,    
                    happy_bitmap, 
                    (UCHAR *)ddsd.lpSurface,
                    ddsd.lPitch);         
     else // we must be sad :(
     Blit_Clipped(happy_faces[face].x, 
                  happy_faces[face].y,
                  8,8,    
                  sad_bitmap, 
                  (UCHAR *)ddsd.lpSurface,
                  ddsd.lPitch);     

    } // end face

// move all happy faces
for (face=0; face < 100; face++)
    {
    // move
    happy_faces[face].x+=happy_faces[face].xv;
    happy_faces[face].y+=happy_faces[face].yv;

    // check for off screen, if so wrap
    if (happy_faces[face].x > SCREEN_WIDTH)
         happy_faces[face].x = -8;
    else
    if (happy_faces[face].x < -8)
        happy_faces[face].x = SCREEN_WIDTH;

    if (happy_faces[face].y > SCREEN_HEIGHT)
         happy_faces[face].y = -8;
    else
    if (happy_faces[face].y < -8)
        happy_faces[face].y = SCREEN_HEIGHT;

    } // end face

// unlock surface
if (FAILED(lpddsback->Unlock(NULL)))
   return(0);

//.........这里部分代码省略.........
开发者ID:calyx,项目名称:windows-game-source-code,代码行数:101,代码来源:demo7_8.cpp

示例14: Game_Main

int Game_Main(void *parms = NULL, int num_parms = 0)
{
// this is the main loop of the game, do all your processing
// here

// make sure this isn't executed again
if (window_closed)
   return(0);

// for now test if user is hitting ESC and send WM_CLOSE
if (KEYDOWN(VK_ESCAPE))
   {
   PostMessage(main_window_handle,WM_CLOSE,0,0);
   window_closed = 1;
   } // end if

// clear out the back buffer
DDraw_Fill_Surface(lpddsback, 0);

// lock primary buffer
DDRAW_INIT_STRUCT(ddsd);

if (FAILED(lpddsback->Lock(NULL,&ddsd,
                           DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR,
                           NULL)))
return(0);

// draw all the asteroids
for (int curr_index = 0; curr_index < NUM_ASTEROIDS; curr_index++)
    {
    // do the graphics
    Draw_Polygon2D(&asteroids[curr_index], (UCHAR *)ddsd.lpSurface, ddsd.lPitch);

    // move the asteroid
    Translate_Polygon2D(&asteroids[curr_index],
                        asteroids[curr_index].xv,
                        asteroids[curr_index].yv);


    // rotate the polygon by 5 degrees
    Rotate_Polygon2D(&asteroids[curr_index], 5);

    // test for out of bounds
    if (asteroids[curr_index].x0 > SCREEN_WIDTH+100)
        asteroids[curr_index].x0 = - 100;

    if (asteroids[curr_index].y0 > SCREEN_HEIGHT+100)
        asteroids[curr_index].y0 = - 100;

    if (asteroids[curr_index].x0 < -100)
        asteroids[curr_index].x0 = SCREEN_WIDTH+100;

    if (asteroids[curr_index].y0 < -100)
        asteroids[curr_index].y0 = SCREEN_HEIGHT+100;

    } // end for curr_asteroid


// unlock primary buffer
if (FAILED(lpddsback->Unlock(NULL)))
   return(0);

// perform the flip
while (FAILED(lpddsprimary->Flip(NULL, DDFLIP_WAIT)));

// wait a sec
Sleep(33);

// return success or failure or your own return code here
return(1);

} // end Game_Main
开发者ID:calyx,项目名称:windows-game-source-code,代码行数:72,代码来源:demo8_4.cpp

示例15: loadBitmapDataFromFile

	BOOL JCDD_Wrapper::loadBitmapDataFromFile(INT surfaceID, LPWCH filePath)
	{
		if(lpjcdd->containsTheOffscreenSurface(surfaceID))
		{
			return FALSE;
		}

		JCDD_File file;
		if(!file.loadData(filePath))
		{
			return FALSE;
		}

		JCDD_BitmapData bmpd;
		if(!bmpd.create(file.getData()))
		{
			return FALSE;
		}
		BOOL reverseRow = bmpd.bmpInfoHeader.biHeight < 0;
		INT biWidth = bmpd.bmpInfoHeader.biWidth;
		INT biHeight = reverseRow ? -bmpd.bmpInfoHeader.biHeight : bmpd.bmpInfoHeader.biHeight;
		
		if(bmpd.bmpInfoHeader.biBitCount != BitmapDataBitCount_8 && 
			bmpd.bmpInfoHeader.biBitCount != BitmapDataBitCount_24 && 
			bmpd.bmpInfoHeader.biBitCount != BitmapDataBitCount_32)
		{
			return FALSE;
		}

		if(!lpjcdd->createOffscreenSurface(surfaceID, bmpd.bmpInfoHeader.biWidth, biHeight))
		{
			return FALSE;
		}

		LPJCDD_Surface surface = lpjcdd->getOffscreenSurface(surfaceID);
		LPDIRECTDRAWSURFACE7 lpdds = surface->getSurface();
		DDSURFACEDESC2 ddsd;
		jcdd_initStruct(&ddsd);
		if(FAILED(lpdds->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL)))
		{
			lpjcdd->deleteOffscreenSurface(surfaceID);
			return FALSE;
		}

		UINT* buffer = (UINT*)ddsd.lpSurface;
		INT pixelWidth = bmpd.bmpInfoHeader.biWidth;
		INT pixelHeight = biHeight;
		INT pixelWidthCount = 0;
		INT pixelHeightCount = biHeight - 1;
		INT pitch = ddsd.lPitch >> 2;

		if(bmpd.bmpInfoHeader.biBitCount == BitmapDataBitCount_8)
		{
			JCDD_BitmapDataColorIterator8Bit it(&bmpd);
			while(it.hasNext())
			{
				PALETTEENTRY color = bmpd.palette[it.next()];
				buffer[pixelWidthCount + pixelHeightCount * pitch] = jcdd_rgb32Bit(0x00, color.peRed, color.peGreen, color.peBlue);
				if(++pixelWidthCount == pixelWidth)
				{
					pixelWidthCount = 0;
					--pixelHeightCount;
				}
			}
		}
		else if(bmpd.bmpInfoHeader.biBitCount == BitmapDataBitCount_24)
		{
			JCDD_BitmapDataColorIterator24Bit it(&bmpd);
			while(it.hasNext())
			{
				JCDD_BitmapDataRGB* color = it.next();
				buffer[pixelWidthCount + pixelHeightCount * pitch] = jcdd_rgb32Bit(0x00, color->r, color->g, color->b);
				if(++pixelWidthCount == pixelWidth)
				{
					pixelWidthCount = 0;
					--pixelHeightCount;
				}
			}
		}
		else if(bmpd.bmpInfoHeader.biBitCount == BitmapDataBitCount_32)
		{
			JCDD_BitmapDataColorIterator32Bit it(&bmpd);
			while(it.hasNext())
			{
				JCDD_BitmapDataXRGB* color = it.next();
				buffer[pixelWidthCount + pixelHeightCount * pitch] = jcdd_rgb32Bit(0x00, color->r, color->g, color->b);
				if(++pixelWidthCount == pixelWidth)
				{
					pixelWidthCount = 0;
					--pixelHeightCount;
				}
			}
		}

		if(FAILED(lpdds->Unlock(NULL)))
		{
			lpjcdd->deleteOffscreenSurface(surfaceID);
			return FALSE;
		}

//.........这里部分代码省略.........
开发者ID:chengkehan,项目名称:lab,代码行数:101,代码来源:JCDD_Wrapper.cpp


注:本文中的LPDIRECTDRAWSURFACE7::Unlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。