Closed bvssvni closed 10 years ago
If I want to write Context::opengl()
then there will be an 'opengl' method for every generic instance of that struct.
One idea is to write traits in the back-end library as new methods on top of the graphics library. This makes it possible for the back-end to choose different ways of reading out the geometry.
A back-end could provide different methods which the graphics library recognizes. The back-end could tell with some flags which format is preferred under which circumstances. For example, whether to use triangle strips or triangle lists, whether to use indices or to use colors per vertex.
One could have a context for each transform, color, rectangle etc.
There could be a type for each combination of the base context. How would this work mathematically?
Using a design where Rust-Graphics makes assumptions about performance and checks the back-end for supported features in performance order. Some features, such as alpha blending, can be ignored.
One way is to have context wrap a generic type T: