Port particles renderer to use shaders (without VBO yet)
parent
b0ec6d6fc2
commit
702531879c
|
@ -7060,35 +7060,29 @@ void Renderer::labelConstellations(const AsterismList& asterisms,
|
||||||
|
|
||||||
|
|
||||||
void Renderer::renderParticles(const vector<Particle>& particles,
|
void Renderer::renderParticles(const vector<Particle>& particles,
|
||||||
const Quaternionf& orientation)
|
const Quaternionf& /*orientation*/)
|
||||||
{
|
{
|
||||||
int nParticles = particles.size();
|
ShaderProperties shaderprop;
|
||||||
|
shaderprop.lightModel = ShaderProperties::ParticleModel;
|
||||||
|
shaderprop.texUsage = ShaderProperties::PointSprite;
|
||||||
|
auto *prog = shaderManager->getShader(shaderprop);
|
||||||
|
if (prog == nullptr)
|
||||||
|
return;
|
||||||
|
prog->use();
|
||||||
|
|
||||||
{
|
glEnable(GL_POINT_SPRITE);
|
||||||
Matrix3f m = orientation.conjugate().toRotationMatrix();
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
Vector3f v0 = m * Vector3f(-1, -1, 0);
|
glVertexPointer(3, GL_FLOAT, sizeof(Particle), &particles[0].center);
|
||||||
Vector3f v1 = m * Vector3f( 1, -1, 0);
|
glEnableVertexAttribArray(CelestiaGLProgram::PointSizeAttributeIndex);
|
||||||
Vector3f v2 = m * Vector3f( 1, 1, 0);
|
glVertexAttribPointer(CelestiaGLProgram::PointSizeAttributeIndex,
|
||||||
Vector3f v3 = m * Vector3f(-1, 1, 0);
|
1, GL_FLOAT, GL_FALSE,
|
||||||
|
sizeof(Particle), &particles[0].size);
|
||||||
|
glDrawArrays(GL_POINTS, 0, particles.size());
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
for (int i = 0; i < nParticles; i++)
|
glDisableVertexAttribArray(CelestiaGLProgram::PointSizeAttributeIndex);
|
||||||
{
|
glUseProgram(0);
|
||||||
Vector3f center = particles[i].center;
|
glDisable(GL_POINT_SPRITE);
|
||||||
float size = particles[i].size;
|
|
||||||
|
|
||||||
glColor(particles[i].color);
|
|
||||||
glTexCoord2f(0, 1);
|
|
||||||
glVertex(center + (v0 * size));
|
|
||||||
glTexCoord2f(1, 1);
|
|
||||||
glVertex(center + (v1 * size));
|
|
||||||
glTexCoord2f(1, 0);
|
|
||||||
glVertex(center + (v2 * size));
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex(center + (v3 * size));
|
|
||||||
}
|
|
||||||
glEnd();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::renderAnnotations(const vector<Annotation>& annotations, FontStyle fs)
|
void Renderer::renderAnnotations(const vector<Annotation>& annotations, FontStyle fs)
|
||||||
|
|
Loading…
Reference in New Issue