0022819: Redesign of OpenGl driver
[occt.git] / src / OpenGl / OpenGl_polygonoffset.cxx
1 /*
2 Created : 22-03-04 : SAN : OCC4895 High-level interface for controlling polygon offsets
3 */
4
5 #include <OpenGl_tgl_all.hxx>
6
7 #include <stddef.h>
8 #include <stdio.h>
9 #include <GL/gl.h>
10 #include <GL/glu.h>
11
12 #include <OpenGl_cmn_varargs.hxx>
13 #include <OpenGl_telem_attri.hxx>
14 #include <OpenGl_tsm.hxx>
15 #include <OpenGl_telem.hxx>
16 #include <OpenGl_telem_inquire.hxx>
17
18 static  TStatus  PolygonOffsetDisplay( TSM_ELEM_DATA, Tint, cmn_key* );
19 static  TStatus  PolygonOffsetAdd( TSM_ELEM_DATA, Tint, cmn_key* );
20 static  TStatus  PolygonOffsetDelete( TSM_ELEM_DATA, Tint, cmn_key* );
21 static  TStatus  PolygonOffsetPrint( TSM_ELEM_DATA, Tint, cmn_key* );
22
23 static  TStatus  (*MtdTbl[])( TSM_ELEM_DATA, Tint, cmn_key* ) =
24 {
25   0,             /* PickTraverse */
26   PolygonOffsetDisplay,
27   PolygonOffsetAdd,
28   PolygonOffsetDelete,
29   PolygonOffsetPrint,
30   0              /* Inquire */
31 };
32
33
34 MtblPtr
35 TelPolygonOffsetInitClass( TelType *el )
36 {
37   *el = TelPolygonOffset;
38   return MtdTbl;
39 }
40
41 static  TStatus
42 PolygonOffsetAdd( TSM_ELEM_DATA d, Tint n, cmn_key *k )
43 {
44   tel_poffset_param data = new TEL_POFFSET_PARAM();
45
46   if( !data )
47     return TFailure;
48
49   *data = *(tel_poffset_param)(k[0]->data.pdata);
50
51   ((tsm_elem_data)(d.pdata))->pdata = data;
52
53   return TSuccess;
54 }
55
56
57 static  TStatus
58 PolygonOffsetDisplay( TSM_ELEM_DATA data, Tint n, cmn_key *k )
59 {
60   tel_poffset_param d;
61   CMN_KEY           key;
62
63   d = (tel_poffset_param)data.pdata;
64
65   key.id = TelPolygonOffset;
66   key.data.pdata = d;
67   TsmSetAttri( 1, &key );
68
69   return TSuccess;
70 }
71
72
73 static  TStatus
74 PolygonOffsetDelete( TSM_ELEM_DATA data, Tint n, cmn_key *k )
75 {
76   if (data.pdata)
77     delete data.pdata;
78   return TSuccess;
79 }
80
81
82 static  TStatus
83 PolygonOffsetPrint( TSM_ELEM_DATA data, Tint n, cmn_key *k )
84 {
85   tel_poffset_param p;
86   p = (tel_poffset_param)data.pdata;
87
88   fprintf( stdout, "TelPolygonOffset. Mode = %x, Factor = %f, Units = %f\n", 
89     p->mode, p->factor, p->units);
90   fprintf( stdout, "\n" );
91
92   return TSuccess;
93 }
94