summaryrefslogtreecommitdiff
path: root/src/OpenGl/OpenGl_GraphicDriver_3.cxx
blob: 4e36c9f664f2ffe98b171d205efc4ee08eeccff6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176


// File   OpenGl_GraphicDriver_3.cxx
// Created  Mardi 28 janvier 1997
// Author CAL

//-Copyright  MatraDatavision 1997

//-Version  

//-Design Declaration des variables specifiques aux Drivers

//-Warning  Un driver encapsule les Pex et OpenGl drivers

//-References 

//-Language C++ 2.0

//-Declarations

// for the class
#include <OpenGl_GraphicDriver.jxx>

#include <Aspect_DriverDefinitionError.hxx>


#include <OpenGl_tgl_funcs.hxx>

int GenerateMarkerBitmap( int theId, unsigned int theWidth, unsigned int theHeight, unsigned char* theArray);

//-Aliases

//-Global data definitions

//-Methods, in order

void OpenGl_GraphicDriver::ClearGroup (const Graphic3d_CGroup& ACGroup) {

  Graphic3d_CGroup MyCGroup = ACGroup;

  if (MyTraceLevel) 
  {
    PrintFunction ("call_togl_cleargroup");
    PrintCGroup (MyCGroup, 1);
  }
  call_togl_cleargroup (&MyCGroup);

}

void OpenGl_GraphicDriver::CloseGroup (const Graphic3d_CGroup& ACGroup) {

  Graphic3d_CGroup MyCGroup = ACGroup;

  if (MyTraceLevel) {
    PrintFunction ("call_togl_closegroup");
    PrintCGroup (MyCGroup, 1);
  }
  call_togl_closegroup (&MyCGroup);

}

void OpenGl_GraphicDriver::FaceContextGroup (const Graphic3d_CGroup& ACGroup, const Standard_Integer NoInsert) {

  Graphic3d_CGroup MyCGroup = ACGroup;

  if (MyTraceLevel) {
    PrintFunction ("call_togl_facecontextgroup");
    PrintCGroup (MyCGroup, 1);
    PrintInteger ("NoInsert", NoInsert);
  }
  call_togl_facecontextgroup (&MyCGroup, int (NoInsert));

}

void OpenGl_GraphicDriver::Group (Graphic3d_CGroup& ACGroup) {

  Graphic3d_CGroup MyCGroup = ACGroup;

  if (MyTraceLevel) {
    PrintFunction ("call_togl_group");
    PrintCGroup (MyCGroup, 1);
  }
  call_togl_group (&MyCGroup);

}

void OpenGl_GraphicDriver::LineContextGroup (const Graphic3d_CGroup& ACGroup, const Standard_Integer NoInsert) {

  Graphic3d_CGroup MyCGroup = ACGroup;

  if (MyTraceLevel) {
    PrintFunction ("call_togl_linecontextgroup");
    PrintCGroup (MyCGroup, 1);
    PrintInteger ("NoInsert", NoInsert);
  }
  call_togl_linecontextgroup (&MyCGroup, int (NoInsert));

}

void OpenGl_GraphicDriver::MarkerContextGroup (const Graphic3d_CGroup& ACGroup, const Standard_Integer NoInsert) {

  Graphic3d_CGroup MyCGroup = ACGroup;

  if (MyTraceLevel) {
    PrintFunction ("call_togl_markercontextgroup");
    PrintCGroup (MyCGroup, 1);
    PrintInteger ("NoInsert", NoInsert);
  }
  call_togl_markercontextgroup (&MyCGroup, int (NoInsert));

}

void OpenGl_GraphicDriver::MarkerContextGroup (const Graphic3d_CGroup& ACGroup, 
                                               const Standard_Integer NoInsert,
                                               const Standard_Integer AMarkWidth,
                                               const Standard_Integer AMarkHeight,
                                               const Handle(TColStd_HArray1OfByte)& ATexture ) 
{

  Graphic3d_CGroup MyCGroup = ACGroup;

  int aByteWidth = AMarkWidth / 8;

  unsigned char *anArray = (unsigned char*) malloc(ATexture->Length());
  for( int anIndex = ATexture->Upper() - ATexture->Lower() - aByteWidth + 1; anIndex >= 0; anIndex -= aByteWidth )
    for( int i = 0; i < aByteWidth; i++ )
      anArray[ATexture->Upper() - ATexture->Lower() - aByteWidth + 1 - anIndex + i ] = ATexture->Value( anIndex + i + 1 );

  GenerateMarkerBitmap( (int)ACGroup.ContextMarker.Scale, AMarkWidth, AMarkHeight, anArray );
  if (MyTraceLevel) {
    PrintFunction ("call_togl_markercontextgroup");
    PrintCGroup (MyCGroup, 1);
    PrintInteger ("NoInsert", NoInsert);
  }
  call_togl_markercontextgroup (&MyCGroup, int (NoInsert));

  free(anArray);
}


void OpenGl_GraphicDriver::OpenGroup (const Graphic3d_CGroup& ACGroup) {

  Graphic3d_CGroup MyCGroup = ACGroup;

  if (MyTraceLevel) {
    PrintFunction ("call_togl_opengroup");
    PrintCGroup (MyCGroup, 1);
  }
  call_togl_opengroup (&MyCGroup);

}

void OpenGl_GraphicDriver::RemoveGroup (const Graphic3d_CGroup& ACGroup) {

  Graphic3d_CGroup MyCGroup = ACGroup;

  if (MyTraceLevel) {
    PrintFunction ("call_togl_removegroup");
    PrintCGroup (MyCGroup, 1);
  }
  call_togl_removegroup (&MyCGroup);

}

void OpenGl_GraphicDriver::TextContextGroup (const Graphic3d_CGroup& ACGroup, const Standard_Integer NoInsert) {

  Graphic3d_CGroup MyCGroup = ACGroup;

  if (MyTraceLevel) {
    PrintFunction ("call_togl_textcontextgroup");
    PrintCGroup (MyCGroup, 1);
    PrintInteger ("NoInsert", NoInsert);
  }
  call_togl_textcontextgroup (&MyCGroup, int (NoInsert));

}