#include <stdexcept>
+#include <msp/gl/extensions/msp_legacy_features.h>
+#include "error.h"
#include "light.h"
#include "lighting.h"
#include "lightunit.h"
void Lighting::attach(unsigned i, const Light &l)
{
- if(i>=LightUnit::get_n_units())
- throw out_of_range("Lighting::attach");
-
if(i>=lights.size())
lights.resize(i+1);
{
shdata.uniform("ambient_color", ambient);
shdata.uniform("sky_color", sky_color);
- shdata.uniform("eye_sky_dir", Vector3(view_matrix*Vector4(sky_direction, 0.0f)));
+ shdata.uniform("eye_sky_dir", view_matrix.block<3, 3>(0, 0)*sky_direction);
shdata.uniform("horizon_limit", horizon_angle.radians());
for(unsigned i=0; i<lights.size(); ++i)
void Lighting::bind() const
{
+ static Require _req(MSP_legacy_features);
+ if(lights.size()>LightUnit::get_n_units())
+ throw invalid_operation("Lighting::bind");
+
if(!set_current(this))
return;