Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
BIAS::TemplateSpecializedBatch Class Reference

This file contains the header for a class template. More...

#include <OpenGLFramework/SpecializedBatches/TemplateSpecializedBatch.hh>

+ Collaboration diagram for BIAS::TemplateSpecializedBatch:

Public Types

enum  ProcessingScheme { myProcessingScheme =0, myOtherProcessingScheme }
 

Public Member Functions

void Execute ()
 Configures GL and issues a "rendering" on the GPU. More...
 
 TemplateSpecializedBatch ()
 
Calls when appropriate Context is available.
void Init (TemplateSpecializedBatch::ProcessingScheme ps)
 This method initializes all necessary GL structures. More...
 
Communication with other GPU work steps
void SetRenderTarget (BIAS::glfRenderTarget *rt)
 Method determines where the results are delivered. More...
 
void SetViewport (unsigned int viewportWidth, unsigned int viewportHeight, unsigned int viewportOx=0, unsigned int viewportOy=0)
 Method determines the viewport size, which is used in the render target. More...
 
General I/O

Textures are a pretty way to exchange information between GPU worksteps.

Although some kind of polymorphism is available not all texture object implement the same amount of functionality. I therefore propose to implement the appropriate, specialized interface.

void UploadTextureImage (BIAS::ImageBase &img)
 Some textures will certainly be created internally. More...
 
void Update ()
 It will certainly be necessary to pass non GL specific data to influence the processing. More...
 

Protected Member Functions

void PreExecute_ ()
 Is the first call performed by the Execute method called. More...
 

Protected Attributes

bool callPreExecuteFlag_
 This flag deteremines whether the PreExecute method has to be called or not. More...
 
bool initialized_
 Guard for multiple calls to Init(). More...
 
ProcessingScheme processingScheme_
 This enum is used to tell the class how it shall behave and setup GL states, it is specified using Init(). More...
 

Batch Assembly

BIAS::glfBatch batch_
 This is the core implementation that determines how updates to the GL state are handled. More...
 
void InitBatch_ ()
 Connects all data used in GL processing to the batch. More...
 

Geometry Specification

BIAS::glfVertexBuffer vertices_
 If you want to process something, you will need vertex data! Of course its possible to have it defined and managed outside this class, but here is the general idea. More...
 
BIAS::glfElementBuffer elements_
 Element buffers can be suitable are however not mandatory. More...
 
void InitPrimitiveData_ ()
 Creates the associated GL objects and the content of vertices_ and elements_. More...
 

Textures.

Various textures exist in opengl however we did not implement them all yet.

Whats pretty heavily used is the Texture2D class, which therefore is well implemented... Number of texture matrices and textures, which be handled in a single pass might differ!

BIAS::glfTexture2D textureInTextureUnit0
 
void InitTextureData_ ()
 Creates and initializes the necessary textures. More...
 
void InitTextureMatrixData_ ()
 Creates and initializes the necessary texture matrices. More...
 

Vertex Transformation.

GL contains a default vertex processing chain, which requires the specification of an affine transformation matrix, the ModelView matrix, and a Projection Matrix.

In the end projected vertices are mapped to a viewport.

BIAS::glfMatrix ModelViewMatrix_
 
BIAS::glfMatrix ProjectionMatrix_
 
BIAS::glfViewport viewport_
 
void InitVertexTransformation_ ()
 Create and setup the render matrices and the viewport. More...
 

Shaders.

The GL processing pipeline is made more flexible by the useage of Shaders.

You do not have to use shaders. Yet I guess the shaders are the reason for using the OpenGLFramework in the first place... (remove these lines and their usage should you not need them?!)

BIAS::glfShaderProgram shaderProgram_
 
BIAS::glfShader fragmentShader_
 
void InitShaders_ ()
 Creates and issues initialization of shader execution. More...
 

Per Fragment Operations.

In the Gl process ing pipeline after shader application per pixel operations are performed.

This are depth test, stencil test, blending ... . Still not all tests are wraped in the OpenGLFramework, but when needed they will.

BIAS::glfDepthBufferMode depthTest_
 
void InitPerFragmentOperations_ ()
 Create and setup the per fragment operations. More...
 

Detailed Description

This file contains the header for a class template.

This template shall aid in the usage of the OpenGLFramework, by proposing an implementation scheme to encapsulate OpenGL processings. The whole proposal is based on the Batch concept proposed in the OpenGLFramework. As such the implementation can be emphesised as mantic gathering and maintenance of the necessary stateinformation to execute one or multiple rendering passes.

Author
bartczak 04/2008
Examples:
ExampleTemplateSpecializedBatch.cpp.

Definition at line 49 of file TemplateSpecializedBatch.hh.

Member Enumeration Documentation

Enumerator
myProcessingScheme 
myOtherProcessingScheme 

Definition at line 51 of file TemplateSpecializedBatch.hh.

Constructor & Destructor Documentation

TemplateSpecializedBatch::TemplateSpecializedBatch ( )

Definition at line 32 of file TemplateSpecializedBatch.cpp.

Member Function Documentation

void TemplateSpecializedBatch::Execute ( )

Configures GL and issues a "rendering" on the GPU.

Examples:
ExampleTemplateSpecializedBatch.cpp.

Definition at line 171 of file TemplateSpecializedBatch.cpp.

References batch_, callPreExecuteFlag_, BIAS::glfBatch::Draw(), initialized_, and PreExecute_().

void TemplateSpecializedBatch::Init ( TemplateSpecializedBatch::ProcessingScheme  ps)

This method initializes all necessary GL structures.

Attention
must not be called before appropriate GLContext is available!

Remove unneccesary lines

Examples:
ExampleTemplateSpecializedBatch.cpp.

Definition at line 40 of file TemplateSpecializedBatch.cpp.

References InitBatch_(), initialized_, InitPerFragmentOperations_(), InitPrimitiveData_(), InitShaders_(), InitTextureData_(), InitTextureMatrixData_(), InitVertexTransformation_(), and processingScheme_.

void TemplateSpecializedBatch::InitBatch_ ( )
protected
void TemplateSpecializedBatch::InitPerFragmentOperations_ ( )
protected

Create and setup the per fragment operations.

Connection to batch_ is performed in InitBatch_().

Definition at line 150 of file TemplateSpecializedBatch.cpp.

References depthTest_, and BIAS::glfDepthBufferMode::SetDepthTest().

Referenced by Init().

void TemplateSpecializedBatch::InitPrimitiveData_ ( )
protected

Creates the associated GL objects and the content of vertices_ and elements_.

Connection to batch_ is performed in InitBatch_().

Definition at line 62 of file TemplateSpecializedBatch.cpp.

References elements_, BIAS::Primitives::PlainQuad2DWithTexture2D(), and vertices_.

Referenced by Init().

void TemplateSpecializedBatch::InitShaders_ ( )
protected

Creates and issues initialization of shader execution.

Connection to batch_ is performed in InitBatch_().

Definition at line 101 of file TemplateSpecializedBatch.cpp.

References BIAS::glfShaderProgram::AttachShader(), BIAS::glfShaderProgram::Create(), BIAS::glfShader::Create(), fragmentShader_, BIAS::glfShaderProgram::Link(), BIAS::glfShaderProgram::SetUniform(), and shaderProgram_.

Referenced by Init().

void TemplateSpecializedBatch::InitTextureData_ ( )
protected

Creates and initializes the necessary textures.

Connection to batch_ is performed in InitBatch_().

Definition at line 69 of file TemplateSpecializedBatch.cpp.

References BIAS::glfTexture::Create(), BIAS::glfTexture2D::Set(), and textureInTextureUnit0.

Referenced by Init().

void TemplateSpecializedBatch::InitTextureMatrixData_ ( )
protected

Creates and initializes the necessary texture matrices.

Connection to batch_ is performed in InitBatch_().

Definition at line 76 of file TemplateSpecializedBatch.cpp.

Referenced by Init().

void TemplateSpecializedBatch::InitVertexTransformation_ ( )
protected

Create and setup the render matrices and the viewport.

Connection to batch_ is performed in InitBatch_(). The viewport is not changed here! It is changed by SetViewport method.

Definition at line 82 of file TemplateSpecializedBatch.cpp.

References BIAS::glfMatrix::MakeIdentity(), ModelViewMatrix_, and ProjectionMatrix_.

Referenced by Init().

void TemplateSpecializedBatch::PreExecute_ ( )
protected

Is the first call performed by the Execute method called.

This method can be used to update shader parameters etc.

Definition at line 184 of file TemplateSpecializedBatch.cpp.

Referenced by Execute().

void TemplateSpecializedBatch::SetRenderTarget ( BIAS::glfRenderTarget rt)

Method determines where the results are delivered.

The default is the Screen, which is the same to passing NULL.

Examples:
ExampleTemplateSpecializedBatch.cpp.

Definition at line 144 of file TemplateSpecializedBatch.cpp.

References batch_, and BIAS::glfBatch::SetRenderTarget().

void TemplateSpecializedBatch::SetViewport ( unsigned int  viewportWidth,
unsigned int  viewportHeight,
unsigned int  viewportOx = 0,
unsigned int  viewportOy = 0 
)

