Fix a huge bunch of memory corruption bugs in GL
[ipdf/code.git] / src / ipdf.h
1 #ifndef _IPDF_H
2 #define _IPDF_H
3
4 #include "common.h"
5 #include "real.h"
6 #include "bezier.h"
7 #include "rect.h"
8
9 #define C_RED Colour(1,0,0,1)
10 #define C_GREEN Colour(0,1,0,1)
11 #define C_BLUE Colour(0,0,1,1)
12 #define C_BLACK Colour(0,0,0,1);
13
14 namespace IPDF
15 {
16
17         inline Real Random(Real max=1, Real min=0)
18         {
19                 return min + (max-min) * (Real(rand() % (int)1e6) / Real(1e6));
20         }
21
22         typedef unsigned ObjectID;
23         /** Type of object
24      * NOTE: Extra entry in the enum so we can use this as an array index
25          */
26         typedef enum 
27         {
28                 CIRCLE_FILLED = 0, 
29                 RECT_FILLED,
30                 RECT_OUTLINE,
31                 BEZIER,
32                 NUMBER_OF_OBJECT_TYPES
33         } ObjectType;
34
35         enum DocChunkTypes
36         {
37                 CT_NUMOBJS,
38                 CT_OBJTYPES,
39                 CT_OBJBOUNDS,
40                 CT_OBJINDICES,
41                 CT_OBJBEZIERS
42                 //CT_OBJGROUPS
43         };
44
45
46
47         
48         
49         struct Colour
50         {
51                 float r; float g; float b; float a;
52                 Colour() = default;
53                 Colour(float _r, float _g, float _b, float _a) : r(_r), g(_g), b(_b), a(_a) {}
54         };
55
56         struct ObjectData
57         {
58                 Colour colour;
59                 
60         };
61
62         struct Objects
63         {
64                 /** Used by all objects **/
65                 std::vector<ObjectType> types; // types of objects
66                 std::vector<Rect> bounds; // rectangle bounds of objects
67                 
68                 /** Used by BEZIER to identify data position in relevant vector **/
69                 std::vector<unsigned> data_indices;
70
71                 /** Used by BEZIER only **/
72                 std::vector<Bezier> beziers; // bezier curves - look up by data_indices
73         };
74
75         class View;
76 }
77
78
79 #endif //_IPDF_H

UCC git Repository :: git.ucc.asn.au