Sign in to follow this  
LevyDee

Drawing a sprite

Recommended Posts

LevyDee    376
Im getting an unknown exception on my sprites Draw function

/////////
My Header:
/////////


#ifndef DRAW_PANEL_H
#define DRAW_PANEL_H

#include "MAIN.h"

class DRAW_PANEL
{
public:

DRAW_PANEL();
void InitD3D(HWND);
void InitSprite();
void RenderFrame();
void D3DCleanUp();


private:

LPDIRECT3D9 _d3d;
LPDIRECT3DDEVICE9 _d3dDev;

LPD3DXSPRITE _drawSprite;

LPDIRECT3DTEXTURE9 _background;
};

#endif


////////////////////////////////////////
and the significant part of my cpp file:
////////////////////////////////////////


void DRAW_PANEL::InitSprite()
{
if(FAILED(D3DXCreateSprite(_d3dDev, &_drawSprite)))
{
MessageBox(NULL, "InitSprite Failure", "InitSprite Failure", NULL);
}

D3DXCreateTextureFromFile(_d3dDev, "testBG.BMP", &_background);

}

void DRAW_PANEL::RenderFrame()
{
_d3dDev->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,0);

_d3dDev->BeginScene();

_drawSprite->Begin(D3DXSPRITE_ALPHABLEND);
_drawSprite->Draw(_background, NULL, NULL, NULL, 0xFFFFFFFF);
_drawSprite->End();


_d3dDev->EndScene();

_d3dDev->Present(NULL, NULL, NULL, NULL);
}


Edit: I debugged and found my texture wasn't loading properly, I needed to tack on the full path, problem solved =D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this