Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
bd8998d1
Commit
bd8998d1
authored
Aug 28, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed cursor drawing for OpenGL.
parent
6fe086ab
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
30 deletions
+46
-30
cairo_gal.cpp
common/gal/cairo/cairo_gal.cpp
+1
-1
opengl_gal.cpp
common/gal/opengl/opengl_gal.cpp
+37
-28
cairo_gal.h
include/gal/cairo/cairo_gal.h
+1
-1
opengl_gal.h
include/gal/opengl/opengl_gal.h
+7
-0
No files found.
common/gal/cairo/cairo_gal.cpp
View file @
bd8998d1
...
@@ -792,7 +792,7 @@ void CAIRO_GAL::ClearTarget( RenderTarget aTarget )
...
@@ -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
);
}
}
...
...
common/gal/opengl/opengl_gal.cpp
View file @
bd8998d1
...
@@ -214,9 +214,11 @@ void OPENGL_GAL::EndDrawing()
...
@@ -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 )
...
@@ -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 )
...
@@ -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
(),
...
...
include/gal/cairo/cairo_gal.h
View file @
bd8998d1
...
@@ -357,7 +357,7 @@ private:
...
@@ -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
);
...
...
include/gal/opengl/opengl_gal.h
View file @
bd8998d1
...
@@ -297,6 +297,8 @@ private:
...
@@ -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:
...
@@ -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.
*
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment