Jump to content
  • Advertisement
Sign in to follow this  
LevyDee

Drawing a sprite

This topic is 2806 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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!