1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-26 04:12:41 +01:00

Add method to retrieve current draw settings from Renderer

This commit is contained in:
Daniel Evans 2015-03-29 23:18:27 +01:00
parent 980ef71e96
commit 78253c59ce
4 changed files with 14 additions and 1 deletions

View File

@ -106,12 +106,15 @@ public:
* Returns the number of draw calls issued for the current frame.
*/
int getDrawCount();
const SceneUniformData& getSceneData() const;
private:
glm::ivec2 viewport;
glm::mat4 projection2D;
protected:
int drawCounter;
SceneUniformData lastSceneData;
};
class OpenGLRenderer : public Renderer

View File

@ -21,6 +21,8 @@ layout(std140) uniform SceneData {
float fogEnd;
};
uniform mat4 inverseVP;
uniform float time;
uniform vec2 waveParams;
uniform sampler2D data;
@ -46,7 +48,7 @@ void main()
TexCoords = position * vec2(0.5,0.5) + vec2(0.5);
mat4 vp = projection * view;
mat4 projector = inverse(vp);
mat4 projector = inverseVP;
mat3 rot = mat3(view);
vec3 ray = vec3(-position.x, -position.y, projection[0][0] ) * rot;

View File

@ -97,6 +97,11 @@ int Renderer::getDrawCount()
return drawCounter;
}
const Renderer::SceneUniformData& Renderer::getSceneData() const
{
return lastSceneData;
}
void OpenGLRenderer::useDrawBuffer(DrawBuffer* dbuff)
{
if( dbuff != currentDbuff )
@ -217,6 +222,7 @@ void OpenGLRenderer::clear(const glm::vec4& colour, bool clearColour, bool clear
void OpenGLRenderer::setSceneParameters(const Renderer::SceneUniformData& data)
{
uploadUBO(UBOScene, data);
lastSceneData = data;
}
void OpenGLRenderer::draw(const glm::mat4& model, DrawBuffer* draw, const Renderer::DrawParameters& p)

View File

@ -142,6 +142,8 @@ void WaterRenderer::render(GameRenderer* renderer, GameWorld* world)
r->setUniform(waterProg, "time", world->gameTime);
r->setUniform(waterProg, "waveParams", glm::vec2(WATER_SCALE, WATER_HEIGHT));
auto ivp = glm::inverse(r->getSceneData().projection * r->getSceneData().view);
r->setUniform(waterProg, "inverseVP", ivp);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, dataTexture);