Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I basically want to have a shader run that can do something like toon shading, or grayscale the whole screen, or radial lighting.

To do this, I create a new bitmap each time the display resizes that is the size of the screen. I then use this as my drawing buffer.

I realized this creates quite a performance hit. Especially on my laptop. Is there a way to do something like this without such a performance hit?

The framework I'm using is Allegro5. This is my current implementation:

void GraphicsContext::flipDisplay()
{
    if(!m_backBuffer)
    {
        al_flip_display();
    }
    else
    {   

        setTargetToBackbuffer();
        if(m_shader)
        {
            m_shader->use();
            m_shader->setSampler(m_backBuffer,"tex");
        }
        drawSprite(m_backBuffer,0,0,0);
        if(m_shader)
        {
            m_shader->stop();
        }

        al_flip_display();
        clear();
        setTargetToBuffer();

    }

}

This way all drawing gets drawn to my bitmap, then that bitmap is blitted to the backbuffer.

I tried using single buffering display but it did not help.

Any advice for fullscreen effects? I have a game I play on my laptop that uses fullscreen film grain and it does not lag. I wonder what they do.

I know that the default shader I set gets ran through every bitmap, but I do not think I can do lighting effects this way since I cannot know which pixel on the screen I'm on.

share|improve this question
    
Why not draw directly to screen or to a frame buffer? Drawing to a bitmap is causing the slowdown. –  Roy T. Aug 19 '12 at 16:08
    
I cannot draw directly to screen because for the effect to work I need the final image to go through the shader. I'm using a library called Allegro5 and I'm not sure how to create / use a frame buffer. –  Milo Aug 19 '12 at 16:33
    
If I read this correctly it looks like Allegro5 can use FBO's wiki.allegro.cc/index.php?title=Hardware_Portability but I've never used Allegro5 so I wouldn't know where to start looking. Someone else will know. I've edited your question to include this info (someone might need to approve the edit before people can see it) –  Roy T. Aug 19 '12 at 17:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.