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.