[SDL] spam filtering

Sam Lantinga slouken at devolution.com
Fri Sep 22 04:43:56 PDT 2006

I realized there is another problem as well: Just like glSDL, SDL 1.3 
(at least the OpenGL renderer) relies on some parts of the API state 
to remain unchanged between calls. This means an application or 
add-on library cannot safely change anything, nor can it rely on the 
state to be unaffected by SDL rendering calls.

For example, in GL_RenderCopy():
    if (blendMode != data->blendMode) {
        switch (blendMode) {
        data->blendMode = blendMode;
...and a similar construct for scaleMode.

A simple solution would be some kind of mutual notification interface, 
so that SDL renderers can tell the application when they've messed 
with the API state, and vice versa.

To make it more effective, one might use a bit mask instead of just a 
single "something changed" flag. One bit for view setup, one for 
blending, one for scaling etc. Without this, both SDL and 
applications/add-on libs will have to do a full state restore 
whenever the other side says it touched "something". The bit mask can 
still be tested like a single boolean if desired, of course.

Also, there doesn't seem to be a way to update any dirty areas of a 
texture without performing a dummy blit. A specific call to do only 
that part (now hardwired into *_RenderCopy() implementations) would 
be handy.

Another way of dealing with these kind of issues would be to make the 
SDL renderer interface public, so that applications and add-on libs 
can plug entire renderers into SDL. That way, one could wire *all* 
rendering, including the SDL calls, to the same renderer, instead of 
trying to get two separate renderers to cooperate. Of course, this 
means quite a bit of code duplication, but it's probably safer...

//David Olofson - Programmer, Composer, Open Source Advocate

.-------  http://olofson.net - Games, SDL examples  -------.
|        http://zeespace.net - 2.5D rendering engine       |
|       http://audiality.org - Music/audio engine          |
|     http://eel.olofson.net - Real time scripting         |
'--  http://www.reologica.se - Rheology instrumentation  --'

More information about the SDL mailing list