Ir para conteúdo
Faça parte da equipe! (2024) ×
Conheça nossa Beta Zone! Novas áreas a caminho! ×
  • Quem está por aqui   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.

D3D9 úteis / C + + Info, Funções, Cham Alternâncias e muito mais!


JuαnxD ~
 Compartilhar

Posts Recomendados

Aqui está uma lista de funções D3D9 úteis, informações, e outros itens variados.

 

Se você gostaria de adicionar uma função, postá-lo abaixo (com créditos) e vou adicioná-lo aqui! Além disso, se eu perdi todos os créditos, por favor diga, para que eu possa acrescentá-los!

 

Este post realmente tem informação suficiente para você fazer seu próprio D3D9 Base.

 

Divirta-se!

 

 

 

 

 

D3D9 Valores vtable (Créditos para Str1k3r21):

 

 

 

QueryInterface // 0

AddRef // 1

Release // 2

TestCooperativeLevel // 3

GetAvailableTextureMem // 4

EvictManagedResources // 5

GetDirect3D // 6

GetDeviceCaps // 7

GetDisplayMode // 8

GetCreationParameters // 9

SetCursorProperties // 10

SetCursorPosition // 11

ShowCursor // 12

CreateAdditionalSwapChain // 13

GetSwapChain // 14

GetNumberOfSwapChains // 15

Reset // 16

Present // 17

GetBackBuffer // 18

GetRasterStatus // 19

SetDialogBoxMode // 20

SetGammaRamp // 21

GetGammaRamp // 22

CreateTexture // 23

CreateVolumeTexture // 24

CreateCubeTexture // 25

CreateVertexBuffer // 26

CreateIndexBuffer // 27

CreateRenderTarget // 28

CreateDepthStencilSurface // 29

UpdateSurface // 30

UpdateTexture // 31

GetRenderTargetData // 32

GetFrontBufferData // 33

StretchRect // 34

ColorFill // 35

CreateOffscreenPlainSurface // 36

SetRenderTarget // 37

GetRenderTarget // 38

SetDepthStencilSurface // 39

GetDepthStencilSurface // 40

BeginScene // 41

EndScene // 42

Clear // 43

SetTransform // 44

GetTransform // 45

MultiplyTransform // 46

SetViewport // 47

GetViewport // 48

SetMaterial // 49

GetMaterial // 50

SetLight // 51

GetLight // 52

LightEnable // 53

GetLightEnable // 54

SetClipPlane // 55

GetClipPlane // 56

SetRenderState // 57

GetRenderState // 58

CreateStateBlock // 59

BeginStateBlock // 60

EndStateBlock // 61

SetClipStatus // 62

GetClipStatus // 63

GetTexture // 64

SetTexture // 65

GetTextureStageState // 66

SetTextureStageState // 67

GetSamplerState // 68

SetSamplerState // 69

ValidateDevice // 70

SetPaletteEntries // 71

GetPaletteEntries // 72

SetCurrentTexturePalette // 73

GetCurrentTexturePalette // 74

SetScissorRect // 75

GetScissorRect // 76

SetSoftwareVertexProcessing // 77

GetSoftwareVertexProcessing // 78

SetNPatchMode // 79

GetNPatchMode // 80

DrawPrimitive // 81

DrawIndexedPrimitive // 82

DrawPrimitiveUP // 83

DrawIndexedPrimitiveUP // 84

ProcessVertices // 85

CreateVertexDeclaration // 86

SetVertexDeclaration // 87

GetVertexDeclaration // 88

SetFVF // 89

GetFVF // 90

CreateVertexShader // 91

SetVertexShader // 92

GetVertexShader // 93

SetVertexShaderConstantF // 94

GetVertexShaderConstantF // 95

SetVertexShaderConstantI // 96

GetVertexShaderConstantI // 97

SetVertexShaderConstantB // 98

GetVertexShaderConstantB // 99

SetStreamSource // 100

GetStreamSource // 101

SetStreamSourceFreq // 102

GetStreamSourceFreq // 103

SetIndices // 104

GetIndices // 105

CreatePixelShader // 106

SetPixelShader // 107

GetPixelShader // 108

SetPixelShaderConstantF // 109

GetPixelShaderConstantF // 110

SetPixelShaderConstantI // 111

GetPixelShaderConstantI // 112

SetPixelShaderConstantB // 113

GetPixelShaderConstantB // 114

DrawRectPatch // 115

DrawTriPatch // 116

DeletePatch // 117

CreateQuery // 118

 

 

 

 

 

ARGB Cores D3D:

 

 

//Colors are A,R,G,B meaning alpha(opacity), red, green, blue

D3DCOLOR RED = D3DCOLOR_ARGB(255, 255, 0, 0);

D3DCOLOR GREEN = D3DCOLOR_ARGB(255, 0, 255, 0);

D3DCOLOR BLUE = D3DCOLOR_ARGB(255, 0, 0, 255);

D3DCOLOR WHITE = D3DCOLOR_ARGB(255, 255, 255, 255);

D3DCOLOR BLACK = D3DCOLOR_ARGB(255, 0, 0, 0);

D3DCOLOR YELLOW = D3DCOLOR_ARGB(255, 255, 255, 0);

D3DCOLOR TEAL = D3DCOLOR_ARGB(255, 0, 255, 255);

D3DCOLOR PINK = D3DCOLOR_ARGB(255, 255, 240, 0);

D3DCOLOR ORANGE = D3DCOLOR_ARGB(255, 255, 132, 0);

D3DCOLOR LIME = D3DCOLOR_ARGB(255, 198, 255, 0);

D3DCOLOR SKY BLUE = D3DCOLOR_ARGB(255, 0, 180, 255);

D3DCOLOR MAROON = D3DCOLOR_ARGB(255, 142, 30, 0);

D3DCOLOR LGRAY = D3DCOLOR_ARGB(255, 174, 174, 174); //Light Gray

D3DCOLOR DGRAY = D3DCOLOR_ARGB(255, 71, 65, 64); //Dark Gray

D3DCOLOR BROWN = D3DCOLOR_ARGB(255, 77, 46, 38);

D3DCOLOR SHIT = D3DCOLOR_ARGB(255, 74, 38, 38); //Shit and brown aint much different

 

 

 

 

Gerar a função de textura (Créditos para Azorbix):

 

 

 

HRESULT GenerateTexture(IDirect3DDevice9 *pD3Ddev, IDirect3DTexture9 **ppD3Dtex, DWORD colour32)

{

if( FAILED(pD3Ddev->CreateTexture(8, 8, 1, 0, D3DFMT_A4R4G4B4, D3DPOOL_MANAGED, ppD3Dtex,NULL)) )

return E_FAIL;

 

WORD colour16 = ((WORD)((colour32>>28)&0xF)<<12)

|(WORD)(((colour32>>20)&0xF)<<8)

|(WORD)(((colour32>>12)&0xF)<<4)

|(WORD)(((colour32>>4)&0xF)<<0);

 

D3DLOCKED_RECT d3dlr;

(*ppD3Dtex)->LockRect(0, &d3dlr, 0, 0);

WORD *pDst16 = (WORD*)d3dlr.pBits;

 

for(int xy=0; xy < 8*8; xy++)

*pDst16++ = colour16;

 

(*ppD3Dtex)->UnlockRect(0);

 

return S_OK;

}

 

 

EndScene(vTable 42):

 

 

typedef HRESULT (WINAPI* oEndScene)(LPDIRECT3DDEVICE9 pDevice);

oEndScene pEndScene;

 

 

HRESULT WINAPI EndScene(LPDIRECT3DDEVICE9 pDevice)

{

return pEndScene(pDevice);

}

 

 

 

Reset (vtable 16):

 

 

typedef HRESULT ( WINAPI* oReset )( LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters );

oReset pReset;

 

HRESULT WINAPI Reset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters )

{

 

return pReset(pDevice, pPresentationParameters);

}

 

 

 

 

 

Draw Indexed Primitive[DIP (vTable 82)]:

 

 

typedef HRESULT (WINAPI* oDIP)(LPDIRECT3DDEVICE9 pDevice,D3DPRIMITIVETYPE,int,UINT,UINT,UINT,UINT);

oDIP pDIP;

 

 

HRESULT WINAPI DIP(LPDIRECT3DDEVICE9 pDevice,D3DPRIMITIVETYPE Type,int BaseVertexIndex,UINT MinIndex,UINT NumVertices,UINT StartIndex,UINT PrimCount)

{

return pDIP(pDevice, Type, BaseVertexIndex, MinIndex, NumVertices, StartIndex, PrimCount);

}

 

 

 

 

 

Encontrar padrão de função (Créditos para d0m1n1c):

 

 

bool bCompare(const BYTE* pData, const BYTE* bMask, const char* szMask)

{

for(;*szMask;++szMask,++pData,++bMask)

if(*szMask=='x' && *pData!=*bMask)

return 0;

return (*szMask) == NULL;

}

 

DWORD FindPattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask)

{

for(DWORD i=0; i<dwLen; i++)

if (bCompare((BYTE*)(dwAddress+i),bMask,szMask))

return (DWORD)(dwAddress+i);

return 0;

}

 

 

 

 

Desvio de função Create (Créditos para Azorbix):

 

 

void *DetourCreate(BYTE *src, const BYTE *dst, const int len)

{

BYTE *jmp = (BYTE*)malloc(len+5);

DWORD dwBack;

 

VirtualProtect(src, len, PAGE_EXECUTE_READWRITE, &dwBack);

memcpy(jmp, src, len);

jmp += len;

jmp[0] = 0xE9;

*(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;

src[0] = 0xE9;

*(DWORD*)(src+1) = (DWORD)(dst - src) - 5;

for (int i=5; i<len; i++) src=0x90;

VirtualProtect(src, len, dwBack, &dwBack);

return (jmp-len);

 

 

 

 

Imagem de fundo (Criar Textura de arquivo na memória):

 

 

 

D3DXCreateTextureFromFileInMemory(pDevice,imagebytes,size,LPDIRECT3DTEXTURE9);

 

 

PrintText Função (créditos para ac1d_bUrn, ele deu-me a acrescentar à lista):

 

 

 

void PrintText(LPD3DXFONT Font, long x, long y, D3DCOLOR fontColor, char *text, ...)

{

RECT rct;

rct.left = x - 1;

rct.right = x + 1;

rct.top = y - 1 ;

rct.bottom = y + 1;

 

if(!text) { return; }

va_list va_alist;

char logbuf[256] = {0};

va_start (va_alist, text);

_vsnprintf (logbuf+strlen(logbuf), sizeof(logbuf) - strlen(logbuf), text, va_alist);

va_end (va_alist);

RECT FontRect = { x, y, x, y };

pFont->DrawText(NULL, logbuf, -1, &rct, DT_NOCLIP, fontColor);

}

 

 

 

Desenhar Caixa de Função (créditos para ac1d_bUrn, ele deu-me a acrescentar à lista):

 

 

 

void FillRGB( int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* pDevice )

{

D3DRECT rec = { x, y, x + w, y + h };

pDevice->Clear( 1, &rec, D3DCLEAR_TARGET, color, 0, 0 );

}

 

 

 

 

Desenhar borda Função (créditos para ac1d_bUrn, ele deu-me a acrescentar à lista):

 

 

 

 

void DrawBorder( int x, int y, int w, int h, int px, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )

{

FillRGB( x, (y + h - px), w, px, BorderColor, pDevice );

FillRGB( x, y, px, h, BorderColor, pDevice );

FillRGB( x, y, w, px, BorderColor, pDevice );

FillRGB( (x + w - px), y, px, h, BorderColor, pDevice );

}

 

 

 

 

Desenhar Caixa com Fronteira Função (créditos para ac1d_bUrn, ele deu-me a acrescentar à lista) (Você vai precisar de mais de 2 funções para usá-lo)

 

 

 

void DrawBox( int x, int y, int w, int h, D3DCOLOR BoxColor, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )

{

FillRGB( x, y, w, h, BoxColor, pDevice );

DrawBorder( x, y, w, h, 1, BorderColor, pDevice );

}

 

 

 

 

Desenhe CrossHair Função (créditos para ac1d_bUrn (dando-me)):

 

 

 

void DrawCrosshair(LPDIRECT3DDEVICE9 pDevice, int size, int strong, D3DCOLOR xcolor)

{

int iCenterX = GetSystemMetrics( 0 ) / 2;

int iCenterY = GetSystemMetrics( 1 ) / 2;

if( iCenterX < 20 && iCenterY < 20 )

{

iCenterX = ( GetSystemMetrics( 0 ) / 2 );

iCenterY = ( GetSystemMetrics( 1 ) / 2 );

}

D3DRECT rec2 = { iCenterX- size, iCenterY, iCenterX+ size, iCenterY+ strong};

D3DRECT rec3 = { iCenterX, iCenterY- size, iCenterX+ strong,iCenterY+ size};

pDevice->Clear(1, &rec2, D3DCLEAR_TARGET, xcolor, 1000, 0);

pDevice->Clear(1, &rec3, D3DCLEAR_TARGET, xcolor, 100, 0);

}

 

 

 

 

Desenhe Healthbar Função (Créditos Para Bater para codificá-la, ac1d_bUrn, ele deu-me a acrescentar à lista)

 

 

 

void DrawHealthBar(int x, int y, int w, int h, D3DCOLOR color, D3DCOLOR BorderColor, int hp, int maxhp)

{

FillRGB(x, y, ( hp / (double)maxhp ) * w, h, color, g_pDevice);

DrawBorder(x, y, w, h, 1, BorderColor, g_pDevice);

}

 

 

 

 

Movendo seu menu para Mouse coordenadas de Button (Créditos para Zanza):

 

 

 

 

int MoveMenu;

 

if(GetAsyncKeyState(VK_DELETE)) MoveMenu = (!MoveMenu);

 

if( MoveMenu ) {

POINT myCursor;

GetCursorPos(&myCursor); // get the cursor position.

if(GetAsyncKeyState(VK_LBUTTON)) {

menu.x = myCursor.x; // set the x of your menu to the cursor x position.

menu.y = myCursor.y; // set the y of your menu to the cursor y position.

}

}

 

 

 

 

Generate Material (Créditos para Bater):

 

 

 

D3DMATERIAL9 GenerateMaterial(int r, int g, int b){

 

D3DMATERIAL9 myMaterial;

D3DCOLORVALUE myColor;

 

myColor.a = 255;

myColor.r = (float)r / 255;

myColor.g = (float)g / 255;

myColor.b = (float)b / 255;

 

myMaterial.Ambient = myColor;

myMaterial.Diffuse = myColor;

myMaterial.Emissive = myColor;

myMaterial.Specular = myColor;

 

return myMaterial;

 

}

 

 

 

 

 

Cham Alterations(NOOB PROOF):

 

 

Luz Chams (Créditos para o Kernel, modificada para D3D9 por CodeDemon):

 

 

 

void SetLightChams(float A, float R, float G, float B, IDirect3DDevice9 *pDevice)

{

D3DMATERIAL9 pMaterial;

ZeroMemory(&pMaterial, sizeof(D3DMATERIAL9));

pDevice->SetRenderState(D3DRS_LIGHTING, TRUE); //Enable Lighting

//Ambient

pMaterial.Ambient.a = (A/255);

pMaterial.Ambient.r = (R/255);

pMaterial.Ambient.g = (G/255);

pMaterial.Ambient.b = (B/255);

//Diffuse

pMaterial.Diffuse.a = (A/255);

pMaterial.Diffuse.r = (R/255);

pMaterial.Diffuse.g = (G/255);

pMaterial.Diffuse.b = (B/255);

//Specular

pMaterial.Specular.a = (A/255);

pMaterial.Specular.r = (R/255);

pMaterial.Specular.g = (G/255);

pMaterial.Specular.b = (B/255);

pDevice->SetMaterial(&pMaterial);

}

 

 

 

 

 

Como usar (DIP):

 

 

//ZBUFFER OFF(Any Real Coder would know what this is! )

SetLightChams(255,255,0,0, pDevice);

 

pDIP;

//ZBUFFER ON

SetLightChams(255,0,0,255, pDevice);

 

 

 

Resultado

 

 

combatarms06v.jpg

 

 

 

Chams Overlay / n Chams Textura (Créditos para Pheron):

 

 

//ZBUFFER OFF

pDevice->SetRenderState(D3DRS_LIGHTING, true);

pDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT);

pDevice->SetRenderState(D3DRS_FOGENABLE, false);

pDevice->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_ARGB(255,255,0,0));

 

