Postby stark » Sun Dec 19, 2010 3:00 pm
No i'm not make every time Texture my friend....
This is my code's
show
how to i make a Texture...
i cut d3d codes for DECREASE code's.....
i set g_pd3dDevice->SetTexture( 0, g_pTexture );
in render Sub()...
Thank You "c0mas"
/////////////////////////BASE DEFINE///////////////////////////////////////
// Headers
#include <tchar.h>
#define _WIN32_WINNT 0x0500
#include "../f_in_box/include/f_in_box.h"
#pragma comment(lib, "../f_in_box/lib/f_in_box.lib")
// Direct 3D
#include <d3dx9math.h>
#include <d3d9types.h>
#define DEF_WIDTH (480)
#define DEF_HEIGHT (480)
#define DEF_MAIN_WND_WIDTH (480)
#define DEF_MAIN_WND_HEIGHT (480)
static HFPC g_hFPC = NULL;
static HWND g_hwndFlashPlayerControl = NULL;
static BOOL g_bTransparent;
static LPDWORD g_lpPixels = NULL;
static SIZE g_size = { 0 };
static RECT g_rcUpdate = { 0 };
D3DSURFACE_DESC d3dsd;
static void WINAPI FPCListener(HWND hwndFlashPlayerControl, LPARAM lParam, NMHDR* pNMHDR);
/////////////////////////////////////////////////////////////////////////////
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow )
g_hFPC = FPC_LoadRegisteredOCX();
g_hwndFlashPlayerControl =
FPC_CreateWindow(g_hFPC,
g_bTransparent ? WS_EX_LAYERED : 0,
NULL,
g_bTransparent ? WS_POPUP : WS_CHILD | WS_CLIPSIBLINGS | FPCS_TRANSPARENT,
0,
0,
DEF_WIDTH,
DEF_HEIGHT,
g_hWnd,
NULL,
NULL,
NULL);
FPC_PutMovie (g_hwndFlashPlayerControl,"c:\\5MOVIE.SWF");
FPC_Play(g_hwndFlashPlayerControl);
FPCSetEventListener(g_hwndFlashPlayerControl, &FPCListener, 0);
////////////////////////////////////////////////////////////////////////////////////////////////////initial Application
void init( void )
{
//Creat Texture;
D3DXCreateTexture(g_pd3dDevice,
DEF_WIDTH,
DEF_HEIGHT,
1,
0,
D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED,
&g_pTexture);
g_pTexture->GetLevelDesc(0, &d3dsd);
/////////////////////////////////////////void UpdateTexture()..........
// Size
SIZE size = { d3dsd.Width, d3dsd.Height };
D3DLOCKED_RECT rcLockedRect = { 0 };
RECT rc = g_rcUpdate;
g_pTexture->LockRect(0, &rcLockedRect, &rc, D3DLOCK_DISCARD);
{
if (NULL != g_lpPixels)
{
BYTE* pTextureBits = (BYTE*)rcLockedRect.pBits;
DWORD dwSizeOfLineInDWORDs = DEF_WIDTH;
DWORD* pBitmapBitsStart = g_lpPixels + (DEF_HEIGHT - rc.bottom) * dwSizeOfLineInDWORDs + rc.left;
BYTE* pLineTextureBits = pTextureBits + rcLockedRect.Pitch * (rc.bottom - rc.top - 1);
for (int j = rc.top; j < rc.bottom; j++)
{
DWORD* pPixels = (DWORD*)pLineTextureBits;
DWORD* pBitmapBits = pBitmapBitsStart;
/*
for (int i = rc.left; i < rc.right; i++)
{
*pPixels = *pBitmapBits;
pPixels++;
pBitmapBits++;
}
*/
CopyMemory(pPixels, pBitmapBits, (rc.right - rc.left) * sizeof(DWORD));
pLineTextureBits -= rcLockedRect.Pitch;
pBitmapBitsStart += dwSizeOfLineInDWORDs;
}
}
}
g_pTexture->UnlockRect(0);
}
//////////////////////////////////////////void WINAPI FPCListener....
static
void WINAPI FPCListener(HWND hwndFlashPlayerControl, LPARAM lParam, NMHDR* pNMHDR)
{
if (FPCN_UPDATE_RECT == pNMHDR->code)
{
g_rcUpdate = ((SFPCNUpdateRect*)pNMHDR)->rc;
if (g_rcUpdate.right > DEF_WIDTH)
g_rcUpdate.right = DEF_WIDTH;
if (g_rcUpdate.bottom > DEF_HEIGHT)
g_rcUpdate.bottom = DEF_HEIGHT;
// FPCN_PAINT will be sent
SendMessage(hwndFlashPlayerControl, WM_PAINT, 0, 0);
}
else if (FPCN_PAINT == pNMHDR->code)
{
SFPCNPaint* pFPCNPaint = (SFPCNPaint*)pNMHDR;
LPDWORD lpPixels = pFPCNPaint->lpPixels; // <-- pixels buffer
RECT rc;
GetClientRect(hwndFlashPlayerControl, &rc);
if (g_size.cx != rc.right || g_size.cy != rc.bottom)
{
if (NULL != g_lpPixels)
delete[] g_lpPixels;
g_size.cx = rc.right;
g_size.cy = rc.bottom;
g_lpPixels = new DWORD[g_size.cx * g_size.cy];
}
CopyMemory(g_lpPixels, lpPixels, g_size.cx * g_size.cy * sizeof(DWORD));
UpdateTexture();
render();
}
any thing's need ?
just tell me....
Thank You Very Much