Здравствуйте, столкнулся с довольно обычной проблемой, однако не могу ее решить обычными методами. Знаю, что такая ошибка случается когда есть рекурсивные зависимости, однако таковых у себя в проекте я не нашел. Также знаю, что помогает forward declaration, однако если я использую его, компилятор ругается на не существующие методы.
Ниже представлены заголовки классов:
#ifndef FUTUREENGINE_TEXTURE_H
#define FUTUREENGINE_TEXTURE_H
#include <vector>
#include "Platform.h"
class Texture {
protected:
enum Filtering : GLint {
Near = GL_NEAREST,
Linear = GL_LINEAR,
NearMipmap = GL_NEAREST_MIPMAP_NEAREST,
LinearMipmap = GL_LINEAR_MIPMAP_LINEAR
};
enum Wrapping : GLint {
Repeat = GL_REPEAT,
MirroredRepeat = GL_MIRRORED_REPEAT,
ClampToEdge = GL_CLAMP_TO_EDGE,
ClampToBorder = GL_CLAMP_TO_BORDER
};
enum TextureType : GLenum {
_1D = GL_TEXTURE_1D,
_2D = GL_TEXTURE_2D,
_3D = GL_TEXTURE_3D,
ARRAY_1D = GL_TEXTURE_1D_ARRAY,
ARRAY_2D = GL_TEXTURE_2D_ARRAY,
BUFFER = GL_TEXTURE_BUFFER,
CUBEMAP = GL_TEXTURE_CUBE_MAP,
MULTISAMPLE = GL_TEXTURE_2D_MULTISAMPLE,
};
enum ImageFormat : GLint{
R8 = GL_R8,
R8_SNORM = GL_R8_SNORM,
R16 = GL_R16,
R16_SNORM = GL_R16_SNORM,
RG8 = GL_RG8,
RG8_SNORM = GL_RG8_SNORM,
RG16 = GL_R16,
RG16_SNORM = GL_RG16_SNORM,
R3G3B2 = GL_R3_G3_B2,
RGB4 = GL_RGB4,
RGB5 = GL_RGB5,
RGB8 = GL_RGB8,
RGB8_SNORM = GL_RG8_SNORM,
RGB10 = GL_RGB10,
RGB12 = GL_RGB12,
RGB16 = GL_RGB16,
RGB16_SNORM = GL_RGB16_SNORM,
RGBA2 = GL_RGBA2,
RGBA4 = GL_RGBA4,
RGBA5_A1 = GL_RGB5_A1,
RGBA8 = GL_RGBA8,
RGBA8_SNORM = GL_RGBA8_SNORM,
RGB10_A2 = GL_RGB10_A2,
RGB10_A2UI = GL_RGB10_A2UI,
RGBA12 = GL_RGBA12,
RGBA16 = GL_RGBA16,
SRGB8 = GL_SRGB8,
SRGB8_A8 = GL_SRGB8_ALPHA8,
R16F = GL_R16F,
RG16F = GL_RG16F,
RGB16F = GL_RGB16F,
RGBA16F = GL_RGBA16F,
R32F = GL_R32F,
RG32F = GL_RG32F,
RGB32F = GL_RGB32F,
RGBA32F = GL_RGBA32F,
R11FG11FB10F = GL_R11F_G11F_B10F,
RGB9E5 = GL_RGB9_E5,
R8I = GL_R8I,
R8UI = GL_R8UI,
R16I = GL_R16I,
R16UI = GL_R16UI,
R32I = GL_R32I,
R32UI = GL_R32UI,
RG8I = GL_R8I,
RG8UI = GL_RG8UI,
RG16I = GL_RG16I,
RG16UI = GL_RG16UI,
RG32I = GL_R32I,
RG32UI = GL_R32UI,
RGB8I = GL_RGB8I,
RGB8UI = GL_RGB8UI,
RGB16I = GL_RGB16I,
RGB16UI = GL_RGB16UI,
RGB32I = GL_RGB32I,
RGB32UI = GL_RGB32UI,
RGBA8I = GL_RGBA8I,
RGBA8UI = GL_RGBA8UI,
RGBA16I = GL_RGBA16I,
RGBA16UI = GL_RGBA16UI,
RGBA32I = GL_RGBA32I,
RGBA32UI = GL_RGBA32UI,
};
enum ImageType : GLint{
ColorIndex = GL_COLOR_INDEX,
Red = GL_RED,
Green = GL_GREEN,
Blue = GL_BLUE,
Alpha = GL_ALPHA,
RGB = GL_RGB,
BGR = GL_BGR,
RGBA = GL_RGBA,
BGRA = GL_BGRA,
Luminance = GL_LUMINANCE,
LuminanceAlpha = GL_LUMINANCE_ALPHA,
};
GLuint _location;
GLuint _texture;
GLenum _textureType;
public:
/*
* Generate texture and assign value to it
*/
Texture(GLfloat* textureColors, TextureType textureType, Wrapping wrapping, Filtering filtering, ImageFormat format, ImageType type, int width, int height, int lenght);
/*
* Generate cubemap texture and assign value to it
* First assign value to positive X
* Second assign value to negative X
* Third assign value to positive Y
* Fourth assign value to negative Y
* Fifth assign value to positive Z
* Sixth assign value to negative Z
*/
Texture(GLfloat** textureColors, Wrapping wrapping, Filtering filtering, ImageFormat format, ImageType type, int width, int height);
/*
* Return current texture
*/
GLuint& TextureValue();
/*
* Activate texture and bind it
*/
void Activate();
};
#endif //FUTUREENGINE_TEXTURE_H
#ifndef FUTUREENGINE_MODEL_H
#define FUTUREENGINE_MODEL_H
#include <assert.h>
#include <iostream>
#include "Platform.h"
#include "Shader.h"
class Mesh {
protected:
/*
* Structure to save vertex data for every vertex attribute array
*/
struct VertexData{
GLuint location;
const GLvoid* data;
GLenum type;
};
/*
* Attributes that was initialized inside fragment shader
* On draw method program will iterate by all it values and bind it
*/
std::vector<VertexData> _variables;
/*
* How much triangles should be drawn
*/
int _meshLenght;
/*
* Elements buffer object
* Used for indexed draw
*/
GLuint _ebo;
/*
* Shader associated with current model
*/
Shader* shaderProgram;
public:
/*
* Default constructor without indices
* Shader used inside AddDataPointer
*/
Mesh(Shader &shader, int size);
/*
* Indices constructor
*/
Mesh(Shader &shader, int size, GLuint* indices);
/*
* Add data to the _variables vector, that will be used on draw method
*/
void AddDataPointer(GLchar* name, const GLvoid* data, GLenum type, GLint size);
/*
* Draw method
*/
void Draw();
};
#endif //FUTUREENGINE_MODEL_H
#ifndef FUTUREENGINE_MODEL_H
#define FUTUREENGINE_MODEL_H
#include <vector>
#include "Texture.h"
#include "Mesh.h"
class Model {
public:
/*
* Default constructor
* If mesh should be created "by hands"
*/
Model(std::vector<Mesh*> meshes, std::vector<Texture*> textures);
//Model(std::string pathToModel);
/*
* Default draw function
* Call draw function for each mesh inside _meshes
*/
void Draw();
protected:
std::vector<Mesh*> _meshes;
std::vector<Texture*> _textures;
};
#endif //FUTUREENGINE_MODEL_H
П.С.: Понимаю, что проблема возможно довольно типичная, но все же я не смог ее решить.
П.С.С.: Вот ошибка
In file included from /Users/airat/ClionProjects/FutureEngine/Model/Model.cpp:5:
/Users/airat/ClionProjects/FutureEngine/Model/Model.h:19:23: error: use of undeclared identifier 'Mesh'
Model(std::vector meshes, std::vector textures);