Kaydet (Commit) 1c8fb3bd authored tarafından Peilin's avatar Peilin Kaydeden (comit) Markus Mohrhard

add black bubble edge and modify transparence

Change-Id: If18e74c2cec00d29bddaffbbd21991749490493a
üst 62d6252d
...@@ -514,6 +514,13 @@ void DummyCircle::render() ...@@ -514,6 +514,13 @@ void DummyCircle::render()
else else
SAL_WARN("chart2.opengl", "missing color"); SAL_WARN("chart2.opengl", "missing color");
itr = maProperties.find("FillTransparence");
if(itr != maProperties.end())
{
sal_Int32 nTrans = itr->second.get<sal_Int32>();
pChart->m_GLRender.SetTransparency(nTrans&0xFF);
}
pChart->m_GLRender.Bubble2DShapePoint(maPosition.X, maPosition.Y, pChart->m_GLRender.Bubble2DShapePoint(maPosition.X, maPosition.Y,
maSize.Width, maSize.Height); maSize.Width, maSize.Height);
pChart->m_GLRender.RenderBubble2FBO(GL_TRUE); pChart->m_GLRender.RenderBubble2FBO(GL_TRUE);
......
...@@ -1044,6 +1044,7 @@ int OpenGLRender::Bubble2DShapePoint(float x, float y, float directionX, float d ...@@ -1044,6 +1044,7 @@ int OpenGLRender::Bubble2DShapePoint(float x, float y, float directionX, float d
int OpenGLRender::RenderBubble2FBO(int) int OpenGLRender::RenderBubble2FBO(int)
{ {
CHECK_GL_ERROR(); CHECK_GL_ERROR();
glm::vec4 edgeColor = glm::vec4(0.0, 0.0, 0.0, 1.0);
size_t listNum = m_Bubble2DShapePointList.size(); size_t listNum = m_Bubble2DShapePointList.size();
for (size_t i = 0; i < listNum; i++) for (size_t i = 0; i < listNum; i++)
{ {
...@@ -1082,7 +1083,30 @@ int OpenGLRender::RenderBubble2FBO(int) ...@@ -1082,7 +1083,30 @@ int OpenGLRender::RenderBubble2FBO(int)
glDrawArrays(GL_TRIANGLE_FAN, 0, m_Bubble2DCircle.size() / 2); glDrawArrays(GL_TRIANGLE_FAN, 0, m_Bubble2DCircle.size() / 2);
glDisableVertexAttribArray(m_2DVertexID); glDisableVertexAttribArray(m_2DVertexID);
glUseProgram(0); glUseProgram(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
//add black edge
glLineWidth(3.0);
glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
glBufferData(GL_ARRAY_BUFFER, m_Bubble2DCircle.size() * sizeof(GLfloat) -2 , &m_Bubble2DCircle[2], GL_STATIC_DRAW);
glUseProgram(m_CommonProID);
glUniform4fv(m_2DColorID, 1, &edgeColor[0]);
glUniformMatrix4fv(m_MatrixID, 1, GL_FALSE, &m_MVP[0][0]);
glEnableVertexAttribArray(m_2DVertexID);
glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
glVertexAttribPointer(
m_2DVertexID, // attribute. No particular reason for 0, but must match the layout in the shader.
2, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
glDrawArrays(GL_LINE_STRIP, 0, (m_Bubble2DCircle.size() * sizeof(GLfloat) -2) / sizeof(float) / 2);
glDisableVertexAttribArray(m_2DVertexID);
glUseProgram(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
m_Bubble2DShapePointList.pop_front(); m_Bubble2DShapePointList.pop_front();
glLineWidth(m_fLineWidth);
} }
//if use MSAA, we should copy the data to the FBO texture //if use MSAA, we should copy the data to the FBO texture
GLenum fbResult = glCheckFramebufferStatus(GL_FRAMEBUFFER); GLenum fbResult = glCheckFramebufferStatus(GL_FRAMEBUFFER);
...@@ -1528,7 +1552,11 @@ void OpenGLRender::SetChartTransparencyGradient(long transparencyGradient) ...@@ -1528,7 +1552,11 @@ void OpenGLRender::SetChartTransparencyGradient(long transparencyGradient)
m_BackgroundColor[15] = 0.0; m_BackgroundColor[15] = 0.0;
} }
} }
void OpenGLRender::SetTransparency(sal_uInt32 transparency)
{
m_fAlpha = (float)transparency / 255.0;
m_2DColor = glm::vec4(m_2DColor.r, m_2DColor.g, m_2DColor.b, m_fAlpha);
}
void OpenGLRender::GeneratePieSegment2D(double fInnerRadius, double fOutterRadius, double nAngleStart, double nAngleWidth) void OpenGLRender::GeneratePieSegment2D(double fInnerRadius, double fOutterRadius, double nAngleStart, double nAngleWidth)
{ {
double nAngleStep = 1; double nAngleStep = 1;
......
...@@ -191,7 +191,7 @@ public: ...@@ -191,7 +191,7 @@ public:
#endif #endif
void SetBackGroundColor(sal_uInt32 color1, sal_uInt32 color2, sal_uInt8 nAlpha); void SetBackGroundColor(sal_uInt32 color1, sal_uInt32 color2, sal_uInt8 nAlpha);
void SetTransparency(sal_uInt32 transparency);
private: private:
GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName); GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName);
int CreateTextureObj(int width, int height); int CreateTextureObj(int width, int height);
...@@ -294,7 +294,7 @@ private: ...@@ -294,7 +294,7 @@ private:
GLuint m_DebugVertexID; GLuint m_DebugVertexID;
GLuint m_DebugColorID; GLuint m_DebugColorID;
#endif #endif
float m_fAlpha;
}; };
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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