Method determines the viewport size, which is used in the render target.

Examples:
ExampleTemplateSpecializedBatch.cpp.

Definition at line 134 of file TemplateSpecializedBatch.cpp.

References BIAS::glfViewport::SetOrigin(), BIAS::glfViewport::SetSize(), and viewport_.

void TemplateSpecializedBatch::Update ( )

It will certainly be necessary to pass non GL specific data to influence the processing.

If changes are made that make a reinitilaization necessary you should work with flags that are evaluated before drawing and are processed when all state changes have been gathered. Use the Update() and the PreExecute_() methods for that.Method evaluates set parameters and adapts the GL state.

Definition at line 192 of file TemplateSpecializedBatch.cpp.

void TemplateSpecializedBatch::UploadTextureImage ( BIAS::ImageBase img)

Some textures will certainly be created internally.

The UploadTextureContent routines, take care to fill them with content. Currently not all texture targets are fully implemented, therefore I also propose to implement the appropriate interface.

Examples:
ExampleTemplateSpecializedBatch.cpp.

Definition at line 199 of file TemplateSpecializedBatch.cpp.

References textureInTextureUnit0, and BIAS::glfTexture2D::UploadImage().

Member Data Documentation

BIAS::glfBatch BIAS::TemplateSpecializedBatch::batch_
protected

This is the core implementation that determines how updates to the GL state are handled.

In this all GL state updates are gathered and the update stratgy is implemented here.

Definition at line 156 of file TemplateSpecializedBatch.hh.

Referenced by Execute(), InitBatch_(), and SetRenderTarget().

bool BIAS::TemplateSpecializedBatch::callPreExecuteFlag_
protected

This flag deteremines whether the PreExecute method has to be called or not.

Definition at line 139 of file TemplateSpecializedBatch.hh.

Referenced by Execute().

BIAS::glfDepthBufferMode BIAS::TemplateSpecializedBatch::depthTest_
protected

Definition at line 270 of file TemplateSpecializedBatch.hh.

Referenced by InitBatch_(), and InitPerFragmentOperations_().

BIAS::glfElementBuffer BIAS::TemplateSpecializedBatch::elements_
protected

Element buffers can be suitable are however not mandatory.

Definition at line 175 of file TemplateSpecializedBatch.hh.

Referenced by InitBatch_(), and InitPrimitiveData_().

BIAS::glfShader BIAS::TemplateSpecializedBatch::fragmentShader_
protected

Definition at line 252 of file TemplateSpecializedBatch.hh.

Referenced by InitShaders_().

bool BIAS::TemplateSpecializedBatch::initialized_
protected

Guard for multiple calls to Init().

This way one can prohibit conflicts with already setup shader programms, which would start throwing exceptions.

Definition at line 136 of file TemplateSpecializedBatch.hh.

Referenced by Execute(), and Init().

BIAS::glfMatrix BIAS::TemplateSpecializedBatch::ModelViewMatrix_
protected

Definition at line 225 of file TemplateSpecializedBatch.hh.

Referenced by InitBatch_(), and InitVertexTransformation_().

ProcessingScheme BIAS::TemplateSpecializedBatch::processingScheme_
protected

This enum is used to tell the class how it shall behave and setup GL states, it is specified using Init().

Definition at line 56 of file TemplateSpecializedBatch.hh.

Referenced by Init().

BIAS::glfMatrix BIAS::TemplateSpecializedBatch::ProjectionMatrix_
protected

Definition at line 226 of file TemplateSpecializedBatch.hh.

Referenced by InitBatch_(), and InitVertexTransformation_().

BIAS::glfShaderProgram BIAS::TemplateSpecializedBatch::shaderProgram_
protected

Definition at line 249 of file TemplateSpecializedBatch.hh.

Referenced by InitBatch_(), and InitShaders_().

BIAS::glfTexture2D BIAS::TemplateSpecializedBatch::textureInTextureUnit0
protected

Definition at line 193 of file TemplateSpecializedBatch.hh.

Referenced by InitBatch_(), InitTextureData_(), and UploadTextureImage().

BIAS::glfVertexBuffer BIAS::TemplateSpecializedBatch::vertices_
protected

If you want to process something, you will need vertex data! Of course its possible to have it defined and managed outside this class, but here is the general idea.

Definition at line 172 of file TemplateSpecializedBatch.hh.

Referenced by InitBatch_(), and InitPrimitiveData_().

BIAS::glfViewport BIAS::TemplateSpecializedBatch::viewport_
protected

Definition at line 235 of file TemplateSpecializedBatch.hh.

Referenced by InitBatch_(), and SetViewport().


The documentation for this class was generated from the following files: