Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 264 vs 265 for /trunk/Source Code/Hardware/Video/OpenGL/GLStates.cpp

Diff revisions: vs.
  @@ -64,39 +64,20 @@
64 64
65 65 ///Update OpenGL light state
66 66 void GL_API::setLight(Light* const light, bool shadowPass){
67 - static mat4<F32> tempViewMatrix;
68 67 assert(light != nullptr);
69 68 if (shadowPass){
70 - const LightShadowProperties& crtShadow = light->getShadowProperties();
71 - const GLsizei sizeOfBlock = sizeof(LightShadowProperties);
72 - _uniformBufferObjects[Shadow_UBO]->ChangeSubData(light->getSlot() * sizeOfBlock, sizeOfBlock, (const GLvoid*)(&crtShadow));
73 - return;
74 - }
75 -
76 - LightProperties crtLight = light->getProperties();
77 -
78 - F32 lightType = crtLight._position.w;
79 -
80 - getMatrix(VIEW_MATRIX, tempViewMatrix);
81 -
82 - if (light->getType() == LIGHT_TYPE_DIRECTIONAL){
83 - crtLight._position.normalize();
84 - crtLight._position.set(tempViewMatrix * vec4<F32>(crtLight._position.xyz(), 0.0f));
85 - }else if (light->getType() == LIGHT_TYPE_SPOT){
86 - F32 spotExponent = crtLight._direction.w;
87 - crtLight._direction.w = 0.0f;
88 - crtLight._direction.set(tempViewMatrix * crtLight._direction);
89 - crtLight._direction.normalize();
90 - crtLight._direction.w = spotExponent;
69 + _uniformBufferObjects[Shadow_UBO]->ChangeSubData(light->getSlot() * sizeof(LightShadowProperties), sizeof(LightShadowProperties), (GLvoid*)&light->getShadowProperties());
91 70 }else{
92 - crtLight._position.set(tempViewMatrix * vec4<F32>(crtLight._position.xyz(), 1.0f));
71 + LightProperties temp = light->getProperties();
72 + mat4<F32> viewMat;
73 + getMatrix(VIEW_MATRIX, viewMat);
74 + if (light->getLightType() == LIGHT_TYPE_DIRECTIONAL){
75 + temp._position.set(vec3<F32>(viewMat * temp._position), temp._position.w);
76 + }else if (light->getLightType() == LIGHT_TYPE_SPOT){
77 + temp._direction.set(vec3<F32>(viewMat * temp._direction), temp._direction.w);
78 + }
79 + _uniformBufferObjects[Lights_UBO]->ChangeSubData(light->getSlot() * sizeof(LightProperties), sizeof(LightProperties), (GLvoid*)&temp);
93 80 }
94 - crtLight._position.w = lightType;
95 -
96 - const GLsizei sizeOfBlock = sizeof(LightProperties);
97 - _uniformBufferObjects[Lights_UBO]->ChangeSubData(light->getSlot() * (sizeOfBlock), // offset
98 - sizeOfBlock, // size
99 - (const GLvoid*)(&crtLight)); // data
100 81 }
101 82
102 83 void GL_API::updateProjectionMatrix(){
  @@ -319,9 +300,9 @@
319 300
320 301 #ifndef SHOULD_TOGGLE
321 302 #define SHOULD_TOGGLE(state) (!oldBlock || oldBlock->getDescriptor().state != newDescriptor.state)
322 - #define SHOULD_TOGGLE_2(state1, state2) SHOULD_TOGGLE(state1) || SHOULD_TOGGLE(state2)
323 - #define SHOULD_TOGGLE_3(state1, state2, state3) SHOULD_TOGGLE_2(state1, state2) || SHOULD_TOGGLE(state3)
324 - #define SHOULD_TOGGLE_4(state1, state2, state3, state4) SHOULD_TOGGLE_3(state1, state2, state3) || SHOULD_TOGGLE(state4)
303 + #define SHOULD_TOGGLE_2(state1, state2) (!oldBlock ||SHOULD_TOGGLE(state1) || SHOULD_TOGGLE(state2))
304 + #define SHOULD_TOGGLE_3(state1, state2, state3) (!oldBlock ||SHOULD_TOGGLE_2(state1, state2) || SHOULD_TOGGLE(state3))
305 + #define SHOULD_TOGGLE_4(state1, state2, state3, state4) (!oldBlock || SHOULD_TOGGLE_3(state1, state2, state3) || SHOULD_TOGGLE(state4))
325 306 #define TOGGLE_NO_CHECK(state, enumValue) newDescriptor.state ? glEnable(enumValue) : glDisable(enumValue)
326 307 #define TOGGLE_WITH_CHECK(state, enumValue) if(SHOULD_TOGGLE(state)) TOGGLE_NO_CHECK(state, enumValue);
327 308 #endif