NCBI C++ ToolKit
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CRenderCommon Class Reference

Search Toolkit Book for CRenderCommon

#include <gui/opengl/render_common.hpp>

+ Inheritance diagram for CRenderCommon:
+ Collaboration diagram for CRenderCommon:

Public Member Functions

 CRenderCommon ()
 
virtual ~CRenderCommon ()
 
virtual void SetIsGreyscale (bool)
 
virtual bool IsSimplified () const
 
virtual bool IsPrinterFriendly () const
 
virtual void Clear ()
 Clear/delete any graphics/OpenGL memory. More...
 
virtual ERenderTarget GetApi ()
 Overridden in subclasses to return the supported rendering target. More...
 
virtual void Begin (GLenum mode)
 Start rendering. More...
 
virtual void End ()
 Finish rendering (create buffer and send to renderer) More...
 
virtual CRef< CGlStateGetState ()
 Allow caller to access state directly. More...
 
virtual void ResetState ()
 
virtual void BeginClippingRect (GLint x, GLint y, GLsizei width, GLsizei height)
 
virtual void EndClippingRect ()
 
virtual void Render (CGlPane &pane, CGlModel2D *model)
 
Polygon rendering interface
virtual void Vertex3f (GLfloat x, GLfloat y, GLfloat z)
 Explicit support not currently available for: GLbyte, GlShort and GLint calls, e.g. More...
 
virtual void Rectf (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
 Rect() functions also do Begin() and End() (as in OpenGL) More...
 
virtual void ColorC (const CRgbaColor &color)
 Colors (also defined in IGlState since they can be set either before or inside of Begin()/End(). More...
 
virtual void TexCoord2f (GLfloat s, GLfloat t)
 Texture coords. More...
 
Text interface
virtual void BeginText (const CGlTextureFont *font, const CRgbaColor &color)
 Text is drawn is pixel coordinates. More...
 
virtual void BeginText (const CGlTextureFont *font)
 Same as above, but get color from m_RenderNode.m_State. More...
 
virtual void EndText ()
 Pops matrices and attributes after writing text. More...
 
void SetTextColor (const CRgbaColor &color)
 Update text color and alpha. More...
 
CRgbaColor GetTextColor () const
 
virtual void WriteText (TModelUnit x, TModelUnit y, const char *text, TModelUnit rotate_degrees=0.0)
 Write text at specified model coords. More...
 
virtual void WriteText (TModelUnit x, TModelUnit y, TModelUnit width, TModelUnit height, const char *text, CGlTextureFont::TAlign align=CGlTextureFont::eAlign_Center, CGlTextureFont::ETruncate trunc=CGlTextureFont::eTruncate_Ellipsis, TModelUnit rotate_degrees=0.0f)
 Write text at specified model coords inside box defined by (x,y,width,height) with specified alignment, truncation and rotation. More...
 
virtual TModelUnit GetMetric (const CGlTextureFont *font, IGlFont::EMetric metric, const char *text=NULL, int len=-1) const
 Calls the standard font metric functions except for pdf in which case it first replaces any bitmap fonts with texture fnots. More...
 
virtual TModelUnit TextWidth (const CGlTextureFont *font, const char *text) const
 
virtual TModelUnit TextHeight (const CGlTextureFont *font) const
 
virtual TModelUnit GetFontDescender (const CGlTextureFont *font) const
 
virtual TModelUnit GetAdvance (const CGlTextureFont *font, char c) const
 
virtual TModelUnit GetMaxWidth (const CGlTextureFont *font, int max_num) const
 
Viewports, matrices and transformations
virtual void Viewport (GLint x, GLint y, GLsizei width, GLsizei height)
 
virtual void GetViewport (GLint *params)
 
- Public Member Functions inherited from IRender
virtual ~IRender ()
 
virtual void PushAttrib (GLbitfield mask)=0
 
virtual void PopAttrib ()=0
 
virtual void UseProgram (GLuint program)=0
 For shaders. Only works with OpenGL 2.0+. More...
 
virtual void Enable (GLenum glstate)=0
 
virtual void Disable (GLenum glstate)=0
 glDisable() More...
 
virtual void Hint (GLenum target, GLenum mode)=0
 
virtual void LineWidth (GLfloat w)=0
 Set line width for drawing: glLineWidth() More...
 
virtual void PointSize (GLfloat size)=0
 Set point size for drawing: glPointSize() More...
 
virtual void ShadeModel (GLenum mode)=0
 Set shade model for default lighting: glShadeModel(GL_FLAT or GL_SMOOTH) More...
 
virtual void Scissor (GLint x, GLint y, GLsizei width, GLsizei height)=0
 Set clipping window: glScissor(x,y,width,height) More...
 
void Color3f (GLfloat r, GLfloat g, GLfloat b)
 
void Color3fv (const GLfloat *v)
 
void Color4f (GLfloat r, GLfloat g, GLfloat b, GLfloat a)
 
void Color4fv (const GLfloat *v)
 
void Color3d (GLdouble r, GLdouble g, GLdouble b)
 
void Color3dv (const GLdouble *v)
 
void Color4d (GLdouble r, GLdouble g, GLdouble b, GLdouble a)
 
void Color4dv (const GLdouble *v)
 
virtual void ColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)=0
 Set the color mask (glColorMask) More...
 
virtual void PolygonMode (GLenum face, GLenum mode)=0
 Set the polygon rasterization mode. More...
 
virtual void LineStipple (GLint factor, GLushort pattern)=0
 Set line stipple pattern: glLineStipple(). Deprecated in gl 3.2+. More...
 
virtual void PolygonStipple (GLubyte *mask)=0
 Set polygon stipple pattern: glPolygonStipple(). Deprecated in gl 3.2+. More...
 
virtual void BlendFunc (GLenum sfactor, GLenum dfactor)=0
 Options to be used when GL_BLEND is enabled. More...
 
virtual void TexEnvi (GLenum target, GLenum pname, GLint param)=0
 
virtual void LineJoinStyle (IGlState::ELineJoinStyle s)=0
 PDF-specific rendering state. More...
 
virtual void LineCapStyle (IGlState::ELineCapStyle c)=0
 Set line cap ending style (pdf only) More...
 
virtual void PdfShadeStyle (IGlState::EPdfShadeStyle s)=0
 Set (override defualt) shading style for polygons. More...
 
void Vertex2f (GLfloat x, GLfloat y)
 
void Vertex2fv (const GLfloat *v)
 
void Vertex3fv (const GLfloat *v)
 
void Vertex2d (GLdouble x, GLdouble y)
 
void Vertex2dv (const GLdouble *v)
 
void Vertex3d (GLdouble x, GLdouble y, GLdouble z)
 
void Vertex3dv (const GLdouble *v)
 
void Rectd (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)
 
void RectC (const TVPRect &rc)
 
void RectC (const TModelRect &rc)
 
void TexCoord2fv (const GLfloat *v)
 
void TexCoord2d (GLdouble s, GLdouble t)
 
void TexCoord2dv (const GLdouble *v)
 
virtual void MatrixMode (GLenum mode)=0
 
virtual void PushMatrix ()=0
 
virtual void PopMatrix ()=0
 
virtual void LoadIdentity ()=0
 
virtual void LoadMatrixf (const GLfloat *m)=0
 
virtual void LoadMatrixd (const GLdouble *m)=0
 
virtual CMatrix4< float > GetModelViewMatrix () const =0
 
virtual CMatrix4< float > GetProjectionMatrix () const =0
 
virtual void GetModelViewMatrix (GLdouble *m) const =0
 
virtual void GetProjectionMatrix (GLdouble *m) const =0
 
virtual void Rotated (GLdouble angle, GLdouble x, GLdouble y, GLdouble z)=0
 
virtual void Rotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z)=0
 
virtual void Scalef (GLfloat x, GLfloat y, GLfloat z)=0
 
virtual void Translated (GLdouble x, GLdouble y, GLdouble z)=0
 
virtual void Translatef (GLfloat x, GLfloat y, GLfloat z)=0
 
virtual void Ortho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal)=0
 

Protected Member Functions

virtual void x_RenderBuffer (CGlVboNode *node)
 
void x_SyncAttribs (vector< CRgbaColor > &colors)
 
void x_SyncAttribs (vector< CVect3< float > > &vecs)
 
void x_SyncAttribs (vector< CVect2< float > > &vecs)
 

Protected Attributes

vector< CVect3< float > > m_VertexBuffer
 
vector< CRgbaColorm_ColorBuffer
 
vector< CVect2< float > > m_TexCoord2DBuffer1
 
CGlVboNode m_RenderNode
 vertex buffer node for rendering all Begin()/End() renders More...
 
CRef< CGlStatem_State
 state used by all nodes More...
 
GLenum m_MatrixMode
 current modelview matrix and matrix mode More...
 
GLint m_Viewport [4]
 current projection set by Viewport() More...
 
GLenum m_CurrentMode
 rendering mode from Begin() More...
 
const CGlTextureFontm_CurrentFont
 text parameters More...
 
CRgbaColor m_TextColor
 color and alpha for text only (other GL options do not apply to text) More...
 

Detailed Description

Definition at line 44 of file render_common.hpp.

Constructor & Destructor Documentation

◆ CRenderCommon()

CRenderCommon::CRenderCommon ( )

◆ ~CRenderCommon()

virtual CRenderCommon::~CRenderCommon ( )
inlinevirtual

Definition at line 48 of file render_common.hpp.

Member Function Documentation

◆ Begin()

void CRenderCommon::Begin ( GLenum  mode)
virtual

Start rendering.

"mode" may be one of: GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP, GL_TRIANGLES, GL_TRIANGLE_FAN, GL_TRIANGLE_STRIP or GL_QUADS. Start rendering - use state in existing 'state' object.

Implements IRender.

Reimplemented in CGlRenderDebug.

Definition at line 305 of file render_common.cpp.

References Error(), LOG_POST, m_ColorBuffer, m_CurrentMode, m_TexCoord2DBuffer1, and m_VertexBuffer.

Referenced by Rectf().

◆ BeginClippingRect()

virtual void CRenderCommon::BeginClippingRect ( GLint  x,
GLint  y,
GLsizei  width,
GLsizei  height 
)
inlinevirtual

Implements IRender.

Reimplemented in CSVGRenderer.

Definition at line 156 of file render_common.hpp.

◆ BeginText() [1/2]

void CRenderCommon::BeginText ( const CGlTextureFont font)
virtual

Same as above, but get color from m_RenderNode.m_State.

Implements IRender.

Reimplemented in CSVGRenderer, CGlRenderPdf, and CGlRenderDebug.

Definition at line 231 of file render_common.cpp.

References CGlTextureFont::BeginText(), CGlState::GetColor(), m_CurrentFont, m_State, and m_TextColor.

◆ BeginText() [2/2]

void CRenderCommon::BeginText ( const CGlTextureFont font,
const CRgbaColor color 
)
virtual

Text is drawn is pixel coordinates.

Its position is transformed by the current ModelView matrix. The color and alpha for text are set in BeginText() and can be changed with SetTextColor(). Other OpenGL state should not affect text (since BeginText sets appropriate state) Set OpenGL state needed for writing text (call before DrawText)

Implements IRender.

Reimplemented in CSVGRenderer, CGlRenderPdf, and CGlRenderDebug.

Definition at line 223 of file render_common.cpp.

References CGlTextureFont::BeginText(), color, m_CurrentFont, and m_TextColor.

◆ Clear()

void CRenderCommon::Clear ( void  )
virtual

Clear/delete any graphics/OpenGL memory.

Call this if you delete the current OpenGL context

Implements IRender.

Reimplemented in CGlRender.

Definition at line 68 of file render_common.cpp.

References m_CurrentMode, m_MatrixMode, m_RenderNode, and CGlVboNode::SetVBOGeom().

Referenced by CGlRender::Clear().

◆ ColorC()

void CRenderCommon::ColorC ( const CRgbaColor color)
virtual

Colors (also defined in IGlState since they can be set either before or inside of Begin()/End().

Other state must be set before.

Implements IRender.

Definition at line 143 of file render_common.cpp.

References CGlState::ColorC(), Error(), CRgbaColor::GetAlpha(), CRgbaColor::GetBlue(), CRgbaColor::GetGreen(), CRgbaColor::GetRed(), LOG_POST, m_ColorBuffer, m_CurrentMode, m_State, m_VertexBuffer, and x_SyncAttribs().

◆ End()

void CRenderCommon::End ( void  )
virtual

◆ EndClippingRect()

virtual void CRenderCommon::EndClippingRect ( )
inlinevirtual

Implements IRender.

Reimplemented in CSVGRenderer.

Definition at line 157 of file render_common.hpp.

◆ EndText()

void CRenderCommon::EndText ( )
virtual

Pops matrices and attributes after writing text.

Implements IRender.

Reimplemented in CSVGRenderer, CGlRenderPdf, and CGlRenderDebug.

Definition at line 239 of file render_common.cpp.

References CGlTextureFont::EndText(), m_CurrentFont, and NULL.

◆ GetAdvance()

TModelUnit CRenderCommon::GetAdvance ( const CGlTextureFont font,
char  c 
) const
virtual

Reimplemented in CRenderVector.

Definition at line 295 of file render_common.cpp.

References CGlTextureFont::GetAdvance().

◆ GetApi()

virtual ERenderTarget CRenderCommon::GetApi ( )
inlinevirtual

Overridden in subclasses to return the supported rendering target.

Implements IRender.

Reimplemented in CMtlRender, CSVGRenderer, CGlRenderPdf, CGlRenderDebug, CGlRender11, and CGlRender20.

Definition at line 61 of file render_common.hpp.

References eApiUndefined.

◆ GetFontDescender()

TModelUnit CRenderCommon::GetFontDescender ( const CGlTextureFont font) const
virtual

Reimplemented in CRenderVector.

Definition at line 290 of file render_common.cpp.

References CGlTextureFont::GetFontDescender().

◆ GetMaxWidth()

TModelUnit CRenderCommon::GetMaxWidth ( const CGlTextureFont font,
int  max_num 
) const
virtual

Implements IRender.

Reimplemented in CRenderVector.

Definition at line 300 of file render_common.cpp.

References CGlTextureFont::GetMaxWidth().

◆ GetMetric()

TModelUnit CRenderCommon::GetMetric ( const CGlTextureFont font,
IGlFont::EMetric  metric,
const char *  text = NULL,
int  len = -1 
) const
virtual

Calls the standard font metric functions except for pdf in which case it first replaces any bitmap fonts with texture fnots.

Implements IRender.

Reimplemented in CRenderVector.

Definition at line 272 of file render_common.cpp.

References CGlTextureFont::GetMetric(), len, and text().

◆ GetState()

virtual CRef<CGlState> CRenderCommon::GetState ( void  )
inlinevirtual

Allow caller to access state directly.

Implements IRender.

Reimplemented in CMtlRender.

Definition at line 149 of file render_common.hpp.

References m_State.

◆ GetTextColor()

CRgbaColor CRenderCommon::GetTextColor ( ) const
inline

Definition at line 114 of file render_common.hpp.

References m_TextColor.

◆ GetViewport()

void CRenderCommon::GetViewport ( GLint *  params)
virtual

Implements IRender.

Definition at line 389 of file render_common.cpp.

References m_Viewport.

◆ IsPrinterFriendly()

virtual bool CRenderCommon::IsPrinterFriendly ( ) const
inlinevirtual

Implements IRender.

Reimplemented in CSVGRenderer, and CGlRenderPdf.

Definition at line 54 of file render_common.hpp.

◆ IsSimplified()

virtual bool CRenderCommon::IsSimplified ( ) const
inlinevirtual

Implements IRender.

Reimplemented in CSVGRenderer, and CGlRenderPdf.

Definition at line 52 of file render_common.hpp.

◆ Rectf()

void CRenderCommon::Rectf ( GLfloat  x1,
GLfloat  y1,
GLfloat  x2,
GLfloat  y2 
)
virtual

Rect() functions also do Begin() and End() (as in OpenGL)

Implements IRender.

Reimplemented in CGlRenderDebug.

Definition at line 117 of file render_common.cpp.

References Begin(), End(), Error(), CGlState::GetPolygonMode(), LOG_POST, m_CurrentMode, m_State, and Vertex3f().

◆ Render()

void CRenderCommon::Render ( CGlPane pane,
CGlModel2D model 
)
virtual

Implements IRender.

Reimplemented in CGlRenderPdf, and CGlRenderDebug.

Definition at line 447 of file render_common.cpp.

References NULL, and CGlModel2D::Render().

◆ ResetState()

virtual void CRenderCommon::ResetState ( )
inlinevirtual

Implements IRender.

Definition at line 150 of file render_common.hpp.

References m_State, and CGlState::Reset().

Referenced by CPdfGrabber::x_InitRenderer(), and CSVGGrabber::x_InitRenderer().

◆ SetIsGreyscale()

virtual void CRenderCommon::SetIsGreyscale ( bool  )
inlinevirtual

Implements IRender.

Reimplemented in CSVGRenderer, and CGlRenderPdf.

Definition at line 50 of file render_common.hpp.

◆ SetTextColor()

void CRenderCommon::SetTextColor ( const CRgbaColor color)
inline

Update text color and alpha.

Definition at line 113 of file render_common.hpp.

References color, and m_TextColor.

◆ TexCoord2f()

void CRenderCommon::TexCoord2f ( GLfloat  s,
GLfloat  t 
)
virtual

Texture coords.

Implements IRender.

Reimplemented in CGlRenderDebug.

Definition at line 190 of file render_common.cpp.

References Error(), LOG_POST, m_TexCoord2DBuffer1, m_VertexBuffer, t, and x_SyncAttribs().

◆ TextHeight()

TModelUnit CRenderCommon::TextHeight ( const CGlTextureFont font) const
virtual

Implements IRender.

Reimplemented in CRenderVector.

Definition at line 285 of file render_common.cpp.

References CGlTextureFont::TextHeight().

◆ TextWidth()

TModelUnit CRenderCommon::TextWidth ( const CGlTextureFont font,
const char *  text 
) const
virtual

Implements IRender.

Reimplemented in CRenderVector.

Definition at line 280 of file render_common.cpp.

References text(), and CGlTextureFont::TextWidth().

◆ Vertex3f()

void CRenderCommon::Vertex3f ( GLfloat  x,
GLfloat  y,
GLfloat  z 
)
virtual

Explicit support not currently available for: GLbyte, GlShort and GLint calls, e.g.

glVertex2i(int x, int y); Vertices with homgeneous coords, e.g. glVertex4f(float x, float y, float z, float w); 3&4-dimensional texture coords, e.g. glTexCoord4f Generic attributes and mulitple texture coords per vertex Vertices

Implements IRender.

Reimplemented in CMtlRender, CGlRenderPdf, and CGlRenderDebug.

Definition at line 76 of file render_common.cpp.

References _TRACE, Error(), CGlState::GetPolygonMode(), LOG_POST, m_ColorBuffer, m_CurrentMode, m_State, m_TexCoord2DBuffer1, m_VertexBuffer, and x_SyncAttribs().

Referenced by Rectf().

◆ Viewport()

void CRenderCommon::Viewport ( GLint  x,
GLint  y,
GLsizei  width,
GLsizei  height 
)
virtual

Implements IRender.

Reimplemented in CMtlRender, CSVGRenderer, CGlRenderPdf, and CGlRender.

Definition at line 381 of file render_common.cpp.

References m_Viewport.

Referenced by CGlRender::Viewport(), CGlRenderPdf::Viewport(), and CSVGRenderer::Viewport().

◆ WriteText() [1/2]

void CRenderCommon::WriteText ( TModelUnit  x,
TModelUnit  y,
const char *  text,
TModelUnit  rotate_degrees = 0.0 
)
virtual

Write text at specified model coords.

Implements IRender.

Reimplemented in CSVGRenderer, CGlRenderPdf, and CGlRenderDebug.

Definition at line 245 of file render_common.cpp.

References Error(), CRgbaColor::GetColorArray(), LOG_POST, m_CurrentFont, m_TextColor, NULL, text(), and CGlTextureFont::WriteText().

◆ WriteText() [2/2]

void CRenderCommon::WriteText ( TModelUnit  x,
TModelUnit  y,
TModelUnit  width,
TModelUnit  height,
const char *  text,
CGlTextureFont::TAlign  align = CGlTextureFont::eAlign_Center,
CGlTextureFont::ETruncate  trunc = CGlTextureFont::eTruncate_Ellipsis,
TModelUnit  rotate_degrees = 0.0f 
)
virtual

Write text at specified model coords inside box defined by (x,y,width,height) with specified alignment, truncation and rotation.

Implements IRender.

Reimplemented in CSVGRenderer, CGlRenderPdf, and CGlRenderDebug.

Definition at line 257 of file render_common.cpp.

References Error(), CRgbaColor::GetColorArray(), LOG_POST, m_CurrentFont, m_TextColor, NULL, text(), trunc, and CGlTextureFont::WriteText().

◆ x_RenderBuffer()

void CRenderCommon::x_RenderBuffer ( CGlVboNode node)
protectedvirtual

Reimplemented in CSVGRenderer, CGlRenderPdf, and CGlRenderDebug.

Definition at line 454 of file render_common.cpp.

References CGlRenderNode::Render().

Referenced by End().

◆ x_SyncAttribs() [1/3]

void CRenderCommon::x_SyncAttribs ( vector< CRgbaColor > &  colors)
protected

◆ x_SyncAttribs() [2/3]

void CRenderCommon::x_SyncAttribs ( vector< CVect2< float > > &  vecs)
protected

Definition at line 431 of file render_common.cpp.

References m_VertexBuffer.

◆ x_SyncAttribs() [3/3]

void CRenderCommon::x_SyncAttribs ( vector< CVect3< float > > &  vecs)
protected

Definition at line 415 of file render_common.cpp.

References m_VertexBuffer.

Member Data Documentation

◆ m_ColorBuffer

vector<CRgbaColor> CRenderCommon::m_ColorBuffer
protected

Definition at line 169 of file render_common.hpp.

Referenced by Begin(), ColorC(), End(), Vertex3f(), and CGlRenderPdf::Vertex3f().

◆ m_CurrentFont

const CGlTextureFont* CRenderCommon::m_CurrentFont
protected

◆ m_CurrentMode

GLenum CRenderCommon::m_CurrentMode
protected

◆ m_MatrixMode

GLenum CRenderCommon::m_MatrixMode
protected

◆ m_RenderNode

CGlVboNode CRenderCommon::m_RenderNode
protected

vertex buffer node for rendering all Begin()/End() renders

Definition at line 173 of file render_common.hpp.

Referenced by CGlRenderPdf::BeginText(), CSVGRenderer::BeginText(), Clear(), CRenderCommon(), and End().

◆ m_State

CRef<CGlState> CRenderCommon::m_State
protected

◆ m_TexCoord2DBuffer1

vector<CVect2<float> > CRenderCommon::m_TexCoord2DBuffer1
protected

Definition at line 170 of file render_common.hpp.

Referenced by Begin(), End(), TexCoord2f(), Vertex3f(), and CGlRenderPdf::Vertex3f().

◆ m_TextColor

CRgbaColor CRenderCommon::m_TextColor
protected

◆ m_VertexBuffer

vector<CVect3<float> > CRenderCommon::m_VertexBuffer
protected

◆ m_Viewport

GLint CRenderCommon::m_Viewport[4]
protected

The documentation for this class was generated from the following files:
Modified on Wed May 15 15:07:47 2024 by modify_doxy.py rev. 669887