summaryrefslogtreecommitdiff
path: root/src/OpenGl/OpenGl_tox.cxx
blob: 342e7276a61212d3aaf2c6f317c1d08a0d4b5607 (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

#ifndef WNT
/***********************************************************************

FONCTION :
----------
File OpenGl_tox :


REMARQUES:
---------- 


HISTORIQUE DES MODIFICATIONS   :
--------------------------------
xx-xx-xx : xxx ; Creation.
20-02-96 : FMN ; Suppression code inutile:
on ne garde que  :
- call_tox_open_display()
- call_tox_getscreen(Tint *d_wdth, Tint *d_hght)
01-04-96 : CAL ; Integration MINSK portage WNT
20-11-97 : CAL ; RererereMerge avec le source de portage.
12-02-01 : GG  ; BUC60821 Add getpitchsize() function
27-03-02 : GG  ; RIC120202 Add new function call_tox_set_display

************************************************************************/

/*----------------------------------------------------------------------*/
/*
* Includes
*/

#include <stdio.h>

#include <X11/Xlib.h>
#include <X11/Xutil.h>

#include <InterfaceGraphic_Aspect.hxx>

#include <OpenGl_tgl_all.hxx>
#include <OpenGl_txgl.hxx>
#include <OpenGl_tgl_tox.hxx>
#include <OpenGl_tgl_util.hxx>

/*----------------------------------------------------------------------*/
/*
* Variables globales
*/

Display * call_thedisplay; /* display pointer; defined in tgl/tox */

/*----------------------------------------------------------------------*/
/*
*Fonctions externes
*/

/*----------------------------------------------------------------------*/

Tint
call_tox_open_display (void)
{
  char synchro[132];

  if (call_thedisplay == NULL)
    /*
    * display_name
    * Specifies the hardware display name, which determines the
    * display and communications domain to be used.
    * On a POSIX system, if the display_name is NULL, it defaults
    * to the value of the DISPLAY environment variable.
    */
    call_thedisplay = XOpenDisplay ((char*) NULL);

  if (call_thedisplay != NULL)
    if (call_util_osd_getenv ("CALL_SYNCHRO_X", synchro, 132))
      XSynchronize (call_thedisplay, 1);
    else
      XSynchronize (call_thedisplay, 0);
  else
    fprintf (stderr, "Cannot connect to X server %s\n",
    XDisplayName ((char*) NULL));

  return (call_thedisplay == NULL);
}

/*RIC120302*/
Tint
call_tox_set_display (void *vdisplay)
{
  Display *pdisplay = (Display*) vdisplay;
  char synchro[132];

  if ( pdisplay ) {
    call_thedisplay = pdisplay;

    if (call_util_osd_getenv ("CALL_SYNCHRO_X", synchro, 132))
      XSynchronize (call_thedisplay, 1);
    else
      XSynchronize (call_thedisplay, 0);
  } else {
    fprintf (stderr, "Cannot connect to X server %s\n",
      XDisplayName ((char*) NULL));
  }
  return (call_thedisplay != NULL);
}
/*RIC120302*/

/*----------------------------------------------------------------------*/

void
call_tox_getscreen( Tint *d_wdth, Tint *d_hght )
{
  *d_wdth = DisplayWidth( call_thedisplay, DefaultScreen(call_thedisplay) );
  *d_hght = DisplayHeight( call_thedisplay, DefaultScreen(call_thedisplay) );
  return;
}

/*----------------------------------------------------------------------*/

Tfloat
call_tox_getpitchsize( )
{
  static float pitch_size = 0.;

  if( pitch_size == 0. ) {
    int width = DisplayWidth( call_thedisplay, DefaultScreen(call_thedisplay) );
    int height = DisplayHeight( call_thedisplay, DefaultScreen(call_thedisplay) );
    int mmwidth = DisplayWidthMM( call_thedisplay, DefaultScreen(call_thedisplay) );
    int mmheight = DisplayHeightMM( call_thedisplay, DefaultScreen(call_thedisplay) );
    pitch_size = ((float)mmwidth/width + (float)mmheight/height)/2.;
  }

  return pitch_size;
}

/*----------------------------------------------------------------------*/
#else
# include <windows.h>
# include <OpenGl_tgl_all.hxx>
# include <OpenGl_txgl.hxx>

DISPLAY* call_thedisplay = "DISPLAY";  /* Dummy for Windows NT */

Tint
call_tox_open_display ( void )
{
  return 1;
}

/*RIC120302*/
Tint
call_tox_set_display ( void* vdisplay)
{
  return 1;
}
/*RIC120302*/

void
call_tox_getscreen ( Tint *d_wdth, Tint *d_hght )
{
  *d_wdth = GetSystemMetrics(SM_CXSCREEN);
  *d_hght = GetSystemMetrics(SM_CYSCREEN);
  return;
}

#endif  /* WNT */