Hi,
I wanted to implement a function "PUSHSTATE" that allows you to push/pop the state variables you can set with GLBasic.
I found the ones below. Did I miss something? Do you think the current directory (or any other variable) should not be bothered?
vpx, vpy, vpw, vph // viewport size (GETVIEWPORT)
smoothshading
usescreen
currentdir
font
orientation
So do these state variables replace their function calls?
All sprite commands ?
no replace. Just...
PUSHSTATE
CallFunctionThatChangesViewportOrAnything()
POPSTATE
ContinueYourWork()
Is it actually needed though ?
yes. Like x_pushmartix. Its mainly for external libraries or so...
I like the idea!
Great for creating generic libraries.
How about 'ALPHAMODE' too?
Ocean, you could use a custom type for doing that, such as: (untested!)
TYPE TPushVariable
name$
value#
ENDTYPE
TYPE TPushStack
stack[] AS TPushVariable
FUNCTION Clear:
DIM self.stack[0]
ENDFUNCTION
FUNCTION Push: name$, value#
LOCAL pushVar AS TPushVariable
pushVar.name$ = name$
pushVar.value = value
DIMPUSH self.stack[], pushVar
ENDFUNCTION
FUNCTION Pop#: name$
LOCAL ix%
LOCAL value#
FOR ix = 0 TO LEN(self.stack[])-1
IF self.stack[ix].name$ = name$
value = self.stack[ix].value
DIMDEL self.stack[], ix
RETURN value
ENDIF
ENDIF
RETURN 0 // Not found
ENDFUNCTION
ENDTYPE
GLOBAL pushStack AS TPushStack
Usage:
pushStack.Clear()
pushStack.Push("ORIENTATION", GETORIENTATION())
pushStack.Push("TIME", GETTIMERALL())
pushStack.Push("ORIENTATION", GETORIENTATION())
time = pushStack.Pop("TIME")
orientation = pushStack.Pop("ORIENTATION")
orientation = pushStack.Pop("ORIENTATION")
But it's limited to integers and floats. Could use all strings and convert it to and from I suppose.
I would LOVE function overloading for times like this!
Quote from: Kitty Hello on 2011-Nov-17Did I miss something? Do you think the current directory (or any other variable) should not be bothered?
settransparency
setfont
IMHO current directory must to be managed by the library, if is needed.