Page 1 of 1

Drop shadow effect when rendering to SDL with OpenGL

Posted: 30 Jul 2024, 15:34
by seanmet
Hello,
I'm running into an issue with the drop shadow effect (this is what ive noticed, there might be other effects or other features) when i render my application to SDL.
 <TextBlock Text="{Binding Path=Value, RelativeSource={RelativeSource AncestorType={x:Type Slider}}}"
                Foreground="White" FontSize="33.74" FontWeight="Bold" FontFamily="../../microscope_adjustment_screen/assets/#Mont-Regular"
                VerticalAlignment="Center" HorizontalAlignment="Left" Margin="-60,0,0,0">
                	<TextBlock.Effect>
                       		<DropShadowEffect Color="#48348F" BlurRadius="4" ShadowDepth="0"/>
                        </TextBlock.Effect>
</TextBlock>
This line of code works fine when I use the launcher, but for some reason when i render myself to SDL window, i get a black screen.
Noesis error handler wont raise any errors, thats why i suspect something else, and i couldnt find an answer in the "IntegrationGLUT" guide.

I registered all components with "RegisterAppComponents", could you think of a reason for this to happen?
Thanks in advance :)

Re: Drop shadow effect when rendering to SDL with OpenGL

Posted: 30 Jul 2024, 15:38
by jsantos
Could you use RenderDoc to compare your integration vs our implementation? That should give you all the details.

This is probably happening because your are not injecting the offscreen phase at the right time.

Re: Drop shadow effect when rendering to SDL with OpenGL

Posted: 31 Jul 2024, 10:33
by seanmet
Doesn't look like the problem is with injecting the offscreen render.
This is the flow of the code:
   void cNoesisScreenManager::renderActiveScreenToFbo(GLuint fbo) {
        glBindFramebuffer(GL_FRAMEBUFFER, fbo); // Bind the framebuffer
        glViewport(0, 0, width, height); // Set the viewport to the FBO dimensions
        glClear(GL_COLOR_BUFFER_BIT); // Clear the FBO

        const auto active_view = getCurrentScreen()->screen_view;
        auto *renderer = active_view->GetRenderer(); // Get the renderer
        renderer->UpdateRenderTree(); // Applies last changes happened in view
        renderer->RenderOffscreen(); // Generates offscreen textures
        renderer->Render(); // Render UI in the active render target and viewport dimensions
        glBindFramebuffer(GL_FRAMEBUFFER, 0); // Unbind the framebuffer
    }
Also, to make sure, i tried adding "glFinish();" right after the Render line to make sure everything finishes rendering, but still i got a black screen..
Do you have any other suggestions?
Thanks :)

Re: Drop shadow effect when rendering to SDL with OpenGL

Posted: 31 Jul 2024, 15:34
by jsantos
As suggested before, have you tried analyzing the differences with RenderDoc to understand what's going on?

Re: Drop shadow effect when rendering to SDL with OpenGL

Posted: 31 Jul 2024, 18:45
by jsantos
After reviewing your code, it seems that the offscreen phase is not being rendered correctly. You need to call RenderOffscreen() before binding the main framebuffer. Additionally, when binding the main buffer, you're only clearing the color bits. Make sure to clear the stencil buffer as well.

These details are thoroughly explained in the Rendering Tutorial that was mentioned earlier.