Jump to content

  • Log In with Google      Sign In   
  • Create Account

kennez

Member Since 26 Feb 2013
Offline Last Active Feb 26 2013 10:24 AM

Topics I've Started

Loading TGA - problems

26 February 2013 - 09:57 AM

Hi all,

 

First post here, so please be gentle with me. I'm sure I'm doing something really stupid, but I can't for the life of me figure it out!

 

I'm following this tutorial, http://www.rastertek.com/gl40tut05.html , and I'm having major problems - I cannot get the targa file texture to display at all. I've tried copying and pasting the code direct from the website into my project, but to no avail.

 

The relevant function is from the file graphicsclass.cpp, and the function is Initialize()

 

bool GraphicsClass::Initialize(OpenGLClass* OpenGL, HWND hwnd)
{
	bool result;


	// Store a pointer to the OpenGL class object.
	m_OpenGL = OpenGL;

	// Create the camera object.
	m_Camera = new CameraClass;
	if(!m_Camera)
	{
		return false;
	}

	// Set the initial position of the camera.
	m_Camera->SetPosition(0.0f, 0.0f, -10.0f);

	// Create the model object.
	m_Model = new ModelClass;
	if(!m_Model)
	{
		return false;
	}

	// Get the full path of current exe file.
	TCHAR FilePath[MAX_PATH] = { 0 };
	GetModuleFileName( 0, FilePath, MAX_PATH );

	// Strip the exe filename from path and get folder name.
	PathRemoveFileSpec( FilePath );    

	// Set the current working directory.
	SetCurrentDirectory( FilePath );

	MessageBox( hwnd, FilePath, L"Error", MB_OK );

	// Initialize the model object.
	result = m_Model->Initialize( m_OpenGL, "data/test.tga", 0, true );
	if( !result ) {
		MessageBox( hwnd, L"Could not initialize the model object.", L"Error", MB_OK );
		return false;
	}
	
	// Create the texture shader object.
	m_TextureShader = new TextureShaderClass;
	if(!m_TextureShader)
	{
		return false;
	}

	// Initialize the texture shader object.
	result = m_TextureShader->Initialize(m_OpenGL, hwnd);
	if(!result)
	{
		MessageBox(hwnd, L"Could not initialize the texture shader object.", L"Error", MB_OK);
		return false;
	}

	return true;
}

I keep hitting the error "Could not initialize the model object."

 

I've even gone through the other classes, copying and pasting them directly, but it still doesn't work. Any ideas?

 

Thanks,

Malcolm


PARTNERS