all it is a simple class for drawing textured quads i get seem to see where its going wrong, nothing is being displayed at all
cpp file
Image2D::Image2D(void)
{
vbuf = NULL;
texture = NULL;
}
Image2D::~Image2D(void)
{
SAFE_RELEASE(vbuf);
SAFE_RELEASE(texture);
}
bool Image2D::Load(const wchar_t *filename)
{
if(D3DXCreateTextureFromFileEx(DXUTGetD3DDevice(), filename, D3DX_DEFAULT, D3DX_DEFAULT,
D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, &info, NULL, &texture) != D3D_OK)
return false;
std::cout << "loaded" << std::endl;
if(DXUTGetD3DDevice()->CreateVertexBuffer(sizeof(vert) * 4, 0, thisfvf, D3DPOOL_MANAGED, &vbuf, NULL) != D3D_OK)
return false;
std::cout << "created" << std::endl;
SetSize(0, 0, info.Width, info.Height);
return true;
}
void Image2D::Draw()
{
std::cout << "trying" << std::endl;
DXUTGetD3DDevice()->SetVertexShader(NULL);
DXUTGetD3DDevice()->SetFVF(thisfvf);
DXUTGetD3DDevice()->SetStreamSource(0, vbuf, 0, sizeof(vert));
DXUTGetD3DDevice()->SetTexture(0, texture);
DXUTGetD3DDevice()->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2);
}
bool Image2D::IsVisible()
{
return visible;
}
void Image2D::SetVisible(bool vis)
{
visible = vis;
}
void Image2D::SetSize(float x, float y, float x2, float y2)
{
_x = x;
_y = y;
_x2 = x2;
_y2 = y2;
vert *data;
if(vbuf->Lock(0, 0, (void **)&data, 0) == D3D_OK)
{
data[0].pos = D3DXVECTOR3(_x, _y, 1.0);
data[0].color = D3DCOLOR_XRGB(255, 255, 255);
data[0].tu = 0.0f;
data[0].tv = 0.0f;
data[1].pos = D3DXVECTOR3(_x, _y2, 1.0);
data[1].color = D3DCOLOR_XRGB(255, 255, 255);
data[1].tu = 0.0f;
data[1].tv = 1.0f;
data[2].pos = D3DXVECTOR3(_x2, _y2, 1.0);
data[2].color = D3DCOLOR_XRGB(255, 255, 255);
data[2].tu = 1.0f;
data[2].tv = 1.0f;
data[3].pos = D3DXVECTOR3(_x2, _y, 1.0);
data[3].color = D3DCOLOR_XRGB(255, 255, 255);
data[3].tu = 1.0f;
data[3].tv = 0.0f;
std::cout << "lock ok" << std::endl;
vbuf->Unlock();
}
}
void Image2D::SetLayer(int l)
{
layer = l;
}
int Image2D::GetLayer()
{
return layer;
}
h file
class Image2D
{
public:
Image2D(void);
~Image2D(void);
bool Load(const wchar_t *filename);
void Draw();
bool IsVisible();
void SetVisible(bool vis);
void SetSize(float x, float y, float x2, float y2);
void SetLayer(int l);
int GetLayer();
private:
static const DWORD thisfvf = (D3DFVF_XYZ | D3DFVF_DIFFUSE |D3DFVF_TEX1);
struct vert
{
D3DXVECTOR3 pos;
DWORD color;
float tu, tv;
};
private:
bool visible;
D3DXIMAGE_INFO info;
LPDIRECT3DTEXTURE9 texture;
LPDIRECT3DVERTEXBUFFER9 vbuf;
float _x, _y, _x2, _y2;
int layer;
};
the draw function is being called from the right place
and im setting up a correct projection matrix
any help would be grateful
tnx