pDIP;

//ZBUFFER ON

pDevice->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_ARGB(255,0,255,0));

 

 

 

 

Resultado

 

 

combatarms10h.jpg

 

 

 

 

Chams Ghost (Créditos de Sangue):

 

 

 

pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true);

pDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVDESTCOLOR);

pDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_INVSRCCOLOR);

//ZBUFFER OFF

 

pDIP;

 

pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true);

pDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVDESTCOLOR);

pDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_INVSRCCOLOR);

//ZBUFFER ON

 

 

 

Resultado

 

 

 

combatarms11i.jpg

 

 

Chams Fantasma (Créditos de Sangue):

 

 

 

 

pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true);

pDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVDESTCOLOR);

pDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_INVSRCALPHA);

//ZBUFFER OFF

 

pDIP;

 

pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true);

pDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVDESTCOLOR);

pDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_INVSRCALPHA);

//ZBUFFER ON

 

 

 

 

Resultado

 

 

 

 

combatarms13m.jpg

 

 

 

Gostouuu ? Agradeça , não custa Nada ! Valeu galera !

Link para o comentário
Compartilhar em outros sites

Este tópico está impedido de receber novos posts.
 Compartilhar

×
×
  • Criar Novo...

Informação Importante

Nós fazemos uso de cookies no seu dispositivo para ajudar a tornar este site melhor. Você pode ajustar suas configurações de cookies , caso contrário, vamos supor que você está bem para continuar.