mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-12-03 00:15:46 +00:00
8472718fb7
This untangles some of the gigantic kitchen sink headers in an attempt to split things into smaller files. Also don't include gl.h, glext.h, windows.h, and other such nonsense *everywhere*. Lots of cleanups on the way too. More dead/unused code removal. Remove incrFlag(), decrFlag() Lua functions.
93 lines
2.3 KiB
C++
93 lines
2.3 KiB
C++
/*
|
|
Copyright (C) 2007, 2010 - Bit-Blot
|
|
|
|
This file is part of Aquaria.
|
|
|
|
Aquaria is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License
|
|
as published by the Free Software Foundation; either version 2
|
|
of the License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*/
|
|
#include "Segmented.h"
|
|
#include "RenderBase.h"
|
|
|
|
Strand::Strand(const Vector &position, int segs, int dist) : RenderObject(), Segmented(dist, dist)
|
|
{
|
|
cull = false;
|
|
segments.resize(segs);
|
|
for (int i = 0; i < segments.size(); i++)
|
|
{
|
|
segments[i] = new RenderObject;
|
|
}
|
|
initSegments(position);
|
|
}
|
|
|
|
void Strand::destroy()
|
|
{
|
|
RenderObject::destroy();
|
|
for (int i = 0; i < segments.size(); i++)
|
|
{
|
|
segments[i]->destroy();
|
|
delete segments[i];
|
|
}
|
|
segments.clear();
|
|
}
|
|
|
|
void Strand::onUpdate(float dt)
|
|
{
|
|
RenderObject::onUpdate(dt);
|
|
updateSegments(position);
|
|
}
|
|
|
|
void Strand::onRender()
|
|
{
|
|
const int numSegments = segments.size();
|
|
if (numSegments == 0) return;
|
|
|
|
glEnable(GL_BLEND);
|
|
glTranslatef(-position.x, -position.y, 0);
|
|
glLineWidth(1);
|
|
|
|
glBegin(GL_LINE_STRIP);
|
|
|
|
|
|
unsigned int r = (unsigned int)(color.x * (255<<8));
|
|
unsigned int g = (unsigned int)(color.y * (255<<8));
|
|
unsigned int b = (unsigned int)(color.z * (255<<8));
|
|
unsigned int a = (255<<8);
|
|
unsigned int dr = r/50;
|
|
unsigned int dg = g/50;
|
|
unsigned int db = b/50;
|
|
unsigned int da = a/numSegments;
|
|
glColor4ub(r>>8, g>>8, b>>8, a>>8);
|
|
glVertex2f(position.x, position.y);
|
|
glVertex2f(segments[0]->position.x, segments[0]->position.y);
|
|
const int colorLimit = numSegments<50 ? numSegments : 50;
|
|
int i;
|
|
for (i = 1; i < colorLimit; i++)
|
|
{
|
|
r -= dr;
|
|
g -= dg;
|
|
b -= db;
|
|
a -= da;
|
|
glColor4ub(r>>8, g>>8, b>>8, a>>8);
|
|
glVertex2f(segments[i]->position.x, segments[i]->position.y);
|
|
}
|
|
for (; i < numSegments; i++)
|
|
{
|
|
a -= da;
|
|
glColor4ub(0, 0, 0, a>>8);
|
|
glVertex2f(segments[i]->position.x, segments[i]->position.y);
|
|
}
|
|
glEnd();
|
|
}
|