]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/opengl/pipelinestate_backend.cpp
Adjust access to main class members from backend classes
[libs/gl.git] / source / backends / opengl / pipelinestate_backend.cpp
index 91789701705d31441a55864f80a4e337d84cfdae..7cd654008d524f38c4d75c495959e54419a9faa0 100644 (file)
@@ -56,11 +56,11 @@ void OpenGLPipelineState::apply() const
 
 void OpenGLPipelineState::apply(unsigned mask) const
 {
-       const PipelineState *self = static_cast<const PipelineState *>(this);
+       const PipelineState &self = *static_cast<const PipelineState *>(this);
 
        if(mask&PipelineState::FRAMEBUFFER)
        {
-               const Framebuffer *framebuffer = self->framebuffer;
+               const Framebuffer *framebuffer = self.framebuffer;
                glBindFramebuffer(GL_FRAMEBUFFER, framebuffer ? framebuffer->id : 0);
                if(framebuffer)
                {
@@ -71,15 +71,15 @@ void OpenGLPipelineState::apply(unsigned mask) const
 
        if(mask&(PipelineState::VIEWPORT|PipelineState::FRAMEBUFFER))
        {
-               if(const Rect *viewport = self->viewport)
+               if(const Rect *viewport = self.viewport)
                        glViewport(viewport->left, viewport->bottom, viewport->width, viewport->height);
-               else if(const Framebuffer *framebuffer = self->framebuffer)
+               else if(const Framebuffer *framebuffer = self.framebuffer)
                        glViewport(0, 0, framebuffer->get_width(), framebuffer->get_height());
        }
 
        if(mask&PipelineState::SCISSOR)
        {
-               if(const Rect *scissor = self->scissor)
+               if(const Rect *scissor = self.scissor)
                {
                        glEnable(GL_SCISSOR_TEST);
                        glScissor(scissor->left, scissor->bottom, scissor->width, scissor->height);
@@ -90,9 +90,9 @@ void OpenGLPipelineState::apply(unsigned mask) const
 
        if(mask&PipelineState::SHPROG)
        {
-               glUseProgram(self->shprog ? self->shprog->id : 0);
+               glUseProgram(self.shprog ? self.shprog->id : 0);
 
-               unsigned ncd = (self->shprog ? self->shprog->get_n_clip_distances() : 0);
+               unsigned ncd = (self.shprog ? self.shprog->get_n_clip_distances() : 0);
                if(ncd!=n_clip_distances)
                {
                        for(unsigned i=0; (i<ncd || i<n_clip_distances); ++i)
@@ -108,7 +108,7 @@ void OpenGLPipelineState::apply(unsigned mask) const
 
        if(mask&PipelineState::UNIFORMS)
        {
-               for(const PipelineState::BoundUniformBlock &u: self->uniform_blocks)
+               for(const PipelineState::BoundUniformBlock &u: self.uniform_blocks)
                        if(u.changed || mask==~0U)
                        {
                                if(u.block)
@@ -118,10 +118,10 @@ void OpenGLPipelineState::apply(unsigned mask) const
                                                glBindBufferRange(GL_UNIFORM_BUFFER, u.binding, u.block->get_buffer()->id, u.block->get_offset(), u.block->get_data_size());
                                                bound_uniform_blocks[u.binding] = 1;
                                        }
-                                       else if(self->shprog)
+                                       else if(self.shprog)
                                        {
                                                const char *data = static_cast<const char *>(u.block->get_data_pointer());
-                                               for(const Program::UniformCall &call: self->shprog->uniform_calls)
+                                               for(const Program::UniformCall &call: self.shprog->uniform_calls)
                                                        call.func(call.location, call.size, data+call.location*16);
                                        }
                                }
@@ -132,7 +132,7 @@ void OpenGLPipelineState::apply(unsigned mask) const
 
        if(mask&PipelineState::TEXTURES)
        {
-               for(const PipelineState::BoundTexture &t: self->textures)
+               for(const PipelineState::BoundTexture &t: self.textures)
                        if(t.changed || mask==~0U)
                        {
                                if(t.texture && t.sampler)
@@ -159,7 +159,7 @@ void OpenGLPipelineState::apply(unsigned mask) const
 
        if(mask&PipelineState::VERTEX_SETUP)
        {
-               const VertexSetup *vertex_setup = self->vertex_setup;
+               const VertexSetup *vertex_setup = self.vertex_setup;
                glBindVertexArray(vertex_setup ? vertex_setup->id : 0);
                if(vertex_setup)
                {
@@ -179,12 +179,12 @@ void OpenGLPipelineState::apply(unsigned mask) const
 
        if(mask&PipelineState::FACE_CULL)
        {
-               glFrontFace(self->front_face==CLOCKWISE ? GL_CW : GL_CCW);
+               glFrontFace(self.front_face==CLOCKWISE ? GL_CW : GL_CCW);
 
-               if(self->face_cull!=NO_CULL && self->front_face!=NON_MANIFOLD)
+               if(self.face_cull!=NO_CULL && self.front_face!=NON_MANIFOLD)
                {
                        glEnable(GL_CULL_FACE);
-                       glCullFace(self->face_cull==CULL_FRONT ? GL_FRONT : GL_BACK);
+                       glCullFace(self.face_cull==CULL_FRONT ? GL_FRONT : GL_BACK);
                }
                else
                        glDisable(GL_CULL_FACE);
@@ -192,7 +192,7 @@ void OpenGLPipelineState::apply(unsigned mask) const
 
        if(mask&PipelineState::DEPTH_TEST)
        {
-               const DepthTest *depth_test = self->depth_test;
+               const DepthTest *depth_test = self.depth_test;
                if(depth_test && depth_test->enabled)
                {
                        glEnable(GL_DEPTH_TEST);
@@ -206,7 +206,7 @@ void OpenGLPipelineState::apply(unsigned mask) const
 
        if(mask&PipelineState::STENCIL_TEST)
        {
-               const StencilTest *stencil_test = self->stencil_test;
+               const StencilTest *stencil_test = self.stencil_test;
                if(stencil_test && stencil_test->enabled)
                {
                        glEnable(GL_STENCIL_TEST);
@@ -219,7 +219,7 @@ void OpenGLPipelineState::apply(unsigned mask) const
 
        if(mask&PipelineState::BLEND)
        {
-               const Blend *blend = self->blend;
+               const Blend *blend = self.blend;
                if(blend && blend->enabled)
                {
                        glEnable(GL_BLEND);
@@ -237,7 +237,7 @@ void OpenGLPipelineState::apply(unsigned mask) const
        }
 
        last_applied = this;
-       self->changes &= ~mask;
+       self.changes &= ~mask;
 }
 
 void OpenGLPipelineState::clear()