Free Electron
opengl_headers.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __opengl_headers_h__
8 #define __opengl_headers_h__
9 
10 #if FE_OS==FE_WIN32 || FE_OS==FE_WIN64
11 #include "windows.h"
12 #include "winuser.h"
13 #include "gl/glew.h"
14 #include "gl/GL.h"
15 #include "gl/glu.h"
16 
17 namespace fe
18 {
19 //* TODO
20 inline float compute_dpi(void) { return float(0); }
21 inline float determine_multiplication(Real a_dpi) { return float(1); }
22 } // namespace
23 
24 #elif FE_OS==FE_LINUX
25 #include <GL/glx.h>
26 #include <GL/gl.h>
27 #include <GL/glu.h>
28 
29 namespace fe
30 {
31 inline float compute_dpi(void)
32 {
33  Display* pDisplayHandle=XOpenDisplay(NULL);
34  if(!pDisplayHandle)
35  {
36  return 0;
37  }
38 
39  Screen* pScreen=DefaultScreenOfDisplay(pDisplayHandle);
40  if(!pScreen)
41  {
42  XCloseDisplay(pDisplayHandle);
43  return 0;
44  }
45 
46  const int screenWidth=XWidthOfScreen(pScreen);
47  const int screenHeight=XHeightOfScreen(pScreen);
48 
49  const int screenWidthMM=XWidthMMOfScreen(pScreen);
50  const int screenHeightMM=XHeightMMOfScreen(pScreen);
51 
52  XCloseDisplay(pDisplayHandle);
53 
54  const float screenWidthInches=screenWidthMM/float(25.4);
55  const float screenHeightInches=screenHeightMM/float(25.4);
56 
57  const float dpiX=screenWidth/screenWidthInches;
58  const float dpiY=screenHeight/screenHeightInches;
59 
60 // fe_printf("dpi_multiplication"
61 // " screen %d %d size %.6G %.6G\n",
62 // screenWidth,screenHeight,
63 // screenWidthInches,screenHeightInches);
64 // fe_printf(" dpi %.6G %.6G\n",dpiX,dpiY);
65 
66  return 0.5*(dpiX+dpiY);
67 }
68 inline float determine_multiplication(Real a_dpi)
69 {
70  //* TODO tweak
71  return fe::maximum(1,int(a_dpi/100));
72 }
73 } // namespace
74 
75 
76 #elif FE_OS==FE_OSX
77 //#include <AGL/agl.h>
78 #include <GL/glx.h>
79 #include <OpenGL/gl.h>
80 #include <OpenGL/glu.h>
81 
82 namespace fe
83 {
84 //* TODO
85 inline float compute_dpi(void) { return float(0); }
86 inline float determine_multiplication(Real a_dpi) { return float(1); }
87 } // namespace
88 
89 #else
90 #error "platform not recognized"
91 #endif
92 
93 #endif /* __opengl_headers_h__ */
kernel
Definition: namespace.dox:3