caramia-0.7.2.2: High-level OpenGL bindings

Safe HaskellNone
LanguageHaskell2010

Graphics.Caramia.Query

Contents

Description

Queries.

Queries have some distinct use cases; you can use them to determine if some object is occluded or you can measure how long GPU takes to execute some commands.

https://www.opengl.org/wiki/Query_Object

Most features in this module require either OpenGL 3.3 or an extension.

Synopsis

Main query operations

withNumericQuery :: (MonadIO m, MonadMask m) => NumericQueryType -> m a -> m (Query Int64, a) Source

Creates a query, runs some actions in it and then returns an Query value.

There can be only one active query for each query type. An user error will be thrown if this is violated.

AnySamplesPassed cannot be used at the same time as SamplesPassed.

You can query the returned Query for results. However, because using the GPU is typically asynchronous, results may not be (and often are not) immediately available. Use tryGetResults to check if results have become available.

withNumericQuery' :: (MonadIO m, MonadMask m) => NumericQueryType -> m a -> m (Query Int64) Source

Same as withNumericQuery but throws away the result of the action itself.

withBooleanQuery :: (MonadIO m, MonadMask m) => BooleanQueryType -> m a -> m (Query Bool, a) Source

Same as withNumericQuery, but uses boolean queries, whose results is either True or False.

withBooleanQuery' :: (MonadIO m, MonadMask m) => BooleanQueryType -> m a -> m (Query Bool) Source

Same as withBooleanQuery but throws away the result of the action itself.

Creating queries manually

newNumericQuery :: MonadIO m => NumericQueryType -> m (Query Int64) Source

Creates a new query object, that returns a numeric type.

Use beginQuery and endQuery to decide which part of GPU commands you want the query to be about.

You may want to use withNumericQuery instead, which begins and ends the query for you.

newBooleanQuery :: MonadIO m => BooleanQueryType -> m (Query Bool) Source

Same as newNumericQuery but for boolean queries.

beginQuery :: MonadIO m => Query a -> m () Source

Begins a query. A query can only be started once.

endQuery :: MonadIO m => Query a -> m () Source

Ends a query.

Retrieving query results

getResults :: (MonadIO m, QueryResultType a) => Query a -> m a Source

Returnts query results, blocks if it has to wait for results.

Note: cannot be interrupted by asynchronous exceptions if it decides to wait.

tryGetResults :: (MonadIO m, QueryResultType a) => Query a -> m (Maybe a) Source

Returns results if they are available or Nothing.

Query types

data BooleanQueryType Source

What of query to make? These queries return boolean results.

Constructors

AnySamplesPassed

If GL_ARB_occlusion_query2 or OpenGL 3.3 is not available, this is implemented with SamplesPassed behind the scenes.

Types

data Query a Source

A query object. The type variable tells the type of the return values from the query.

class QueryResultType a Source

Minimal complete definition

fromInt64