[Libreoffice-commits] core.git: 3 commits - chart2/opengl chart2/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Mon Feb 3 11:53:34 PST 2014
chart2/opengl/symbolFragmentShader.glsl | 37 +++++++++++++++++++++++++------
chart2/source/view/main/OpenGLRender.cxx | 20 ++++++++--------
chart2/source/view/main/OpenGLRender.hxx | 18 +++++----------
3 files changed, 48 insertions(+), 27 deletions(-)
New commits:
commit 6183af64de3d18a1342747bc8186ab429d6dd7db
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Mon Feb 3 20:52:47 2014 +0100
no need for typedefs here
Change-Id: I93c6a2ead9dfa25799376e4cfc88d77e18a4c9fd
diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index 864a58c..b5aeba3 100755
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -58,22 +58,22 @@
#define DEBUG_POSITIONING 0
#define RENDER_TO_FILE 0
-typedef struct PosVecf3
+struct PosVecf3
{
float x;
float y;
float z;
-}PosVecf3;
+};
typedef std::vector<GLfloat> Line2DPointList;
-typedef struct Bubble2DPointList
+struct Bubble2DPointList
{
float x;
float y;
float xScale;
float yScale;
-}Bubble2DPointList;
+};
typedef std::vector<GLfloat> Bubble2DCircle;
@@ -82,7 +82,7 @@ struct RectanglePointList
float points[12];
};
-typedef struct TextInfo
+struct TextInfo
{
GLuint texture;
float x;
@@ -90,7 +90,7 @@ typedef struct TextInfo
float z;
double rotation;
float vertex[12];
-}TextInfo;
+};
typedef std::vector<GLfloat> Area2DPointList;
typedef std::vector<GLfloat> PieSegment2DPointList;
commit a47351f84e9d9fe569700d79f14b239b6eff70a6
Author: Peilin <peilin at multicorewareinc.com>
Date: Mon Feb 3 20:49:40 2014 +0100
replace malloc with std::vector
Change-Id: I3546d0d005d17286107ff2c70a29a4bceebd36a0
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 8ca8a58..f6a473a 100755
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -1074,18 +1074,18 @@ int OpenGLRender::CreateMultiSampleFrameBufObj()
int OpenGLRender::Create2DCircle(int detail)
{
float angle;
- int idx = 2;
if (detail <= 0)
{
return -1;
}
- m_Bubble2DCircle.bufLen = 2 * (detail + 3)* sizeof(float);
- m_Bubble2DCircle.pointBuf = (float *)malloc(m_Bubble2DCircle.bufLen);
- memset(m_Bubble2DCircle.pointBuf, 0, m_Bubble2DCircle.bufLen);
+ m_Bubble2DCircle.clear();
+ m_Bubble2DCircle.reserve(2 * (detail + 3));
+ m_Bubble2DCircle.push_back(0);
+ m_Bubble2DCircle.push_back(0);
for(angle = 2.0f * GL_PI; angle > -(2.0f * GL_PI / detail); angle -= (2.0f * GL_PI / detail))
{
- m_Bubble2DCircle.pointBuf[idx++] = sin(angle);
- m_Bubble2DCircle.pointBuf[idx++] = cos(angle);
+ m_Bubble2DCircle.push_back(sin(angle));
+ m_Bubble2DCircle.push_back(cos(angle));
}
return 0;
}
@@ -1093,7 +1093,7 @@ int OpenGLRender::Create2DCircle(int detail)
int OpenGLRender::Bubble2DShapePoint(float x, float y, float directionX, float directionY)
{
//check whether to create the circle data
- if (!m_Bubble2DCircle.pointBuf)
+ if (m_Bubble2DCircle.empty())
{
Create2DCircle(100);
}
@@ -1126,11 +1126,11 @@ int OpenGLRender::RenderBubble2FBO(int)
//render to fbo
//fill vertex buffer
glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
- if (!m_Bubble2DCircle.pointBuf)
+ if (m_Bubble2DCircle.empty())
{
Create2DCircle(100);
}
- glBufferData(GL_ARRAY_BUFFER, m_Bubble2DCircle.bufLen, m_Bubble2DCircle.pointBuf, GL_STATIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, m_Bubble2DCircle.size() * sizeof(GLfloat), &m_Bubble2DCircle[0], GL_STATIC_DRAW);
glUseProgram(m_CommonProID);
@@ -1148,7 +1148,7 @@ int OpenGLRender::RenderBubble2FBO(int)
0, // stride
(void*)0 // array buffer offset
);
- glDrawArrays(GL_TRIANGLE_FAN, 0, m_Bubble2DCircle.bufLen / sizeof(float) / 2);
+ glDrawArrays(GL_TRIANGLE_FAN, 0, m_Bubble2DCircle.size() / 2);
glDisableVertexAttribArray(m_2DVertexID);
glUseProgram(0);
m_Bubble2DShapePointList.pop_front();
diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index 18176f6..864a58c 100755
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -75,11 +75,7 @@ typedef struct Bubble2DPointList
float yScale;
}Bubble2DPointList;
-typedef struct Bubble2DCircle
-{
- float *pointBuf;
- int bufLen;
-}Bubble2DCircle;
+typedef std::vector<GLfloat> Bubble2DCircle;
struct RectanglePointList
{
commit 89c6efe4ec986d6bc3c1147fea260f882f04c66b
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Mon Feb 3 20:14:34 2014 +0100
add the remaining symbols
Change-Id: I81b63d9e0e164e07cee3e10072a565e669b98196
diff --git a/chart2/opengl/symbolFragmentShader.glsl b/chart2/opengl/symbolFragmentShader.glsl
index 2837f95..3ac6b03 100644
--- a/chart2/opengl/symbolFragmentShader.glsl
+++ b/chart2/opengl/symbolFragmentShader.glsl
@@ -37,37 +37,62 @@ void main()
else if(p.y < 0 && abs(p.x) > 0.5)
discard;
}
- else if(shape == 4)
+ else if(shape == 4) // arrow right
{
if(p.x > 0 && (abs(p.x) + abs(p.y)) > 1)
discard;
else if(p.x < 0 && abs(p.y) > 0.5)
discard;
}
- else if(shape == 5)
+ else if(shape == 5) // arrow left
{
if(p.x < 0 && (abs(p.x) + abs(p.y)) > 1)
discard;
else if(p.x > 0 && abs(p.y) > 0.5)
discard;
}
- else if(shape == 6)
+ else if(shape == 6) // hour glass
{
if(abs(p.x) < abs(p.y))
discard;
}
- else if(shape == 7)
+ else if(shape == 7) // bow tie
{
if(abs(p.y) < abs(p.x))
discard;
}
- else if(shape == 8)
+ else if(shape == 8) // circle
{
if(dot(p.x, p.y) > 1)
discard;
}
- else if(shape == 9)
+ else if(shape == 9) // star
{
+ if(sqrt(abs(p.x))+sqrt(abs(p.y)) > 1)
+ discard;
+ }
+ else if(shape == 10) // X
+ {
+ if(abs(abs(p.x) - abs(p.y)) > 0.2)
+ discard;
+ }
+ else if(shape == 11) // Plus
+ {
+ if(abs(p.x) > 0.2 && abs(p.y) > 0.2)
+ discard;
+ }
+ else if(shape == 12) // asterisk
+ {
+ }
+ else if(shape == 13) // horizontal bar
+ {
+ if(abs(p.y) > 0.2)
+ discard;
+ }
+ else if(shape == 14) // vertical bar
+ {
+ if(abs(p.x) > 0.2)
+ discard;
}
gl_FragColor = fragmentColor;
More information about the Libreoffice-commits
mailing list