I've been getting this odd error on my DirectX app, first, I create an array of LPCSTRing's (this is just a character format incase you haven't encountered if before), and fill it like so
LPCSTR cCubeMapDirectories[9];
cCubeMapDirectories[0] = "Media/LightProbes/uffizi_cross.dds";
cCubeMapDirectories[1] = "Media/LightProbes/beach_cross.dds";
cCubeMapDirectories[2] = "Media/LightProbes/building_cross.dds";
cCubeMapDirectories[3] = "Media/LightProbes/rnl_cross.dds";
cCubeMapDirectories[4] = "Media/LightProbes/stpeters_cross.dds";
cCubeMapDirectories[5] = "Media/LightProbes/grace_cross.dds";
cCubeMapDirectories[6] = "Media/LightProbes/campus_cross.dds";
cCubeMapDirectories[7] = "Media/LightProbes/galileo_cross.dds";
cCubeMapDirectories[8] = "Media/LightProbes/kitchen_cross.dds";
I then pass this array to the 'create' function of a skybox class like so;
hr = g_SkyBox.CreateSkyBox(g_pd3dDevice,
&BackBufferDesc,
50,
cCubeMapDirectories,
"Media/Effects/SkyBox.fx");
I then copy it into a vector of LPCSTRing's in the class like so
for(int i = 0; i < sizeof(strCubeMapFilePaths); i++)
{
m_EnvironmentMapDirs.push_back(strCubeMapFilePaths);
}
// the data member m_EnvironmentMapDirs is private and declared as such:
std::vector<LPCSTR> m_EnvironmentMapDirs; // stores paths for light probes
After this, I have a function that allows me to set the current light probe cube map based on an index passed to it, the index is also stored in a UNIT data member in the private section of the class, the function for navigating is as follows;
/******SetEnvironmentMapByIndex*******/
HRESULT SetEnvironmentMapByIndex(UINT uiIndex)
{
// make sure that the index is in the arrays range
if(uiIndex < 0 || uiIndex > m_EnvironmentMapDirs.size())
return E_FAIL;
HRESULT hr;
SAFE_RELEASE(m_pEnvironmentMap);
IDirect3DCubeTexture9* pCubeTexture = NULL;
hr = D3DXCreateCubeTextureFromFileEx(m_pd3dDevice, m_EnvironmentMapDirs[uiIndex], D3DX_DEFAULT, 1, 0, D3DFMT_A16B16G16R16F,
D3DPOOL_MANAGED, D3DX_FILTER_LINEAR, D3DX_FILTER_LINEAR, 0, NULL,
NULL, &pCubeTexture);
CHECK_RESULT(hr, "Could not set environment by index");
m_pEnvironmentMap = pCubeTexture;
m_EnvironmentMapIndex = uiIndex;
return hr;
}
although, what happens when I get to the 5th element (m_EnvironmentMapDirs[4]) is that I get a debug assertion error saying "Expression: vector subscript out of range" and the debug points me here
[source lang"cpp"]
// this is in the vector file
#if _HAS_ITERATOR_DEBUGGING
if (size() <= _Pos)
{
_DEBUG_ERROR("vector subscript out of range");
_SCL_SECURE_OUT_OF_RANGE;
}
I don't see how I am trying to access a member of the vector outside of it's range when it's size is 9, any ideas?