From 94df6a528c8dc77c56795dad0b8b03f6ef1affa5 Mon Sep 17 00:00:00 2001 From: Allanis Date: Sat, 25 Nov 2017 13:14:10 +0000 Subject: [PATCH] [Add] Stars glow right?! --- src/star.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/star.cpp b/src/star.cpp index 53739e1..dd6b3a1 100644 --- a/src/star.cpp +++ b/src/star.cpp @@ -16,6 +16,33 @@ void Star::SetPosition(vector3d p) { pos = p; } +static void DrawCorona(double rad, vector3d& pos, const float col[3]) { + glPushMatrix(); + /* Face the camera damnit! */ + vector3d dir = vector3d::Normalize(pos); + vector3d d2 = vector3d(0, 1, 0); + vector3d d3 = vector3d::Cross(dir, d2); + d3.Normalize(); + d2 = vector3d::Cross(dir, d3); + matrix4x4d rot = matrix4x4d::MakeRotMatrix(d3, d2, dir); + glMultMatrixd(&rot[0]); + + glEnable(GL_BLEND); + glDisable(GL_CULL_FACE); + glBegin(GL_TRIANGLE_FAN); + glColor4f(col[0], col[1], col[2], 1); + glVertex3f(0, 0, 0); + glColor4f(0, 0, 0, 0); + for(float ang = 0; ang < 2*M_PI; ang += 0.2) { + glVertex3f(rad*sin(ang), rad*cos(ang), 0); + } + glVertex3f(0, rad, 0); + glEnd(); + glEnable(GL_CULL_FACE); + glDisable(GL_BLEND); + glPopMatrix(); +} + void Star::Render(const Frame* a_camFrame) { glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); @@ -36,6 +63,7 @@ void Star::Render(const Frame* a_camFrame) { glColor3fv(StarSystem::starColors[type]); gluSphere(L3D::gluQuadric, rad, 100, 100); + DrawCorona(rad*4, fpos, StarSystem::starColors[type]); glPopMatrix(); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING);