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
191cb40e
Commit
191cb40e
authored
Apr 30, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduction of VBO. Now only tracks are rendered in a very simple way.
parent
0cd108b5
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
483 additions
and
31 deletions
+483
-31
CMakeLists.txt
common/CMakeLists.txt
+1
-0
drawpanel_gal.cpp
common/drawpanel_gal.cpp
+1
-5
opengl_gal.cpp
common/gal/opengl/opengl_gal.cpp
+196
-12
vbo_item.cpp
common/gal/opengl/vbo_item.cpp
+134
-0
view.cpp
common/view/view.cpp
+3
-0
opengl_gal.h
include/gal/opengl/opengl_gal.h
+30
-10
vbo_item.h
include/gal/opengl/vbo_item.h
+114
-0
basepcbframe.cpp
pcbnew/basepcbframe.cpp
+4
-4
No files found.
common/CMakeLists.txt
View file @
191cb40e
...
...
@@ -20,6 +20,7 @@ set(GAL_SRCS
gal/color4d.cpp
gal/opengl/opengl_gal.cpp
gal/opengl/shader.cpp
gal/opengl/vbo_item.cpp
gal/cairo/cairo_gal.cpp
view/wx_view_controls.cpp
)
...
...
common/drawpanel_gal.cpp
View file @
191cb40e
...
...
@@ -65,9 +65,8 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
m_gal
->
ComputeWorldScreenMatrix
();
m_painter
=
new
KiGfx
::
PCB_PAINTER
(
m_gal
);
m_painter
->
SetGAL
(
m_gal
);
m_view
=
new
KiGfx
::
VIEW
(
true
);
m_view
=
new
KiGfx
::
VIEW
(
true
,
true
);
m_view
->
SetPainter
(
m_painter
);
m_view
->
SetGAL
(
m_gal
);
...
...
@@ -157,9 +156,6 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType, bool aUseShaders )
if
(
m_view
)
m_view
->
SetGAL
(
m_gal
);
if
(
m_painter
)
m_painter
->
SetGAL
(
m_gal
);
wxSize
size
=
GetClientSize
();
m_gal
->
ResizeScreen
(
size
.
GetX
(),
size
.
GetY
()
);
}
common/gal/opengl/opengl_gal.cpp
View file @
191cb40e
This diff is collapsed.
Click to expand it.
common/gal/opengl/vbo_item.cpp
0 → 100644
View file @
191cb40e
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file vbo_item.cpp
* @brief Class to handle an item held in a Vertex Buffer Object.
*/
#include <gal/opengl/vbo_item.h>
#include <cstring>
using
namespace
KiGfx
;
VBO_ITEM
::
VBO_ITEM
()
:
m_vertices
(
NULL
),
m_indices
(
NULL
),
m_offset
(
0
),
m_size
(
0
),
m_isDirty
(
true
)
{
}
VBO_ITEM
::~
VBO_ITEM
()
{
if
(
m_vertices
)
delete
m_vertices
;
}
void
VBO_ITEM
::
PushVertex
(
const
GLfloat
*
aVertex
)
{
GLfloat
*
newVertices
=
new
GLfloat
[(
m_size
+
1
)
*
VertStride
];
GLuint
*
newIndices
=
new
GLuint
[(
m_size
+
1
)
*
IndStride
];
// Handle a new vertex
if
(
m_vertices
)
{
// Copy all previous vertices data
memcpy
(
newVertices
,
m_vertices
,
(
m_size
)
*
VertSize
);
delete
m_vertices
;
}
m_vertices
=
newVertices
;
// Add the new vertex
memcpy
(
&
newVertices
[
m_size
*
VertStride
],
aVertex
,
VertSize
);
// Handle a new index
if
(
m_indices
)
{
// Copy all previous vertices data
memcpy
(
newIndices
,
m_indices
,
(
m_size
)
*
IndSize
);
delete
m_indices
;
}
m_indices
=
newIndices
;
// Add the new vertex
newIndices
[
m_size
]
=
m_offset
+
m_size
;
m_size
++
;
m_isDirty
=
true
;
}
void
VBO_ITEM
::
PushVertices
(
const
GLfloat
*
aVertex
,
GLuint
aSize
)
{
// FIXME to be done
m_isDirty
=
true
;
}
GLfloat
*
VBO_ITEM
::
GetVertices
()
const
{
return
m_vertices
;
}
GLuint
*
VBO_ITEM
::
GetIndices
()
const
{
return
m_indices
;
}
int
VBO_ITEM
::
GetSize
()
const
{
return
m_size
;
}
void
VBO_ITEM
::
SetOffset
(
int
aOffset
)
{
m_offset
=
aOffset
;
// TODO change offset for all the vertices?
}
int
VBO_ITEM
::
GetOffset
()
const
{
return
m_offset
;
}
/*
// TODO
void SetVbo( int aVboId )
{
}
int GetVbo()
{
}
*/
common/view/view.cpp
View file @
191cb40e
...
...
@@ -205,6 +205,9 @@ void VIEW::SetGAL( GAL* aGal )
{
m_gal
=
aGal
;
if
(
m_painter
)
m_painter
->
SetGAL
(
m_gal
);
// items need to be recached after changing GAL
if
(
m_useGroups
)
recacheAllItems
();
...
...
include/gal/opengl/opengl_gal.h
View file @
191cb40e
...
...
@@ -55,6 +55,7 @@
namespace
KiGfx
{
class
SHADER
;
class
VBO_ITEM
;
/**
* @brief Class OpenGL_GAL is the OpenGL implementation of the Graphics Abstraction Layer.
...
...
@@ -88,7 +89,7 @@ public:
*/
OPENGL_GAL
(
wxWindow
*
aParent
,
wxEvtHandler
*
aMouseListener
=
NULL
,
wxEvtHandler
*
aPaintListener
=
NULL
,
bool
isUseShaders
=
false
,
const
wxString
&
aName
=
wxT
(
"GLCanvas"
)
);
const
wxString
&
aName
=
wxT
(
"GLCanvas"
)
);
virtual
~
OPENGL_GAL
();
...
...
@@ -132,7 +133,7 @@ public:
// Screen methods
// --------------
/// @brief Resizes the canvas.
/// @brief Resizes the canvas.
virtual
void
ResizeScreen
(
int
aWidth
,
int
aHeight
);
/// @brief Shows/hides the GAL canvas
...
...
@@ -335,19 +336,28 @@ private:
wxEvtHandler
*
paintListener
;
// Display lists
GLuint
displayListsArcs
;
///< Arc display list
GLuint
displayListCircle
;
///< Circle display list
GLuint
displayListSemiCircle
;
///< Semi circle display list
std
::
deque
<
GLuint
>
displayListsGroup
;
///< List of display lists used for groups
GLuint
displayListsArcs
;
///< Arc display list
GLuint
displayListCircle
;
///< Circle display list
GLuint
displayListSemiCircle
;
///< Semi circle display list
std
::
deque
<
GLuint
>
displayListsGroup
;
///< List of display lists used for groups
double
curvePoints
[
12
];
///< Coefficients for curves
std
::
deque
<
VECTOR2D
>
unitCirclePoints
;
///< List of the points on a unit circle
// Vertex buffer objects related fields
std
::
deque
<
VBO_ITEM
*>
vboItems
;
///< Stores informations about VBO objects
VBO_ITEM
*
curVboItem
;
GLuint
curVboVertId
;
GLuint
curVboIndId
;
int
vboSize
;
bool
vboNeedsUpdate
;
double
curvePoints
[
12
];
///< Coefficients for curves
std
::
deque
<
VECTOR2D
>
unitCirclePoints
;
///< List of the points on a unit circle
// Polygon tesselation
GLUtesselator
*
tesselator
;
///< Pointer to the tesselator
GLUtesselator
*
tesselator
;
///< Pointer to the tesselator
// Shader
std
::
deque
<
SHADER
>
shaderList
;
///< List of the shaders
std
::
deque
<
SHADER
>
shaderList
;
///< List of the shaders
// Cursor
int
cursorSize
;
///< Size of the cursor in pixels
...
...
@@ -368,6 +378,7 @@ private:
bool
isCreated
;
bool
isGlewInitialized
;
///< Is GLEW initialized?
bool
isFrameBufferInitialized
;
///< Are the frame buffers initialized?
bool
isVboInitialized
;
bool
isShaderInitialized
;
///< Was the shader initialized?
bool
isShaderEnabled
;
///< Are the shaders enabled?
bool
isUseShader
;
///< Should the shaders be used?
...
...
@@ -457,6 +468,15 @@ private:
*/
void
deleteFrameBuffer
(
GLuint
*
aFrameBuffer
,
GLuint
*
aDepthBuffer
,
GLuint
*
aTexture
);
// TODO comment
void
initVertexBufferObjects
();
// TODO comment
void
deleteVertexBufferObjects
();
// TODO comment
void
rebuildVbo
();
/**
* @brief Draw a quad for the line.
*
...
...
include/gal/opengl/vbo_item.h
0 → 100644
View file @
191cb40e
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file vbo_item.h
* @brief Class to handle an item held in a Vertex Buffer Object.
*/
// TODO comments
#ifndef VBO_ITEM_H_
#define VBO_ITEM_H_
#include <GL/gl.h>
namespace
KiGfx
{
class
VBO_ITEM
{
public
:
VBO_ITEM
();
~
VBO_ITEM
();
// TODO comments
void
PushVertex
(
const
GLfloat
*
aVertex
);
void
PushVertices
(
const
GLfloat
*
aVertex
,
GLuint
aSize
);
/**
* Function GetVertices()
* Returns a pointer to the array containing all vertices.
* @return Pointer to vertices packed in format {X, Y, Z, R, G, B, A}.
*/
GLfloat
*
GetVertices
()
const
;
GLuint
*
GetIndices
()
const
;
/**
* Function GetSize()
* Returns information about number of vertices stored.
* @param Amount of vertices.
*/
int
GetSize
()
const
;
/**
* Function SetOffset()
* Sets data offset in the VBO.
* @param aOffset is the offset expressed as a number of vertices.
*/
void
SetOffset
(
int
aOffset
);
/**
* Function GetOffset()
* Returns data offset in the VBO.
* @return Data offset expressed as a number of vertices.
*/
int
GetOffset
()
const
;
///< Functions for getting VBO ids.
//void SetVbo( int aVboId );
//int GetVbo();
///< Data organization information for vertices.
static
const
int
VertStride
=
7
;
static
const
int
VertSize
=
VertStride
*
sizeof
(
GLfloat
);
static
const
int
IndStride
=
1
;
static
const
int
IndSize
=
IndStride
*
sizeof
(
GLuint
);
static
const
int
ColorOffset
=
3
*
sizeof
(
GLfloat
);
private
:
///< VBO ids in which the item is stored.
//int m_vboId; // not used yet
///< Contains vertices coordinates and colors.
///< Packed by 7 floats for each vertex: {X, Y, Z, R, G, B, A}
GLfloat
*
m_vertices
;
GLuint
*
m_indices
;
///< Offset and size of data in VBO.
int
m_offset
;
int
m_size
;
///< Shader data used for rendering.
int
m_shader
;
int
m_shaderAttrib
;
///< Flag telling if the item should be recached in VBO or not.
bool
m_isDirty
;
};
}
// namespace KiGfx
#endif
/* VBO_ITEM_H_ */
pcbnew/basepcbframe.cpp
View file @
191cb40e
...
...
@@ -166,7 +166,7 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
// in order to be displayed
// Load zones
for
(
int
i
=
0
;
i
<
m_Pcb
->
GetAreaCount
();
++
i
)
/*
for( int i = 0; i < m_Pcb->GetAreaCount(); ++i )
{
view->Add( (KiGfx::VIEW_ITEM*) ( m_Pcb->GetArea( i ) ) );
}
...
...
@@ -175,7 +175,7 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
for( BOARD_ITEM* drawing = m_Pcb->m_Drawings; drawing; drawing = drawing->Next() )
{
view->Add( drawing );
}
}
*/
// Load tracks
for
(
TRACK
*
track
=
m_Pcb
->
m_Track
;
track
;
track
=
track
->
Next
()
)
...
...
@@ -184,7 +184,7 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
}
// Load modules and its additional elements
for
(
MODULE
*
module
=
m_Pcb
->
m_Modules
;
module
;
module
=
module
->
Next
()
)
/*
for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() )
{
// Load module's pads
for( D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
...
...
@@ -208,7 +208,7 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
for( SEGZONE* zone = m_Pcb->m_Zone; zone; zone = zone->Next() )
{
view->Add( zone );
}
}
*/
// Apply layer coloring scheme & display options
if
(
view
->
GetPainter
()
)
...
...
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