Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualXuchilbara

Posted 17 February 2013 - 09:32 PM

Currently Writing a new system, and I've put a small box with a texture on it, with DirectX11 (which was previously working before I started adding more unrelated code).

 

Now for some unknown reason, I've receiving this unhandled exception:

 

http://img15.imageshack.us/img15/5666/textureunload.png

 

Continuing will loop the same problem. I'm probably missing something really stupid, but I'd really like some insight to why this is happening.. Thanks!

 

 

Texture.cpp

#include "Texture.h"

/* Constructor & Deconstructor */
Texture::Texture()
{
	m_texture = 0;
}
Texture::~Texture(){}

/* Initialize */
bool Texture::Init(ID3D11Device* device, CHAR* filename)
{
	HRESULT r;

	//Load texture
	r = D3DX11CreateShaderResourceViewFromFile(device, filename, NULL, NULL, &m_texture, NULL);
	if(FAILED(r))
	{return false;}

	return true;
}

/* Return objects we are using to higher level */
ID3D11ShaderResourceView* Texture::GetTexture()
{return m_texture;}

/* Shutdown/Release Objects we have used */
void Texture::Shutdown()
{
	if(m_texture)
	{
		m_texture->Release();
		m_texture = 0;
	}
	return;
}

#1Xuchilbara

Posted 17 February 2013 - 09:31 PM

Currently Writing a new system, and I've put a small box with a texture on it, with DirectX11 (which was previously working before I started adding more unrelated code).

 

Now for some unknown reason, I've receiving this unhandled exception:

 

http://img15.imageshack.us/img15/5666/textureunload.png

 

Continuing will loop the same problem. I'm probably missing something really stupid, but I'd really like some insight to why this is happening.. Thanks!

 

Model.cpp - LoadTexture function

bool Model::LoadTexture(ID3D11Device* device, CHAR* filename)
{
	bool r;

	//Create the texture object
	m_texture = new Texture;
	if(!m_texture)
	{return false;}

	//Initialize the texture object
	r = m_texture->Init(device, filename);
	if(!r)
	{return false;}

	return true;
}

 

Texture.cpp


#include "Texture.h"

/* Constructor & Deconstructor */
Texture::Texture()
{
	m_texture = 0;
}
Texture::~Texture(){}

/* Initialize */
bool Texture::Init(ID3D11Device* device, CHAR* filename)
{
	HRESULT r;

	//Load texture
	r = D3DX11CreateShaderResourceViewFromFile(device, filename, NULL, NULL, &m_texture, NULL);
	if(FAILED(r))
	{return false;}

	return true;
}

/* Return objects we are using to higher level */
ID3D11ShaderResourceView* Texture::GetTexture()
{return m_texture;}

/* Shutdown/Release Objects we have used */
void Texture::Shutdown()
{
	if(m_texture)
	{
		m_texture->Release();
		m_texture = 0;
	}
	return;
}

 

 

 


PARTNERS