Commit a6c8beb7 authored by Maciej Suminski's avatar Maciej Suminski

Drawing tracks using PushVertices, added some comments, fixed formatting.

parent 32784ea1
...@@ -615,20 +615,35 @@ inline void OPENGL_GAL::drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2 ...@@ -615,20 +615,35 @@ inline void OPENGL_GAL::drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2
VECTOR2D perpendicularVector( -startEndVector.y * scale, startEndVector.x * scale ); VECTOR2D perpendicularVector( -startEndVector.y * scale, startEndVector.x * scale );
// Compute the edge points of the line // Compute the edge points of the line
VECTOR2D point1 = aStartPoint + perpendicularVector; VECTOR2D v0 = aStartPoint + perpendicularVector;
VECTOR2D point2 = aStartPoint - perpendicularVector; VECTOR2D v1 = aStartPoint - perpendicularVector;
VECTOR2D point3 = aEndPoint + perpendicularVector; VECTOR2D v2 = aEndPoint + perpendicularVector;
VECTOR2D point4 = aEndPoint - perpendicularVector; VECTOR2D v3 = aEndPoint - perpendicularVector;
if( isGrouping )
{
GLfloat newVertices[] = {
v0.x, v0.y, layerDepth, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a,
v1.x, v1.y, layerDepth, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a,
v3.x, v3.y, layerDepth, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a,
v0.x, v0.y, layerDepth, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a,
v3.x, v3.y, layerDepth, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a,
v2.x, v2.y, layerDepth, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a
};
curVboItem->PushVertices( newVertices, 6 );
}
else
{
glBegin( GL_TRIANGLES ); glBegin( GL_TRIANGLES );
glVertex3d( point1.x, point1.y, layerDepth ); glVertex3d( v0.x, v0.y, layerDepth );
glVertex3d( point2.x, point2.y, layerDepth ); glVertex3d( v1.x, v1.y, layerDepth );
glVertex3d( point4.x, point4.y, layerDepth ); glVertex3d( v3.x, v3.y, layerDepth );
glVertex3d( point1.x, point1.y, layerDepth ); glVertex3d( v0.x, v0.y, layerDepth );
glVertex3d( point4.x, point4.y, layerDepth ); glVertex3d( v3.x, v3.y, layerDepth );
glVertex3d( point3.x, point3.y, layerDepth ); glVertex3d( v2.x, v2.y, layerDepth );
glEnd(); glEnd();
}
} }
...@@ -637,7 +652,7 @@ void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndP ...@@ -637,7 +652,7 @@ void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndP
VECTOR2D startEndVector = aEndPoint - aStartPoint; VECTOR2D startEndVector = aEndPoint - aStartPoint;
double lineAngle = atan2( startEndVector.y, startEndVector.x ); double lineAngle = atan2( startEndVector.y, startEndVector.x );
if ( isGrouping ) /*if ( isGrouping )
{ {
// Angle of a line perpendicular to the segment being drawn // Angle of a line perpendicular to the segment being drawn
double beta = ( M_PI / 2.0 ) - lineAngle; double beta = ( M_PI / 2.0 ) - lineAngle;
...@@ -662,9 +677,11 @@ void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndP ...@@ -662,9 +677,11 @@ void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndP
}; };
curVboItem->PushVertices( newVertices, 6 ); curVboItem->PushVertices( newVertices, 6 );
} }
else*/
{
if( isFillEnabled ) if( isFillEnabled )
{ {
if( !isGrouping )
glColor4d( fillColor.r, fillColor.g, fillColor.b, fillColor.a ); glColor4d( fillColor.r, fillColor.g, fillColor.b, fillColor.a );
SetLineWidth( aWidth ); SetLineWidth( aWidth );
...@@ -694,6 +711,7 @@ void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndP ...@@ -694,6 +711,7 @@ void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndP
glPopMatrix(); glPopMatrix();
} }
}
} }
......
...@@ -86,7 +86,7 @@ void VBO_ITEM::PushVertex( const GLfloat* aVertex ) ...@@ -86,7 +86,7 @@ void VBO_ITEM::PushVertex( const GLfloat* aVertex )
} }
void VBO_ITEM::PushVertices( const GLfloat* aVertex, GLuint aSize ) void VBO_ITEM::PushVertices( const GLfloat* aVertices, GLuint aSize )
{ {
int newSize = m_size + aSize; int newSize = m_size + aSize;
GLfloat* newVertices = new GLfloat[newSize * VertStride]; GLfloat* newVertices = new GLfloat[newSize * VertStride];
...@@ -101,8 +101,8 @@ void VBO_ITEM::PushVertices( const GLfloat* aVertex, GLuint aSize ) ...@@ -101,8 +101,8 @@ void VBO_ITEM::PushVertices( const GLfloat* aVertex, GLuint aSize )
} }
m_vertices = newVertices; m_vertices = newVertices;
// Add the new vertex // Add new vertices
memcpy( &newVertices[m_size * VertStride], aVertex, aSize * VertSize ); memcpy( &newVertices[m_size * VertStride], aVertices, aSize * VertSize );
// Handle new indices // Handle new indices
if( m_indices ) if( m_indices )
...@@ -160,7 +160,7 @@ void SetVbo( int aVboId ) ...@@ -160,7 +160,7 @@ void SetVbo( int aVboId )
} }
int GetVbo() int GetVbo() const
{ {
} }
*/ */
...@@ -43,9 +43,23 @@ public: ...@@ -43,9 +43,23 @@ public:
VBO_ITEM(); VBO_ITEM();
~VBO_ITEM(); ~VBO_ITEM();
// TODO comments /**
* Function PushVertex()
* Adds a single vertex to the VBO_ITEM. Vertex contains information about coordinates and
* colors and has to follow the specified format {X,Y,Z,R,G,B,A}.
* @param aVertex is a vertex to be added.
*/
void PushVertex( const GLfloat* aVertex ); void PushVertex( const GLfloat* aVertex );
void PushVertices( const GLfloat* aVertex, GLuint aSize );
/**
* Function PushVertices()
* Adds multiple vertices to the VBO_ITEM. This function is recommended over multiple calls to
* PushVertex, as it does less memory reallocations. Vertices contain information about
* coordinates and colors and has to follow the specified format {X,Y,Z,R,G,B,A}.
* @param aVertices are vertices to be added.
* @param aSize is an amount of vertices to be added.
*/
void PushVertices( const GLfloat* aVertices, GLuint aSize );
/** /**
* Function GetVertices() * Function GetVertices()
...@@ -79,7 +93,7 @@ public: ...@@ -79,7 +93,7 @@ public:
///< Functions for getting VBO ids. ///< Functions for getting VBO ids.
//void SetVbo( int aVboId ); //void SetVbo( int aVboId );
//int GetVbo(); //int GetVbo() const;
///< Data organization information for vertices. ///< Data organization information for vertices.
static const int VertStride = 7; static const int VertStride = 7;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment