Before you start in and say use this:
Code:
#ifndef FOO
#define FOO
..
#endif
I already have.
Problem:
I'm rendering a terrain scene with water that reflects the scene around it. All vectors for the water point straight up and the eventual plan is to use the Fresnel term in a shader to perturb the water. In order to do this correctly I must use cubic environment mapping. The basic idea of cubic environment mapping is that you draw the scene from 6 different directions with the camera at the center of the scene. Each view matrix represents a 90 degree field of view. You render this to a texture and then use that texture for the primtive that is supposed to reflect the geometry. But the catch is you cannot render the object that is doing the reflecting in the cube map render.
In order to do this in my system, the CWater object requires a pointer to the CTerrainApp class which is derived from CD3DApp which is the core engine code. The message loop of CD3DApp calls the pure virtual function ScreenRender. ScreenRender is then defined to call CoreRender with bRenderWater set to true. Inside of Water::Render(), if water reflections are enabled, then I call CWater::RenderCubeMap(). Inside of RenderCubeMap() I must call CTerrainApp::CoreRender with bRenderWater set to false.
So as you see CWater must include CTerrainApp.h and CTerrainApp.h must include CWater.h. MSVC .NET is telling me that CTerrainApp is an undefined identifier and thus spits out several more errors pointing to the fact that it does not know what CTerrainApp is in CWater file scope. Even though I'm including CTerrainApp.h, it is not including the file.
How do I fix this? I must call the render for the core engine in order to render the scene to the cube map texture, but it won't allow me to pass a pointer to it because it says it's undefined.
Quite odd.
Code:
#include "CD3DApp.h"
#include "CCamera.h" //Camera
#include "CTerrain.h" //Terrain
//#include "CSky.h" //Sky plane
#include "CWater.h" //Water plane w/ cubic environ mapping
//#include "CSun.h" //Sun billboard
#include "CFrustrum.h" //Frustum
#include "CSkyBox.h" //Skybox
//For fonts
#include "dxutil.h"
#include "d3dutil.h"
#include "d3dfont.h"
class CTerrainApp:public CD3DApp
{
CCamera *TheCamera;
...
...
Code:
#ifndef CWATER
#define CWATER
#include "d3dx9.h"
#include "dxutil.h"
#include "d3dutil.h"
#include "CTerrainApp.h"
struct WaterVertex
{
D3DXVECTOR3 Pos;
D3DXVECTOR3 Normal;
D3DCOLOR Color;
float u1,v1;
float u2,v2;
static const DWORD FVF;
WaterVertex(void):Pos(D3DXVECTOR3(0.0f,0.0f,0.0f)),Color(0),
Normal(D3DXVECTOR3(0.0f,0.0f,0.0f)),
u1(0.0f),v1(0.0f),u2(0.0f),v2(0.0f) {}
WaterVertex(D3DXVECTOR3 _Pos,float _u,float _v):Pos(_Pos),u1(_u),v1(_v) {}
WaterVertex(float x,float y,float z,float u,float v):
Pos(D3DXVECTOR3(x,y,z)),u1(u),v1(v) {}
};
class CWater
{
IDirect3DDevice9 *m_pDevice;
IDirect3DCubeTexture9 *m_pCubeMap;
WaterVertex Vertices[4];
CTerrainApp *m_pApp;
...
Results:
d:\msvc .net 05\terrain -.net 05\cwater.h(38) : error C2143: syntax error : missing ';' before '*'
d:\msvc .net 05\terrain -.net 05\cwater.h(38) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\msvc .net 05\terrain -.net 05\cwater.h(38) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\msvc .net 05\terrain -.net 05\cwater.h(51) : error C2061: syntax error : identifier 'CTerrainApp'
d:\msvc .net 05\terrain -.net 05\cterrainapp.h(32) : error C2143: syntax error : missing ';' before '*'
d:\msvc .net 05\terrain -.net 05\cterrainapp.h(32) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\msvc .net 05\terrain -.net 05\cterrainapp.h(32) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int