|
Graphics.GPipe.Stream.Primitive |
|
|
|
|
Description |
PrimitiveStreams implement the Functor class, which provides the
fmap method that you can use to manipulate those streams. This corresponds to writing and using
vertex shaders, but in a much more modular way. You may for instance apply fmap
several times in a sequence, effectively creating complex shaders.
Instances are also provided for the Monoid class, so several streams (of the same type) can be
concatenated. The order is preserved, meaning that the primitives in stream a in a mappend b will be
drawn before the primitives in b.
All atomic values except textures in vertex streams uses the Vertex type constructor.
Composite types are created by composing the atomic Vertex types, rather than wrapping the
composite type in the Vertex type constructors.
Vertex instances for are provided for most of Prelude's numerical classes. Since Eq, Ord
and Show are prerequisites for these classes, instances are provided for them too, even though
their methods all will generate errors if used (except min and max). Use the instances of
EqB, OrdB and IfB from the Boolean package if you want to compare Vertex values.
Hyperbolic trigonometrical functions aren't provided either.
Rewrite rule specializations are provided for the Vec package functions norm, normalize,
dot and cross on vectors of Vertex Float, so the use of these functions (and others
from that package that is defined in terms of them) are highly encouraged.
|
|
Synopsis |
|
|
|
|
Data types
|
|
data PrimitiveStream p a | Source |
|
A stream of primitives built by vertices on the GPU. The first parameter is the primitive type (currently Triangle, Line or Point) and the second the
the type of each primitives' vertices' type (built up of atoms of type Vertex).
| Instances | |
|
|
|
An opaque type constructor for atomic values in a vertex on the GPU, e.g. Vertex Float.
| Instances | |
|
|
Creating primitive streams
|
|
|
The context of types that can be converted into vertices in PrimitiveStreams.
Create your own instances in terms of the existing ones, e.g. convert your vertex data to Floats,
turn them into Vertex Floats with toVertex and then convert them to your vertex data representation.
| | Methods | | Turns an ordinary value into a vertex value in the InputAssembler monad. This should not be strict on its argument.
Its definition should also always use the same series of toVertex calls to convert values of the same type. This unfortunatly
rules out ordinary lists (but instances for fixed length lists from the Vec package are however provided).
|
| | Instances | |
|
|
|
A monad in which CPU data gets converted to vertex data.
Use toVertex in the existing instances of VertexInput to operate in this monad.
| Instances | |
|
|
|
Constructors | TriangleStrip | | TriangleList | | TriangleFan | |
| Instances | |
|
|
|
Constructors | | Instances | |
|
|
|
Constructors | | Instances | |
|
|
|
| Instances | |
|
|
|
:: (VertexInput a, Primitive p) | | => p | The primitive type.
| -> [CPU a] | A list of vertices, with the layout specified by the primitive type.
| -> PrimitiveStream p a | The resulting PrimitiveStream.
| Converts a list of values to a PrimitiveStream, using a specified Primitive type.
This function is lazy in the aspect that if parts of the values aren't used on the GPU, they won't
get evaluated and transferred there either.
|
|
|
|
:: (VertexInput a, Primitive p) | | => p | The primitive type.
| -> [CPU a] | A list of vertices.
| -> [Int] | A list of indexes into the vertex list, with the layout specified by the primitive type.
| -> PrimitiveStream p a | The resulting PrimitiveStream.
| Converts a list of values to a PrimitiveStream, using a specified Primitive type and an index list.
This will use index buffer objects on the GPU, and is recommended if several primitives share vertices.
This function is lazy in the aspect that if parts of the values aren't used on the GPU, they won't
get evaluated and transferred there either.
|
|
|
Produced by Haddock version 2.4.2 |