Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / chart2 / source / view / main / OpenGLRender.hxx
blobb222a40f6647dec3040dffb177dabdb2edfb305a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #ifndef INCLUDED_CHART2_SOURCE_VIEW_MAIN_OPENGLRENDER_HXX
11 #define INCLUDED_CHART2_SOURCE_VIEW_MAIN_OPENGLRENDER_HXX
13 #include <vcl/bitmapex.hxx>
14 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
15 #include <com/sun/star/drawing/FillStyle.hpp>
16 #include <com/sun/star/drawing/XDrawPage.hpp>
17 #include <vcl/font.hxx>
18 #include <vcl/opengl/OpenGLContext.hxx>
19 #include <boost/shared_array.hpp>
21 // Include GLM
22 #include <vector>
23 #include <map>
24 #include <glm/glm.hpp>
25 #include <glm/gtx/transform.hpp>
26 #include <glm/gtx/euler_angles.hpp>
27 #include <glm/gtx/quaternion.hpp>
29 #define DEBUG_POSITIONING 0
31 struct PosVecf3
33 float x;
34 float y;
35 float z;
38 struct Bubble2DPointList
40 float x;
41 float y;
42 float xScale;
43 float yScale;
46 struct RectanglePointList
48 float points[12];
51 struct TextInfo
53 GLuint texture;
54 double rotation;
55 float vertex[12];
56 float nDx;
57 float nDy;
60 typedef std::vector<GLfloat> PointList;
62 // for 3D, use vector to save the points
64 class OpenGLRender
66 public:
67 OpenGLRender();
68 ~OpenGLRender();
69 int InitOpenGL();
70 int MoveModelf(const PosVecf3& trans, const PosVecf3& angle, const PosVecf3& scale);
71 void SetSize(int width, int height);
72 void SetSizePixel(int width, int height);
73 void Release();
74 int RenderLine2FBO();
75 int SetLine2DShapePoint(float x, float y, int listLength);
76 void SetLine2DColor(sal_uInt8 r, sal_uInt8 g, sal_uInt8 b, sal_uInt8 nAlpha);
77 void SetLine2DWidth(int width);
78 void SetColor(sal_uInt32 color, sal_uInt8 nAlpha);
79 int Bubble2DShapePoint(float x, float y, float directionX, float directionY);
80 int RenderBubble2FBO();
82 void prepareToRender();
84 int RenderRectangleShape(bool bBorder, bool bFill);
85 int RectangleShapePoint(float x, float y, float directionX, float directionY);
87 int CreateTextTexture(const boost::shared_array<sal_uInt8> &rPixels,
88 const ::Size &aPixelSize,
89 const css::awt::Size& aSize,
90 long rotation,
91 const css::drawing::HomogenMatrix3& rTrans);
92 int CreateTextTexture(const BitmapEx& rBitmapEx,
93 const css::awt::Size& aSize,
94 long rotation, const css::drawing::HomogenMatrix3& rTrans);
95 int RenderTextShape();
97 int SetArea2DShapePoint(float x, float y, int listLength);
98 int RenderArea2DShape();
99 void SetChartTransparencyGradient(long transparencyGradient);
101 void GeneratePieSegment2D(double, double, double, double);
102 int RenderPieSegment2DShape(float, float, float);
104 int RenderSymbol2DShape(float, float, sal_Int32);
105 #if DEBUG_POSITIONING
106 void renderDebug();
107 #endif
109 void SetBackGroundColor(::Color color1, ::Color color2, css::drawing::FillStyle fillstyle);
111 private:
112 int m_iWidth;
114 int m_iHeight;
116 private:
117 int Create2DCircle(int detail);
118 private:
119 // Projection matrix : default 45 degree Field of View, 4:3 ratio, display range : 0.1 unit <-> 100 units
120 glm::mat4 m_Projection;
121 // Camera matrix
122 glm::mat4 m_View;
123 // Model matrix : an identity matrix (model will be at the origin
124 glm::mat4 m_Model;
125 // Our ModelViewProjection : multiplication of our 3 matrices
126 glm::mat4 m_MVP;
128 GLuint m_VertexBuffer;
130 GLuint m_ColorBuffer;
132 GLint m_MatrixID;
134 GLuint m_RenderVertexBuf;
136 GLuint m_RenderTexCoordBuf;
138 PointList m_Line2DPointList;
140 float m_fLineWidth;
142 std::vector<PointList> m_Line2DShapePointList;
144 glm::vec4 m_2DColor;
146 std::vector<GLfloat> m_Bubble2DCircle;
148 std::vector<Bubble2DPointList> m_Bubble2DShapePointList;
149 GLint m_CommonProID;
150 GLint m_2DVertexID;
151 GLint m_2DColorID;
153 float m_fZStep;
155 std::vector<RectanglePointList> m_RectangleShapePointList;
156 // add for text
157 std::vector<TextInfo> m_TextInfoVector;
158 GLint m_TextProID;
159 GLint m_TextMatrixID;
160 GLint m_TextVertexID;
161 GLint m_TextTexCoordID;
162 GLuint m_TextTexCoordBuf;
163 GLint m_TextTexID;
165 PointList m_Area2DPointList;
166 std::vector<PointList> m_Area2DShapePointList;
168 GLint m_BackgroundProID;
169 GLint m_BackgroundMatrixID;
170 GLint m_BackgroundVertexID;
171 GLint m_BackgroundColorID;
173 float m_BackgroundColor[16];
175 std::vector<PointList> m_PieSegment2DShapePointList;
177 GLuint m_SymbolProID;
178 GLuint m_SymbolVertexID;
179 GLuint m_SymbolMatrixID;
180 GLuint m_SymbolColorID;
181 GLuint m_SymbolShapeID;
183 #if DEBUG_POSITIONING
184 GLuint m_DebugProID;
185 GLuint m_DebugVertexID;
186 GLuint m_DebugColorID;
187 #endif
190 #endif // INCLUDED_CHART2_SOURCE_VIEW_MAIN_OPENGLRENDER_HXX
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */