glEnable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
glEnable(GL_COLOR_MATERIAL);
- glColor4f(1.0, 1.0, 1.0, 1.0);
+ // glColor4f(1.0, 1.0, 1.0, 1.0);
+ if ( cur_light_params.sun_angle * RAD_TO_DEG < 95.0 ) {
+ glColor4fv( cur_light_params.scene_diffuse );
+ } else {
+ glColor4f(0.7, 0.2, 0.2, 1.0);
+ }
glBindTexture(GL_TEXTURE_2D, _bg->getHandle());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
FGPanel::doMouseAction (int button, int updown, int x, int y)
{
// Note a released button and return
+ // cerr << "Doing mouse action\n";
if (updown == 1) {
_mouseDown = false;
_mouseInstrument = 0;
int iw = inst->getWidth() / 2;
int ih = inst->getHeight() / 2;
if (x >= ix - iw && x < ix + iw && y >= iy - ih && y < iy + ih) {
- cout << "Do mouse action for component " << i << '\n';
+// cout << "Do mouse action for component " << i << '\n';
_mouseDown = true;
_mouseDelay = 20;
_mouseInstrument = inst;
return true;
}
}
- cout << "Did not click on an instrument\n";
+// cout << "Did not click on an instrument\n";
return false;
}
////////////////////////////////////////////////////////////////////////
FGAdjustAction::FGAdjustAction (getter_type getter, setter_type setter,
- double increment, double min, double max,
+ float increment, float min, float max,
bool wrap=false)
: _getter(getter), _setter(setter), _increment(increment),
_min(min), _max(max), _wrap(wrap)
void
FGAdjustAction::doAction ()
{
- double value = (*_getter)();
- cout << "Do action; value=" << value << '\n';
+ float value = (*_getter)();
+// cout << "Do action; value=" << value << '\n';
value += _increment;
if (value < _min) {
value = (_wrap ? _max : _min);
} else if (value > _max) {
value = (_wrap ? _min : _max);
}
- cout << "New value is " << value << '\n';
+// cout << "New value is " << value << '\n';
(*_setter)(value);
}
void
FGSwapAction::doAction ()
{
- double value = (*_getter1)();
+ float value = (*_getter1)();
(*_setter1)((*_getter2)());
(*_setter2)(value);
}
{
action_list_type::iterator it = _actions.begin();
action_list_type::iterator last = _actions.end();
- cout << "Mouse action at " << x << ',' << y << '\n';
+// cout << "Mouse action at " << x << ',' << y << '\n';
for ( ; it != last; it++) {
- cout << "Trying action at " << it->x << ',' << it->y << ','
- << it->w <<',' << it->h << '\n';
+// cout << "Trying action at " << it->x << ',' << it->y << ','
+// << it->w <<',' << it->h << '\n';
if (button == it->button &&
x >= it->x && x < it->x + it->w && y >= it->y && y < it->y + it->h) {
it->action->doAction();
FGLayeredInstrument::addLayer (FGInstrumentLayer *layer)
{
int n = _layers.size();
+ if (layer->getWidth() == -1) {
+ layer->setWidth(getWidth());
+ }
+ if (layer->getHeight() == -1) {
+ layer->setHeight(getHeight());
+ }
_layers.push_back(layer);
return n;
}
int
-FGLayeredInstrument::addLayer (ssgTexture * texture)
+FGLayeredInstrument::addLayer (CroppedTexture &texture,
+ int w = -1, int h = -1)
{
- return addLayer(new FGTexturedLayer(texture, _w, _h));
+ return addLayer(new FGTexturedLayer(texture, w, h));
}
void
FGLayeredInstrument::addTransformation (FGInstrumentLayer::transform_type type,
FGInstrumentLayer::transform_func func,
- double min, double max,
- double factor, double offset)
+ float min, float max,
+ float factor, float offset)
{
int layer = _layers.size() - 1;
_layers[layer]->addTransformation(type, func, min, max, factor, offset);
void
FGLayeredInstrument::addTransformation (FGInstrumentLayer::transform_type type,
- double offset)
+ float offset)
{
addTransformation(type, 0, 0.0, 0.0, 1.0, offset);
}
transformation_list::const_iterator last = _transformations.end();
while (it != last) {
transformation *t = *it;
- double value = (t->func == 0 ? 0.0 : (*(t->func))());
+ float value = (t->func == 0 ? 0.0 : (*(t->func))());
if (value < t->min) {
value = t->min;
} else if (value > t->max) {
void
FGInstrumentLayer::addTransformation (transform_type type,
transform_func func,
- double min, double max,
- double factor, double offset)
+ float min, float max,
+ float factor, float offset)
{
transformation *t = new transformation;
t->type = type;
// Implementation of FGTexturedLayer.
////////////////////////////////////////////////////////////////////////
-FGTexturedLayer::FGTexturedLayer (ssgTexture * texture, int w, int h,
- double texX1 = 0.0, double texY1 = 0.0,
- double texX2 = 1.0, double texY2 = 1.0)
+// FGTexturedLayer::FGTexturedLayer (ssgTexture * texture, int w, int h,
+// float texX1 = 0.0, float texY1 = 0.0,
+// float texX2 = 1.0, float texY2 = 1.0)
+// : FGInstrumentLayer(w, h),
+// _texX1(texX1), _texY1(texY1), _texX2(texX2), _texY2(texY2)
+// {
+// setTexture(texture);
+// }
+
+FGTexturedLayer::FGTexturedLayer (CroppedTexture &texture, int w, int h)
: FGInstrumentLayer(w, h),
- _texX1(texX1), _texY1(texY1), _texX2(texX2), _texY2(texY2)
+ _texX1(texture.minX), _texY1(texture.minY),
+ _texX2(texture.maxX), _texY2(texture.maxY)
{
- setTexture(texture);
+ setTexture(texture.texture);
}
FGTexturedLayer::~FGTexturedLayer ()
transform();
glBindTexture(GL_TEXTURE_2D, _texture->getHandle());
glBegin(GL_POLYGON);
-
+ if ( cur_light_params.sun_angle * RAD_TO_DEG < 95.0 ) {
+ glColor4fv( cur_light_params.scene_diffuse );
+ } else {
+ glColor4f(0.7, 0.2, 0.2, 1.0);
+ }
glTexCoord2f(_texX1, _texY1); glVertex2f(-w2, -h2);
glTexCoord2f(_texX2, _texY1); glVertex2f(w2, -h2);
glTexCoord2f(_texX2, _texY2); glVertex2f(w2, h2);
// Implementation of FGTextLayer.
////////////////////////////////////////////////////////////////////////
-FGTextLayer::FGTextLayer (int w, int h)
+FGTextLayer::FGTextLayer (int w, int h, Chunk * chunk1, Chunk * chunk2,
+ Chunk * chunk3)
: FGInstrumentLayer(w, h)
{
_color[0] = _color[1] = _color[2] = 0.0;
_color[3] = 1.0;
+ if (chunk1)
+ addChunk(chunk1);
+ if (chunk2)
+ addChunk(chunk2);
+ if (chunk3)
+ addChunk(chunk3);
}
FGTextLayer::~FGTextLayer ()
}
FGTextLayer::Chunk::Chunk (double_func func, char * fmt = "%.2f",
- double mult = 1.0)
+ float mult = 1.0)
: _type(FGTextLayer::DOUBLE_FUNC), _fmt(fmt), _mult(mult)
{
_value._dfunc = func;