display state management

BlitzMax Forums/BlitzMax Beginners Area/display state management

RktMan(Posted 2005) [#1]
hi all,

new guy here.

i've done very little game development.

this is likely a far too general kind of question, but i will ask anyway.

i'm currently developing some framework for the display of a game i'm working on.

this framework is all 2D code so far.

i do some image drawing.
i do some line drawing.
i do some masking of images/textures to get "shaped" textures "dynamically"
i use viewports.
i rely on the use of "Origin" heavily to get things to draw from "offsets"

as i am writing this code, and as it gets more complex, i'm getting more wary of how i am managing the "state" of the display, so that i can link functions together to get the display results i want.

how do people normally manage things like "origin", colors, global image handle states, masks etc.

i'm starting to find that many of my functions are storing/restoring color/origin minimally because otherwise, i might have problems with other functions in my render pipeline starting off from an unknown state.

i don't know if i'm making sense ...

it just seems like there are a number of ways to skin the cat so to speak when building a number of routines in your code that are reusable during "draw()" phases of your application, but where colors and origins and masks and things of that nature might very well be different given what is happening at render time.

it is almost like it would be nice if Blitz had some sort of "push/pop" mechanism for a bunch of the important display attributes.

so as a developer, whenever i use a routine that changes things, i could "push" the display config, change a bunch of stuff, and then "pop" and return.

also, can anyone comment on whether redundant/ineffecient calls to routines like "setcolor" or "setorigin" ... or any of the set/get display state calls have any signigicant overhead in them ?

if i am being really anal about doing my own "push"/"pop" code around all of my routines, even if i don't need to ... is this going to become a performance problem for me ?

thanks for any advice ...
Tony


FlameDuck(Posted 2005) [#2]
i'm starting to find that many of my functions are storing/restoring color/origin minimally because otherwise, i might have problems with other functions in my render pipeline starting off from an unknown state.
I've come across this problem to. the solution I'm currently going with is assuming an unknown state and enforcing a known state at entry and not doing any cleaning up afterwards. Since I rely heavilly on inheritance to provide rendering functions (ie. everything that needs to be drawn must extend an Abstract "sprite" class). It doesn't often give any problems.

Besides if I remember correctly BlitzMAX checks for redundant state changes before actually changing anything.

is this going to become a performance problem for me ?
Probably not - in either case I wouldn't worry about it until you're done, then if you have performance issues, optimize reactively.