Mercurial > fife-parpg
diff engine/core/view/camera.cpp @ 661:e3140f01749d
* Merged the light branch back into trunk.
* Modified the demos so they work with the new loaders and setting.
author | helios2000@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 05 Nov 2010 15:21:10 +0000 |
parents | 07b1cf8e92b5 |
children | e8a799239384 |
line wrap: on
line diff
--- a/engine/core/view/camera.cpp Wed Nov 03 13:44:12 2010 +0000 +++ b/engine/core/view/camera.cpp Fri Nov 05 15:21:10 2010 +0000 @@ -105,7 +105,9 @@ m_renderbackend(renderbackend), m_ipool(ipool), m_apool(apool), - m_layer_to_instances() { + m_layer_to_instances(), + m_lighting(false), + m_light_colors() { m_viewport = viewport; m_map_observer = new MapObserver(this); @@ -630,6 +632,29 @@ m_layer_to_instances.erase(layer); } + void Camera::setLightingColor(float red, float green, float blue, float alpha) { + m_lighting = true; + m_light_colors.clear(); + m_light_colors.push_back(red); + m_light_colors.push_back(green); + m_light_colors.push_back(blue); + m_light_colors.push_back(alpha); + } + + std::vector<float> Camera::getLightingColor() { + if(m_light_colors.empty()) { + for(int colors = 0; colors != 4; ++colors) { + m_light_colors.push_back(1.0f); + } + } + return m_light_colors; + } + + void Camera::resetLightingColor() { + m_lighting = false; + m_renderbackend->resetLighting(); + } + void Camera::render() { Transform transform = NormalTransform; if(m_iswarped) @@ -645,13 +670,22 @@ // return; //} + if (m_renderbackend->getLightingModel() != 0) { + m_renderbackend->resetStencilBuffer(0); + if (m_lighting) { + m_renderbackend->setLighting(m_light_colors[0], m_light_colors[1], m_light_colors[2], m_light_colors[3]); + } + } + if(m_backendSDL) { m_renderbackend->pushClipArea(getViewPort()); } else { m_renderbackend->pushClipArea(getViewPort(), testRenderedViewPort()); } + // update each layer // m_layer_to_instances.clear(); + const std::list<Layer*>& layers = map->getLayers(); std::list<Layer*>::const_iterator layer_it = layers.begin(); for (;layer_it != layers.end(); ++layer_it) { @@ -671,6 +705,11 @@ } } } + + if (m_lighting) { + m_renderbackend->resetLighting(); + } + m_renderbackend->popClipArea(); resetUpdates(); m_updated = true;