for some reason, i get an access violation then it goes to this Line in memcpy.asm:
rep movsd ;N - move all of our dwords
here is my function with Memecry. Well, i'll just post the whole code.
#include "DarkGDK.h"
#include <globStruct.h>
#include <d3d9.h>
#include <d3dx9.h>
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")
struct VERTEX
{
int X,Y,Z,RHW;
DWORD Color;
};
#define D3DFVF_HEALTH_BOXES ( D3DFVF_XYZRHW | D3DFVF_DIFFUSE)
LPDIRECT3DVERTEXBUFFER9 VertexBuffer;
int Create2DHealthBox(int X1, int Y1, int X2, int Y2);
int Create2DHealthBoxColored(int X1, int Y1, int X2, int Y2, DWORD ColorA, DWORD ColorB, DWORD ColorC, DWORD ColorD);
int CreateHexgonHealthBar(int X1, int Y1, int X2, int Y2);
int CreateHexgonHealthBarColored(int X1, int Y1, int X2, int Y2, DWORD ColorA, DWORD ColorB, DWORD ColorC, DWORD ColorD);
VERTEX SquareHealth[4];
VERTEX HexgonBox[6];
// the main entry point for the application is this function
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
// our main loop
while ( LoopGDK ( ) )
{
Create2DHealthBox(10,10,100,30);
// update the screen
dbSync ( );
}
// return back to windows
return;
}
int Create2DHealthBox(int X1, int Y1, int X2, int Y2)
{
//First side of the box
SquareHealth[0].X = X1;
SquareHealth[0].Y = Y1;
SquareHealth[0].Color = g_pGlob->dwForeColor;
//Second side of the box
SquareHealth[1].X = X1;
SquareHealth[1].Y = Y2;
SquareHealth[1].Color = g_pGlob->dwForeColor;
//The buttom right side.
SquareHealth[2].X = X2;
SquareHealth[2].Y = Y1;
SquareHealth[2].Color = g_pGlob->dwForeColor;
SquareHealth[3].X = X2;
SquareHealth[3].Y = Y2;
SquareHealth[3].Color = g_pGlob->dwForeColor;
HRESULT result = dbGetDirect3DDevice()->CreateVertexBuffer(
4*sizeof(VERTEX),
0,
D3DFVF_HEALTH_BOXES,
D3DPOOL_DEFAULT,
&VertexBuffer,
NULL);
if(FAILED(result))
{
return 0;
}
dbGetDirect3DDevice()->SetTexture(0,NULL);
dbGetDirect3DDevice()->SetTexture(1,NULL);
dbGetDirect3DDevice()->SetVertexShader(NULL);
dbGetDirect3DDevice()->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
dbGetDirect3DDevice()->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
dbGetDirect3DDevice()->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
VOID* Temp = NULL;
VertexBuffer->Lock(0,sizeof(VERTEX),(VOID**)&Temp,D3DLOCK_DISCARD);
memcpy(Temp,SquareHealth,sizeof(SquareHealth));
VertexBuffer->Unlock();
dbGetDirect3DDevice()->SetStreamSource(0,VertexBuffer,0,sizeof(VERTEX));
dbGetDirect3DDevice()->SetFVF(D3DFVF_HEALTH_BOXES);
dbGetDirect3DDevice()->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2);
VertexBuffer->Release();
return 1;
}
Hopefully someone can tell me what i'm doing wrong.
"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack