MCPcopy Create free account
hub / github.com/TankOs/SFGUI / DisplayImpl

Method DisplayImpl

src/SFGUI/Renderers/VertexArrayRenderer.cpp:79–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79void VertexArrayRenderer::DisplayImpl() const {
80 CheckGLError( glMatrixMode( GL_MODELVIEW ) );
81 CheckGLError( glPushMatrix() );
82 CheckGLError( glLoadIdentity() );
83
84 CheckGLError( glMatrixMode( GL_PROJECTION ) );
85 CheckGLError( glPushMatrix() );
86 CheckGLError( glLoadIdentity() );
87
88 // When SFML dies (closes) it sets the window size to 0 for some reason.
89 // That then causes glOrtho errors.
90
91 // SFML doesn't seem to bother updating the OpenGL viewport when
92 // it's window resizes and nothing is drawn directly through SFML...
93
94 if( m_last_window_size != m_window_size ) {
95 CheckGLError( glViewport( 0, 0, m_window_size.x, m_window_size.y ) );
96
97 m_last_window_size = m_window_size;
98
99 if( m_window_size.x && m_window_size.y ) {
100 const_cast<VertexArrayRenderer*>( this )->Invalidate( INVALIDATE_VERTEX | INVALIDATE_TEXTURE );
101 }
102 }
103
104 CheckGLError( glOrtho( 0.0f, static_cast<GLdouble>( m_window_size.x ? m_window_size.x : 1 ), static_cast<GLdouble>( m_window_size.y ? m_window_size.y : 1 ), 0.0f, -1.0f, 64.0f ) );
105
106 CheckGLError( glMatrixMode( GL_TEXTURE ) );
107 CheckGLError( glPushMatrix() );
108 CheckGLError( glLoadIdentity() );
109
110 if( m_alpha_threshold > 0.f ) {
111 CheckGLError( glAlphaFunc( GL_GREATER, m_alpha_threshold ) );
112 CheckGLError( glEnable( GL_ALPHA_TEST ) );
113 }
114
115 if( m_dirty ) {
116 // Disclaimer:
117 // const_cast IS safe to use in ANY non-static method of
118 // Renderer. Because we make sure that the only instance
119 // that can be constructed is the singleton instance and
120 // that the singleton instance is non-const, we don't have
121 // to fear that some member variable is non-mutable. This
122 // is a nice hack to please certain people who require const
123 // methods in the most exotic places without having to declare
124 // half the member variables and methods as mutable. Then
125 // again this might be all wrong...
126
127 // Refresh array data if out of sync
128 const_cast<VertexArrayRenderer*>( this )->RefreshArray();
129 }
130
131 CheckGLError( glVertexPointer( 2, GL_FLOAT, 0, &m_vertex_data[0] ) );
132 CheckGLError( glColorPointer( 4, GL_UNSIGNED_BYTE, 0, &m_color_data[0] ) );
133 CheckGLError( glTexCoordPointer( 2, GL_FLOAT, 0, &m_texture_data[0] ) );
134
135 // Not needed, constantly kept enabled by SFML... -_-
136 //CheckGLError( glEnableClientState( GL_VERTEX_ARRAY ) );

Callers

nothing calls this directly

Calls 3

RefreshArrayMethod · 0.80
getMethod · 0.80
InvalidateMethod · 0.45

Tested by

no test coverage detected