Fixed cursor drawing for OpenGL.
This commit is contained in:
parent
6fe086ab6d
commit
bd8998d1da
|
@ -792,7 +792,7 @@ void CAIRO_GAL::ClearTarget( RenderTarget aTarget )
|
||||||
void CAIRO_GAL::DrawCursor( const VECTOR2D& aCursorPosition )
|
void CAIRO_GAL::DrawCursor( const VECTOR2D& aCursorPosition )
|
||||||
{
|
{
|
||||||
// Now we should only store the position of the mouse cursor
|
// Now we should only store the position of the mouse cursor
|
||||||
// The real drawing routines are in EndDrawing()
|
// The real drawing routines are in blitCursor()
|
||||||
cursorPosition = VECTOR2D( aCursorPosition.x - cursorSize / 2,
|
cursorPosition = VECTOR2D( aCursorPosition.x - cursorSize / 2,
|
||||||
aCursorPosition.y - cursorSize / 2 );
|
aCursorPosition.y - cursorSize / 2 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,9 +214,11 @@ void OPENGL_GAL::EndDrawing()
|
||||||
overlayManager.EndDrawing();
|
overlayManager.EndDrawing();
|
||||||
|
|
||||||
// Draw the remaining contents, blit the rendering targets to the screen, swap the buffers
|
// Draw the remaining contents, blit the rendering targets to the screen, swap the buffers
|
||||||
glFlush();
|
|
||||||
compositor.DrawBuffer( mainBuffer );
|
compositor.DrawBuffer( mainBuffer );
|
||||||
compositor.DrawBuffer( overlayBuffer );
|
compositor.DrawBuffer( overlayBuffer );
|
||||||
|
blitCursor();
|
||||||
|
|
||||||
|
glFlush();
|
||||||
SwapBuffers();
|
SwapBuffers();
|
||||||
|
|
||||||
delete clientDC;
|
delete clientDC;
|
||||||
|
@ -737,33 +739,10 @@ void OPENGL_GAL::ClearTarget( RenderTarget aTarget )
|
||||||
|
|
||||||
void OPENGL_GAL::DrawCursor( const VECTOR2D& aCursorPosition )
|
void OPENGL_GAL::DrawCursor( const VECTOR2D& aCursorPosition )
|
||||||
{
|
{
|
||||||
if( !isCursorEnabled )
|
// Now we should only store the position of the mouse cursor
|
||||||
return;
|
// The real drawing routines are in blitCursor()
|
||||||
|
cursorPosition = VECTOR2D( aCursorPosition.x,
|
||||||
compositor.SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING );
|
screenSize.y - aCursorPosition.y ); // invert Y axis
|
||||||
|
|
||||||
// Invert y axis
|
|
||||||
VECTOR2D cursorPosition = VECTOR2D( aCursorPosition.x, screenSize.y - aCursorPosition.y );
|
|
||||||
|
|
||||||
VECTOR2D cursorBegin = ToWorld( cursorPosition -
|
|
||||||
VECTOR2D( cursorSize / 2, cursorSize / 2 ) );
|
|
||||||
VECTOR2D cursorEnd = ToWorld( cursorPosition +
|
|
||||||
VECTOR2D( cursorSize / 2, cursorSize / 2 ) );
|
|
||||||
VECTOR2D cursorCenter = ( cursorBegin + cursorEnd ) / 2.0;
|
|
||||||
|
|
||||||
glLineWidth( 1.0 );
|
|
||||||
glColor4d( cursorColor.r, cursorColor.g, cursorColor.b, cursorColor.a );
|
|
||||||
|
|
||||||
glBegin( GL_LINES );
|
|
||||||
glVertex3f( cursorCenter.x, cursorBegin.y, GetMinDepth() );
|
|
||||||
glVertex3f( cursorCenter.x, cursorEnd.y, GetMinDepth() );
|
|
||||||
|
|
||||||
glVertex3f( cursorBegin.x, cursorCenter.y, GetMinDepth() );
|
|
||||||
glVertex3f( cursorEnd.x, cursorCenter.y, GetMinDepth() );
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
// Restore the default color, so textures will be drawn properly
|
|
||||||
glColor4d( 1.0, 1.0, 1.0, 1.0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -969,6 +948,36 @@ void OPENGL_GAL::initCursor( int aCursorSize )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void OPENGL_GAL::blitCursor()
|
||||||
|
{
|
||||||
|
if( !isCursorEnabled )
|
||||||
|
return;
|
||||||
|
|
||||||
|
compositor.SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING );
|
||||||
|
|
||||||
|
VECTOR2D cursorBegin = ToWorld( cursorPosition -
|
||||||
|
VECTOR2D( cursorSize / 2, cursorSize / 2 ) );
|
||||||
|
VECTOR2D cursorEnd = ToWorld( cursorPosition +
|
||||||
|
VECTOR2D( cursorSize / 2, cursorSize / 2 ) );
|
||||||
|
VECTOR2D cursorCenter = ( cursorBegin + cursorEnd ) / 2.0;
|
||||||
|
|
||||||
|
glDisable( GL_TEXTURE_2D );
|
||||||
|
glLineWidth( 1.0 );
|
||||||
|
glColor4d( cursorColor.r, cursorColor.g, cursorColor.b, cursorColor.a );
|
||||||
|
|
||||||
|
glBegin( GL_LINES );
|
||||||
|
glVertex2d( cursorCenter.x, cursorBegin.y );
|
||||||
|
glVertex2d( cursorCenter.x, cursorEnd.y );
|
||||||
|
|
||||||
|
glVertex2d( cursorBegin.x, cursorCenter.y );
|
||||||
|
glVertex2d( cursorEnd.x, cursorCenter.y );
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
// Restore the default color, so textures will be drawn properly
|
||||||
|
glColor4d( 1.0, 1.0, 1.0, 1.0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int OPENGL_GAL::getNewGroupNumber()
|
unsigned int OPENGL_GAL::getNewGroupNumber()
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( groups.size() < std::numeric_limits<unsigned int>::max(),
|
wxASSERT_MSG( groups.size() < std::numeric_limits<unsigned int>::max(),
|
||||||
|
|
|
@ -357,7 +357,7 @@ private:
|
||||||
virtual void initCursor( int aCursorSize );
|
virtual void initCursor( int aCursorSize );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Blits cursor into current screen.
|
* @brief Blits cursor into the current screen.
|
||||||
*/
|
*/
|
||||||
virtual void blitCursor( wxBufferedDC& clientDC );
|
virtual void blitCursor( wxBufferedDC& clientDC );
|
||||||
|
|
||||||
|
|
|
@ -297,6 +297,8 @@ private:
|
||||||
bool isShaderInitialized; ///< Was the shader initialized?
|
bool isShaderInitialized; ///< Was the shader initialized?
|
||||||
bool isGrouping; ///< Was a group started?
|
bool isGrouping; ///< Was a group started?
|
||||||
|
|
||||||
|
VECTOR2D cursorPosition; ///< Current cursor position
|
||||||
|
|
||||||
// Polygon tesselation
|
// Polygon tesselation
|
||||||
/// The tessellator
|
/// The tessellator
|
||||||
GLUtesselator* tesselator;
|
GLUtesselator* tesselator;
|
||||||
|
@ -363,6 +365,11 @@ private:
|
||||||
/// @copydoc GAL::initCursor()
|
/// @copydoc GAL::initCursor()
|
||||||
virtual void initCursor( int aCursorSize );
|
virtual void initCursor( int aCursorSize );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Blits cursor into the current screen.
|
||||||
|
*/
|
||||||
|
void blitCursor();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns a valid key that can be used as a new group number.
|
* @brief Returns a valid key that can be used as a new group number.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue