Stellarium 0.12.4
List of all members | Public Member Functions | Protected Member Functions
StelQGL2Renderer Class Reference

Renderer backend using OpenGL 2.1 or GLSL 2.0 with Qt. More...

#include <StelQGL2Renderer.hpp>

Public Member Functions

 StelQGL2Renderer (QGraphicsView *parent, bool pvrSupported)
 Construct a StelQGL2Renderer. More...
 
virtual bool init ()
 Initialize the renderer. More...
 
virtual bool areFloatTexturesSupported () const
 Returns true if floating point textures are supported, false otherwise. More...
 
virtual bool areNonPowerOfTwoTexturesSupported () const
 Returns true if non-power-of-two textures are supported, false otherwise. More...
 
virtual StelGLSLShadercreateGLSLShader ()
 Create a GLSL shader. More...
 
virtual bool isGLSLSupported () const
 Are GLSL shaders supported? More...
 
StelQGLGLSLShadergetShader (const StelVertexAttribute *const attributes, const int attributeCount)
 Get shader corresponding to specified vertex format. More...
 
void bindCustomShader (StelQGLGLSLShader *shader)
 Use a custom shader program, overriding builtin shader programs. More...
 
void releaseCustomShader (StelQGLGLSLShader *shader)
 Release a custom shader program, allowing use of builtin shader programs. More...
 
- Public Member Functions inherited from StelQGLRenderer
 StelQGLRenderer (QGraphicsView *const parent, const bool pvrSupported)
 Construct a StelQGLRenderer. More...
 
virtual QImage screenshot ()
 Take a screenshot and return it. More...
 
virtual void renderFrame (StelRenderClient &renderClient)
 Render a frame. More...
 
virtual void viewportHasBeenResized (const QSize size)
 Must be called once at startup and on every GL viewport resize, specifying new size. More...
 
virtual QSize getViewportSize () const
 Get size of the viewport in pixels. More...
 
StelIndexBuffercreateIndexBuffer (const IndexType type)
 Create an empty index buffer and return a pointer to it. More...
 
virtual void drawText (const TextParams &params)
 Draw text with specified parameters. More...
 
virtual void setFont (const QFont &font)
 Set font to use for drawing text. More...
 
virtual void bindTextureBackend (StelTextureBackend *const textureBackend, const int textureUnit)
 Bind a texture (following draw calls will use this texture on specified texture unit). More...
 
void ensureTextureNotBound (StelTextureBackend *const textureBackend)
 Must be called by texture backend destructor to ensure we don't keep any pointers to it. More...
 
virtual void destroyTextureBackend (StelTextureBackend *const textureBackend)
 Destroy a StelTextureBackend. More...
 
virtual void setGlobalColor (const Vec4f &color)
 Set the global vertex color. More...
 
virtual void setCulledFaces (const CullFace cullFace)
 Set which faces (triangles) should be culled. More...
 
virtual void setBlendMode (const BlendMode mode)
 Set blend mode. More...
 
virtual void setDepthTest (const DepthTest test)
 Set depth test mode. More...
 
virtual void clearDepthBuffer ()
 Clear the depth buffer to zeroes, removing any depth information. More...
 
virtual void setStencilTest (const StencilTest test)
 Set stencil test mode. More...
 
virtual void clearStencilBuffer ()
 Clear the stencil buffer to zeroes, removing any stencil information. More...
 
virtual void swapBuffers ()
 Swap front and back buffers. More...
 
virtual void drawRect (const float x, const float y, const float width, const float height, const float angle=0.0f)
 Draw a rectangle to the screen. More...
 
virtual void drawTexturedRect (const float x, const float y, const float width, const float height, const float angle=0.0f)
 Draw a textured rectangle to the screen. More...
 
virtual StelRendererStatisticsgetStatistics ()
 Access statistics data. More...
 
virtual void makeGLContextCurrent ()
 Make Stellarium GL context the currently used GL context. Call this before GL calls. More...
 
QGLContext * getGLContext ()
 Used to access the GL context. More...
 
QGLFunctions & getGLFunctions ()
 Used for GL/GLES-compatible function wrappers and to determine which GL features are available. More...
 
QThread * getLoaderThread ()
 Get a pointer to the thread used for loading graphics data (e.g. textures). More...
 
const Vec4fgetGlobalColor () const
 Get global vertex color (used for drawing). More...
 
QPaintEngine::Type qtPaintEngineType () const
 Get the paint engine type used for Qt drawing. More...
 
- Public Member Functions inherited from StelRenderer
virtual ~StelRenderer ()
 Destructor. More...
 
template<class V >
StelVertexBuffer< V > * createVertexBuffer (const PrimitiveType primitiveType)
 Create an empty vertex buffer and return a pointer to it. More...
 
template<class V >
void drawVertexBuffer (StelVertexBuffer< V > *vertexBuffer, class StelIndexBuffer *indexBuffer=NULL, StelProjectorP projector=StelProjectorP(NULL), bool dontProject=false)
 Draw contents of a vertex buffer. More...
 
template<class V >
void drawVertexBuffer (StelVertexBuffer< V > *vertexBuffer, class StelIndexBuffer *indexBuffer, StelProjector *projector, bool dontProject=false)
 Draw contents of a vertex buffer. More...
 
virtual void drawLine (const float startX, const float startY, const float endX, const float endY)
 Draw a line with current global color to the screen. More...
 
StelTextureNewcreateTexture (const QString &filename, const TextureParams &params=TextureParams(), const TextureLoadingMode loadingMode=TextureLoadingMode_Normal)
 Create a texture from specified file or URL. More...
 
StelTextureNewcreateTexture (QImage &image, const TextureParams &params=TextureParams())
 Create a texture from an image. More...
 
StelTextureNewcreateTexture (const void *const data, const QSize size, const TextureDataFormat format, const TextureParams &params=TextureParams())
 Create a texture from raw data. More...
 
StelTextureNewgetViewportTexture ()
 Get a texture of the viewport, with everything drawn to the viewport so far. More...
 
void setGlobalColor (const float r, const float g, const float b, const float a=1.0f)
 setGlobalColor overload specifying color channels directly instead of through Vec4f. More...
 

Protected Member Functions

virtual StelVertexBufferBackendcreateVertexBufferBackend (const PrimitiveType primitiveType, const QVector< StelVertexAttribute > &attributes)
 Create a vertex buffer backend. More...
 
virtual void drawVertexBufferBackend (StelVertexBufferBackend *vertexBuffer, StelIndexBuffer *indexBuffer=NULL, StelProjector *projector=NULL, bool dontProject=false)
 Draw contents of a vertex buffer (backend). More...
 
virtual int getTextureUnitCountBackend ()
 Return the number of texture units (implementation). More...
 
virtual void invariant () const
 Asserts that we're in a valid state. More...
 
- Protected Member Functions inherited from StelQGLRenderer
virtual StelTextureBackendcreateTextureBackend (const QString &filename, const TextureParams &params, const TextureLoadingMode loadingMode)
 Implementation of createTexture. More...
 
virtual StelTextureBackendcreateTextureBackend (QImage &image, const TextureParams &params)
 Implementation of createTexture loading from image. More...
 
virtual StelTextureBackendcreateTextureBackend (const void *data, const QSize size, const TextureDataFormat format, const TextureParams &params)
 Implementation of createTexture loading from raw data. More...
 
virtual StelTextureBackendgetViewportTextureBackend ()
 Implementation of getViewportTexture. More...
 
void setupGLState (StelProjector *projector)
 Set up GL state common between the GL1 and GL2 backends before drawing. More...
 
void restoreGLState (StelProjector *projector)
 Reset GL state after drawing. More...
 
template<class VBufferBackend >
void updateDrawStatistics (VBufferBackend *vertexBuffer, StelQGLIndexBuffer *indexBuffer)
 Update statistics in a drawVertexBufferBackend() call. More...
 

Additional Inherited Members

- Protected Attributes inherited from StelQGLRenderer
QString glVendorString
 OpenGL vendor string (used to enable/disable features based on driver). More...
 
QString glRendererString
 OpenGL renderer (usually GPU) string (can be used to enable/disable features based on GPU). More...
 
StelRendererStatistics statistics
 Statistics collected during program run (such as estimated texture memory usage, etc.). More...
 
QGLFunctions gl
 Wraps some GL functions for compatibility across GL and GLES. More...
 

Detailed Description

Renderer backend using OpenGL 2.1 or GLSL 2.0 with Qt.

Note
This is an internal class of the Renderer subsystem and should not be used elsewhere.

Definition at line 40 of file StelQGL2Renderer.hpp.

Constructor & Destructor Documentation

StelQGL2Renderer::StelQGL2Renderer ( QGraphicsView *  parent,
bool  pvrSupported 
)
inline

Construct a StelQGL2Renderer.

Parameters
parentParent widget for the renderer's GL widget.
pvrSupportedAre .pvr (PVRTC - PowerVR hardware) textures supported on this platform? This should be true for mobile platforms with PowerVR GPUs.

Definition at line 48 of file StelQGL2Renderer.hpp.

Member Function Documentation

virtual bool StelQGL2Renderer::areFloatTexturesSupported ( ) const
inlinevirtual

Returns true if floating point textures are supported, false otherwise.

Implements StelRenderer.

Definition at line 287 of file StelQGL2Renderer.hpp.

virtual bool StelQGL2Renderer::areNonPowerOfTwoTexturesSupported ( ) const
inlinevirtual

Returns true if non-power-of-two textures are supported, false otherwise.

Implements StelQGLRenderer.

Definition at line 293 of file StelQGL2Renderer.hpp.

void StelQGL2Renderer::bindCustomShader ( StelQGLGLSLShader shader)
inline

Use a custom shader program, overriding builtin shader programs.

This can only be called when no custom shader is bound already (any previously bound custom shader must be released).

Used by StelQGLGLSLShader.

Parameters
shaderShader to use.

Definition at line 367 of file StelQGL2Renderer.hpp.

virtual StelGLSLShader* StelQGL2Renderer::createGLSLShader ( )
inlinevirtual

Create a GLSL shader.

This can only be called if isGLSLSupported() is true.

The constructed shader must be deleted before the StelRenderer is destroyed.

Reimplemented from StelRenderer.

Definition at line 295 of file StelQGL2Renderer.hpp.

virtual StelVertexBufferBackend* StelQGL2Renderer::createVertexBufferBackend ( const PrimitiveType  primitiveType,
const QVector< StelVertexAttribute > &  attributes 
)
inlineprotectedvirtual

Create a vertex buffer backend.

Used by createVertexBuffer.

This allows each Renderer backend to create its own vertex buffer backend.

Parameters
primitiveTypeGraphics primitive type stored in the buffer.
attributesDescriptions of all attributes of the vertex type stored in the buffer.
Returns
Pointer to a vertex buffer backend specific to the Renderer backend.

Implements StelRenderer.

Definition at line 395 of file StelQGL2Renderer.hpp.

virtual void StelQGL2Renderer::drawVertexBufferBackend ( StelVertexBufferBackend vertexBuffer,
StelIndexBuffer indexBuffer = NULL,
StelProjector projector = NULL,
bool  dontProject = false 
)
inlineprotectedvirtual

Draw contents of a vertex buffer (backend).

Used by drawVertexBuffer.

See Also
drawVertexBuffer

Implements StelRenderer.

Definition at line 402 of file StelQGL2Renderer.hpp.

StelQGLGLSLShader* StelQGL2Renderer::getShader ( const StelVertexAttribute *const  attributes,
const int  attributeCount 
)
inline

Get shader corresponding to specified vertex format.

If the user binds a custom shader (StelGLSLShader, in this case StelQGLGLSLShader), this shader is returned instead. (I.e. custom shader programs override builtin ones.)

Parameters
attributesVertex attributes used in the vertex format.
attributeCountNumber of vertex attributes.
Returns
Pointer to the shader.

Definition at line 310 of file StelQGL2Renderer.hpp.

virtual int StelQGL2Renderer::getTextureUnitCountBackend ( )
inlineprotectedvirtual

Return the number of texture units (implementation).

Implements StelQGLRenderer.

Definition at line 517 of file StelQGL2Renderer.hpp.

virtual bool StelQGL2Renderer::init ( )
inlinevirtual

Initialize the renderer.

Must be called before any other methods.

Returns
true on success, false if there was an error.

Reimplemented from StelQGLRenderer.

Definition at line 70 of file StelQGL2Renderer.hpp.

virtual void StelQGL2Renderer::invariant ( ) const
inlineprotectedvirtual

Asserts that we're in a valid state.

Overriding methods should also call StelQGLRenderer::invariant().

Reimplemented from StelQGLRenderer.

Definition at line 527 of file StelQGL2Renderer.hpp.

virtual bool StelQGL2Renderer::isGLSLSupported ( ) const
inlinevirtual

Are GLSL shaders supported?

Implements StelRenderer.

Definition at line 300 of file StelQGL2Renderer.hpp.

void StelQGL2Renderer::releaseCustomShader ( StelQGLGLSLShader shader)
inline

Release a custom shader program, allowing use of builtin shader programs.

The released shader must match the currently bound one.

Used by StelQGLGLSLShader.

Parameters
shaderShader assumed to be bound, for error checking.

Definition at line 382 of file StelQGL2Renderer.hpp.


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