diff options
author | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2014-01-15 21:30:41 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-01-29 08:09:50 +0100 |
commit | f5e82d5378a5fb45a2a5781dd482e72990b403b1 (patch) | |
tree | aa530ea38f9d566af907e27a1f6386dd685d641f | |
parent | 6a515ca18479ad0335ef71d26be0c326b13bf5f7 (diff) |
finally fix rectangle rendering
Change-Id: Iaf0467ce4d9eb12ac3e84c2f1059b859ee9c4de1
-rwxr-xr-x | chart2/source/view/main/OpenGLRender.cxx | 39 | ||||
-rwxr-xr-x | chart2/source/view/main/OpenGLRender.hxx | 10 |
2 files changed, 25 insertions, 24 deletions
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx index 5b6010855158..7340b378eee2 100755 --- a/chart2/source/view/main/OpenGLRender.cxx +++ b/chart2/source/view/main/OpenGLRender.cxx @@ -211,13 +211,6 @@ static GLfloat coordVertices[] = { 0.0f, 1.0f, }; -static GLfloat square2DVertices[] = { - -1.0f, -1.0f, - 1.0f, -1.0f, - 1.0f, 1.0f, - -1.0f, 1.0f -}; - #if 0 static const GLfloat g_vertex_buffer_data[] = { -1.0f,-1.0f,-1.0f, @@ -1346,34 +1339,46 @@ int OpenGLRender::RectangleShapePoint(float x, float y, float directionX, float //check whether to create the circle data float actualX = x / OPENGL_SCALE_VALUE; float actualY = y / OPENGL_SCALE_VALUE; - RectanglePointList aRectangleList.x = actualX; - aRectangleList.y = actualY; - aRectangleList.z = m_fZStep; - aRectangleList.xScale = directionX / OPENGL_SCALE_VALUE; - aRectangleList.yScale = directionY / OPENGL_SCALE_VALUE; - - m_RectangleShapePointList.push_back(aRectangleList); + float actualSizeX = directionX / OPENGL_SCALE_VALUE; + float actualSizeY = directionY / OPENGL_SCALE_VALUE; + RectanglePointList aRectangle; + + aRectangle.points[0] = actualX; + aRectangle.points[1] = actualY; + aRectangle.points[2] = m_fZStep; + aRectangle.points[3] = actualX + actualSizeX; + aRectangle.points[4] = actualX; + aRectangle.points[5] = m_fZStep; + aRectangle.points[6] = actualX + actualSizeX; + aRectangle.points[7] = actualX + actualSizeY; + aRectangle.points[8] = m_fZStep; + aRectangle.points[9] = actualX; + aRectangle.points[10] = actualX + actualSizeY; + aRectangle.points[11] = m_fZStep; + + m_RectangleShapePointList.push_back(aRectangle); return 0; } int OpenGLRender::RenderRectangleShape() { + m_fZStep += 0.001; size_t listNum = m_RectangleShapePointList.size(); for (size_t i = 0; i < listNum; i++) { //move the circle to the pos, and scale using the xScale and Y scale RectanglePointList &pointList = m_RectangleShapePointList.front(); - PosVecf3 trans = {pointList.x, pointList.y, pointList.z}; + PosVecf3 trans = {0, 0, 0}; PosVecf3 angle = {0.0f, 0.0f, 0.0f}; - PosVecf3 scale = {pointList.xScale, pointList.yScale, 1.0f}; + PosVecf3 scale = {1, 1, 1.0f}; MoveModelf(trans, angle, scale); m_MVP = m_Projection * m_View * m_Model; //render to fbo //fill vertex buffer glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer); - glBufferData(GL_ARRAY_BUFFER, sizeof(square2DVertices), square2DVertices, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, sizeof(pointList.points), pointList.points, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, m_ColorBuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(m_BackgroundColor), m_BackgroundColor, GL_STATIC_DRAW); diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx index 68d0982395a3..815d7d32394b 100755 --- a/chart2/source/view/main/OpenGLRender.hxx +++ b/chart2/source/view/main/OpenGLRender.hxx @@ -84,14 +84,10 @@ typedef struct Bubble2DCircle int bufLen; }Bubble2DCircle; -typedef struct RectanglePointList +struct RectanglePointList { - float x; - float y; - float z; - float xScale; - float yScale; -}RectanglePointList; + float points[12]; +}; typedef struct TextInfo { |