Sign in to follow this  

Drawing a sprite

This topic is 2623 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

This topic is 2623 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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