My problem is about including header files. I don't want to include headers in other header file so when I need it, I always write declarations the beginning of the header and include in the cpp files as you can see, but this time it does not work.
BaseModel.h
#pragma once
#include <vector>
#include <unordered_map>
#include <string>
class Texture
{
public:
void addTexture2D(const char* keyname, int filter, int wrap, int internalformat, int format, int width, int height, unsigned char* texelData);
void addTextureCubeMap(const char* keyname, int filter, int wrap, int internalformat, int format, int width, int height, unsigned char* texelData);
void bindTexture(const char* keyname, unsigned int additionalUnits = 0);
inline static Texture* const getInstance() { return m_instance; }
private:
static Texture* const m_instance;
std::unordered_map<const char*, unsigned int> m_textureIDs;
Texture();
~Texture();
friend void terminateEngine();
};
class Mesh
{
public:
Mesh();
Mesh(const Mesh& copy) = delete;
Mesh(Mesh&& move) noexcept;
~Mesh();
void addVertexBuffer(size_t sizeInByte, const void* data, const unsigned int* perAttribSize, const unsigned int attribCount, unsigned int divisorValue, bool isDynamic = false);
void addIndexBuffer(size_t sizeInByte, const void* data);
void Bind() const;
inline const unsigned int& getVertexArrayId() const { return m_vertexArrayID; }
private:
unsigned int m_attribIndex;
unsigned int m_vertexArrayID;
std::vector<unsigned int> m_buffers;
};
class Program
{
public:
struct Shaders
{
unsigned int vertexShader;
unsigned int tessControlShader;
unsigned int tessEvaluationShader;
unsigned int geometryShader;
unsigned int fragmentShader;
};
Program();
Program(const Program& copy) = delete;
Program(Program&& move) noexcept;
~Program();
void addShaders(const Shaders& shaders);
void addComputeShader(const unsigned int computeShader);
void Bind() const;
inline const unsigned int& getProgramID() const { return m_programID; }
private:
unsigned int m_programID;
};
Model.h
#pragma once
#include "Interfaces.h"
#include "glm/glm.hpp"
class Mesh;
class Program;
class Surface
{
public:
Surface(const unsigned int seed, float chunkSize, float instanceCountperSide);
Surface(const Surface& copy) = delete;
Surface(Surface&& move) noexcept = delete;
~Surface();
void Render(const glm::vec3& cameraPos);
private:
Mesh m_mesh;
Program m_program;
unsigned int m_indexCount;
float a;
float globaltexCoords[2];
int m_cameraLoc;
int m_globaltexCoordloc;
};
In Model.cpp
#include "Model.h"
#include "BaseModel.h"
#include "glad/glad.h"
#include "GLFW/glfw3.h" // Silincek
#include "stb_image.h"
#include "FileIO.h"
The problem says Surface::m_mesh and Surface::m_program are undefined classes 'Mesh' and 'Program' but actually I added them as can be seen in the Model.cpp. Why do I encounter with the this problem?
I have examined the preprocessor file of Model.cpp and there is nothing wrong.