Kaydet (Commit) a670e159 authored tarafından weigao's avatar weigao Kaydeden (comit) Markus Mohrhard

add screen text color set interface

Change-Id: I2407166368b55b973c70a2edc377785b82d8481b
üst bbd07982
...@@ -861,7 +861,7 @@ void GL3DBarChart::clickedAt(const Point& rPos, sal_uInt16 nButtons) ...@@ -861,7 +861,7 @@ void GL3DBarChart::clickedAt(const Point& rPos, sal_uInt16 nButtons)
rBarInfo.maPos.y + BAR_SIZE_Y / 2.0f, rBarInfo.maPos.y + BAR_SIZE_Y / 2.0f,
rBarInfo.maPos.z); rBarInfo.maPos.z);
maShapes.push_back(new opengl3D::ScreenText(mpRenderer.get(), *mpTextCache, maShapes.push_back(new opengl3D::ScreenText(mpRenderer.get(), *mpTextCache,
OUString("Value: ") + OUString::number(rBarInfo.mnVal), CALC_POS_EVENT_ID)); OUString("Value: ") + OUString::number(rBarInfo.mnVal), glm::vec4(0.0f, 0.0f, 1.0f, 1.0f), CALC_POS_EVENT_ID));
opengl3D::ScreenText* pScreenText = static_cast<opengl3D::ScreenText*>(&maShapes.back()); opengl3D::ScreenText* pScreenText = static_cast<opengl3D::ScreenText*>(&maShapes.back());
pScreenText->setPosition(glm::vec2(-0.9f, 0.9f), glm::vec2(-0.6f, 0.8f), aTextPos); pScreenText->setPosition(glm::vec2(-0.9f, 0.9f), glm::vec2(-0.6f, 0.8f), aTextPos);
pScreenText->render(); pScreenText->render();
...@@ -995,9 +995,9 @@ void GL3DBarChart::contextDestroyed() ...@@ -995,9 +995,9 @@ void GL3DBarChart::contextDestroyed()
mbValidContext = false; mbValidContext = false;
} }
void GL3DBarChart::addScreenTextShape(OUString &nStr, glm::vec2 rLeftTop, float nTextHeight, const glm::vec3& rPos, sal_uInt32 nEvent) void GL3DBarChart::addScreenTextShape(OUString &nStr, glm::vec2 rLeftTop, float nTextHeight, const glm::vec3& rPos, const glm::vec4& rColor, sal_uInt32 nEvent)
{ {
maScreenTextShapes.push_back(new opengl3D::ScreenText(mpRenderer.get(), *mpTextCache, nStr, nEvent)); maScreenTextShapes.push_back(new opengl3D::ScreenText(mpRenderer.get(), *mpTextCache, nStr, rColor, nEvent));
const opengl3D::TextCacheItem& rTextCache = mpTextCache->getText(nStr); const opengl3D::TextCacheItem& rTextCache = mpTextCache->getText(nStr);
float nRectWidth = (float)rTextCache.maSize.Width() / (float)rTextCache.maSize.Height() * nTextHeight / 2.0f; float nRectWidth = (float)rTextCache.maSize.Width() / (float)rTextCache.maSize.Height() * nTextHeight / 2.0f;
opengl3D::ScreenText* pScreenText = static_cast<opengl3D::ScreenText*>(&maScreenTextShapes.back()); opengl3D::ScreenText* pScreenText = static_cast<opengl3D::ScreenText*>(&maScreenTextShapes.back());
...@@ -1017,7 +1017,7 @@ void GL3DBarChart::updateRenderFPS() ...@@ -1017,7 +1017,7 @@ void GL3DBarChart::updateRenderFPS()
osl_getSystemTime(&maFPSRenderStartTime); osl_getSystemTime(&maFPSRenderStartTime);
} }
osl_getSystemTime(&maFPSRenderEndTime); osl_getSystemTime(&maFPSRenderEndTime);
addScreenTextShape(maFPS, glm::vec2(-0.99f, 0.99f), 0.06f); addScreenTextShape(maFPS, glm::vec2(-0.99f, 0.99f), 0.06f, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));
} }
int GL3DBarChart::calcTimeInterval(TimeValue &startTime, TimeValue &endTime) int GL3DBarChart::calcTimeInterval(TimeValue &startTime, TimeValue &endTime)
...@@ -1085,7 +1085,7 @@ void GL3DBarChart::updateClickEvent() ...@@ -1085,7 +1085,7 @@ void GL3DBarChart::updateClickEvent()
if (idex + 1 == aList.size()) if (idex + 1 == aList.size())
{ {
aBarValue = OUString("Value: ") + OUString::number(*it); aBarValue = OUString("Value: ") + OUString::number(*it);
maScreenTextShapes.push_back(new opengl3D::ScreenText(mpRenderer.get(), *mpTextCache, aBarValue, CALC_POS_EVENT_ID)); maScreenTextShapes.push_back(new opengl3D::ScreenText(mpRenderer.get(), *mpTextCache, aBarValue, glm::vec4(0.0f, 0.0f, 1.0f, 1.0f), CALC_POS_EVENT_ID));
const opengl3D::TextCacheItem& rTextCache = mpTextCache->getText(aBarValue); const opengl3D::TextCacheItem& rTextCache = mpTextCache->getText(aBarValue);
float nRectWidth = (float)rTextCache.maSize.Width() / (float)rTextCache.maSize.Height() * 0.03; float nRectWidth = (float)rTextCache.maSize.Width() / (float)rTextCache.maSize.Height() * 0.03;
std::map<sal_uInt32, const BarInformation>::const_iterator itr = maBarMap.find(nBarId); std::map<sal_uInt32, const BarInformation>::const_iterator itr = maBarMap.find(nBarId);
...@@ -1226,7 +1226,7 @@ void GL3DBarChart::updateScroll() ...@@ -1226,7 +1226,7 @@ void GL3DBarChart::updateScroll()
for(size_t i = 0; i < aBarInfoList.size(); i++) for(size_t i = 0; i < aBarInfoList.size(); i++)
{ {
OUString aBarValue = OUString("Value: ") + OUString::number(aBarInfoList[i].mnVal); OUString aBarValue = OUString("Value: ") + OUString::number(aBarInfoList[i].mnVal);
maScreenTextShapes.push_back(new opengl3D::ScreenText(mpRenderer.get(), *mpTextCache, aBarValue, CALC_POS_EVENT_ID)); maScreenTextShapes.push_back(new opengl3D::ScreenText(mpRenderer.get(), *mpTextCache, aBarValue, glm::vec4(0.0f, 0.0f, 1.0f, 1.0f), CALC_POS_EVENT_ID));
const opengl3D::TextCacheItem& rTextCache = mpTextCache->getText(aBarValue); const opengl3D::TextCacheItem& rTextCache = mpTextCache->getText(aBarValue);
float nRectWidth = (float)rTextCache.maSize.Width() / (float)rTextCache.maSize.Height() * 0.03; float nRectWidth = (float)rTextCache.maSize.Width() / (float)rTextCache.maSize.Height() * 0.03;
glm::vec3 aTextPos = glm::vec3(aBarInfoList[i].maPos.x + BAR_SIZE_X / 2.0f, glm::vec3 aTextPos = glm::vec3(aBarInfoList[i].maPos.x + BAR_SIZE_X / 2.0f,
......
...@@ -108,7 +108,7 @@ private: ...@@ -108,7 +108,7 @@ private:
class ScreenText : public Renderable3DObject class ScreenText : public Renderable3DObject
{ {
public: public:
ScreenText(OpenGL3DRenderer* pRenderer, TextCache& rTextCache, const OUString& rStr, sal_uInt32 nId); ScreenText(OpenGL3DRenderer* pRenderer, TextCache& rTextCache, const OUString& rStr, glm::vec4 rColor, sal_uInt32 nId);
virtual void render() SAL_OVERRIDE; virtual void render() SAL_OVERRIDE;
void setPosition(const glm::vec2& rTopLeft, const glm::vec2& rBottomRight, glm::vec3 r3DPos = glm::vec3(0.0, 0.0, 0.0)); void setPosition(const glm::vec2& rTopLeft, const glm::vec2& rBottomRight, glm::vec3 r3DPos = glm::vec3(0.0, 0.0, 0.0));
...@@ -118,6 +118,7 @@ private: ...@@ -118,6 +118,7 @@ private:
glm::vec2 maTopLeft; glm::vec2 maTopLeft;
glm::vec2 maBottomRight; glm::vec2 maBottomRight;
glm::vec3 ma3DPos; glm::vec3 ma3DPos;
glm::vec4 maColor;
}; };
class Rectangle : public Renderable3DObject class Rectangle : public Renderable3DObject
......
...@@ -91,7 +91,10 @@ private: ...@@ -91,7 +91,10 @@ private:
void updateDataUpdateFPS(); void updateDataUpdateFPS();
DECL_LINK(updateTimer, void*); DECL_LINK(updateTimer, void*);
int calcTimeInterval(TimeValue &startTime, TimeValue &endTime); int calcTimeInterval(TimeValue &startTime, TimeValue &endTime);
void addScreenTextShape(OUString &nStr, glm::vec2 rLeftTop, float nTextHeight, const glm::vec3& rPos = glm::vec3(0.0f, 0.0f, 0.0f), sal_uInt32 nEvent = 0); void addScreenTextShape(OUString &nStr, glm::vec2 rLeftTop, float nTextHeight,
const glm::vec3& rPos = glm::vec3(0.0f, 0.0f, 0.0f),
const glm::vec4& rColor = glm::vec4(0.0f, 0.0f, 1.0f, 1.0f),
sal_uInt32 nEvent = 0);
void recordBarHistory(sal_uInt32 &nBarID, float &nVal); void recordBarHistory(sal_uInt32 &nBarID, float &nVal);
void updateClickEvent(); void updateClickEvent();
void calcDistance(std::vector<sal_uInt32> &vectorNearest); void calcDistance(std::vector<sal_uInt32> &vectorNearest);
......
...@@ -142,6 +142,7 @@ struct TextInfo ...@@ -142,6 +142,7 @@ struct TextInfo
GLuint texture; GLuint texture;
float vertex[12]; float vertex[12];
glm::vec3 pos; glm::vec3 pos;
glm::vec4 textColor;
}; };
struct TextureArrayInfo struct TextureArrayInfo
...@@ -199,7 +200,7 @@ public: ...@@ -199,7 +200,7 @@ public:
sal_uInt32 nUniqueId); sal_uInt32 nUniqueId);
void CreateScreenTextTexture(const boost::shared_array<sal_uInt8> &bitmapBuf, void CreateScreenTextTexture(const boost::shared_array<sal_uInt8> &bitmapBuf,
::Size maSizePixels, const glm::vec2& vTopLeft, ::Size maSizePixels, const glm::vec2& vTopLeft,
const glm::vec2& vBottomRight, glm::vec3 vPos, sal_uInt32 nUniqueId); const glm::vec2& vBottomRight, glm::vec3 vPos, glm::vec4 screenTextColor, sal_uInt32 nUniqueId);
void ProcessUnrenderedShape(bool bNewScene); void ProcessUnrenderedShape(bool bNewScene);
void SetPickingMode(bool bPickingMode); void SetPickingMode(bool bPickingMode);
......
...@@ -128,9 +128,10 @@ void Text::setPosition(const glm::vec3& rTopLeft, const glm::vec3& rTopRight, co ...@@ -128,9 +128,10 @@ void Text::setPosition(const glm::vec3& rTopLeft, const glm::vec3& rTopRight, co
maBottomRight = rBottomRight; maBottomRight = rBottomRight;
} }
ScreenText::ScreenText(OpenGL3DRenderer* pRenderer, TextCache& rTextCache, const OUString& rStr, sal_uInt32 nId): ScreenText::ScreenText(OpenGL3DRenderer* pRenderer, TextCache& rTextCache, const OUString& rStr, glm::vec4 rColor, sal_uInt32 nId):
Renderable3DObject(pRenderer, nId), Renderable3DObject(pRenderer, nId),
maText(rTextCache.getText(rStr)) maText(rTextCache.getText(rStr)),
maColor(rColor)
{ {
} }
...@@ -144,7 +145,7 @@ void ScreenText::setPosition(const glm::vec2& rTopLeft, const glm::vec2& rBottom ...@@ -144,7 +145,7 @@ void ScreenText::setPosition(const glm::vec2& rTopLeft, const glm::vec2& rBottom
void ScreenText::render() void ScreenText::render()
{ {
mpRenderer->CreateScreenTextTexture(maText.maPixels, maText.maSize, mpRenderer->CreateScreenTextTexture(maText.maPixels, maText.maSize,
maTopLeft, maBottomRight, ma3DPos, maTopLeft, maBottomRight, ma3DPos, maColor,
mnUniqueId); mnUniqueId);
} }
......
...@@ -1670,7 +1670,7 @@ void OpenGL3DRenderer::RenderExtrude3DObject() ...@@ -1670,7 +1670,7 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
void OpenGL3DRenderer::CreateScreenTextTexture( void OpenGL3DRenderer::CreateScreenTextTexture(
const boost::shared_array<sal_uInt8> &bitmapBuf, const boost::shared_array<sal_uInt8> &bitmapBuf,
::Size maSizePixels, const glm::vec2& vTopLeft, ::Size maSizePixels, const glm::vec2& vTopLeft,
const glm::vec2& vBottomRight, glm::vec3 vPos, sal_uInt32 nUniqueId) const glm::vec2& vBottomRight, glm::vec3 vPos, glm::vec4 screenTextColor, sal_uInt32 nUniqueId)
{ {
long bmpWidth = maSizePixels.Width(); long bmpWidth = maSizePixels.Width();
long bmpHeight = maSizePixels.Height(); long bmpHeight = maSizePixels.Height();
...@@ -1694,6 +1694,7 @@ void OpenGL3DRenderer::CreateScreenTextTexture( ...@@ -1694,6 +1694,7 @@ void OpenGL3DRenderer::CreateScreenTextTexture(
aTextInfo.vertex[10] = vBottomRight.y; aTextInfo.vertex[10] = vBottomRight.y;
aTextInfo.vertex[11] = 0; aTextInfo.vertex[11] = 0;
aTextInfo.pos = vPos; aTextInfo.pos = vPos;
aTextInfo.textColor = screenTextColor;
CHECK_GL_ERROR(); CHECK_GL_ERROR();
glGenTextures(1, &aTextInfo.texture); glGenTextures(1, &aTextInfo.texture);
...@@ -1881,8 +1882,6 @@ void OpenGL3DRenderer::ReleaseScreenTextTexture() ...@@ -1881,8 +1882,6 @@ void OpenGL3DRenderer::ReleaseScreenTextTexture()
void OpenGL3DRenderer::RenderScreenTextShape() void OpenGL3DRenderer::RenderScreenTextShape()
{ {
glUseProgram(maResources.m_ScreenTextProID); glUseProgram(maResources.m_ScreenTextProID);
glm::vec4 textColor = glm::vec4(0.0, 0.0, 1.0, 1.0);
glUniform4fv(maResources.m_ScreenTextColorID, 1, &textColor[0]);
CHECK_GL_ERROR(); CHECK_GL_ERROR();
for (size_t i = 0; i < m_ScreenTextInfoList.size(); i++) for (size_t i = 0; i < m_ScreenTextInfoList.size(); i++)
{ {
...@@ -1910,6 +1909,7 @@ void OpenGL3DRenderer::RenderScreenTextShape() ...@@ -1910,6 +1909,7 @@ void OpenGL3DRenderer::RenderScreenTextShape()
} }
} }
} }
glUniform4fv(maResources.m_ScreenTextColorID, 1, &textInfo.textColor[0]);
glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer); glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
CHECK_GL_ERROR(); CHECK_GL_ERROR();
glBufferData(GL_ARRAY_BUFFER, sizeof(textInfo.vertex), textInfo.vertex, GL_STATIC_DRAW); glBufferData(GL_ARRAY_BUFFER, sizeof(textInfo.vertex), textInfo.vertex, GL_STATIC_DRAW);
......
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