我已经在.hpp文件中定义了一个粒子类Particle
#ifndef PARTICLE_HPP
#define PARTICLE_HPP
#include <glm/glm.hpp>
#include <GL/glew.h>
#include <GL/gl.h>
#include <vector>
struct Particle
{
Particle()
: m_Position(0.0f)
, m_Velocity(0.0f)
, m_Color(1.0f)
, m_fRotate(0.0f)
, m_fAge(0.0f)
, m_fLifeSpan(0.0f)
, m_is_alive(false)
{}
public:
glm::vec3 m_Position; // Center point of particle
glm::vec3 m_Velocity; // Current particle velocity
glm::vec4 m_Color; // Particle color
GLfloat m_fRotate; // Rotate the particle the center
GLfloat m_fSize; // Size of the particle
GLfloat m_fAge;
GLfloat m_fLifeSpan;
bool m_is_alive;
};
Run Code Online (Sandbox Code Playgroud)
在另一个.cpp文件中,我在typedef命名空间中声明了Particle.我想要做的是实例化粒子结构并将它们推入向量中.因为我有一个空的构造函数,我相信只使用Particle()进行实例化应该可行.但是,我不能这样做,因为编译认为粗体线中存在"不完全类型不允许"错误. particles.push_back(颗粒());
#include "Particle.hpp"
#include <stdlib.h> //malloc …
Run Code Online (Sandbox Code Playgroud)