File: SNAPOpenGL.cxx

package info (click to toggle)
itksnap 3.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 10,196 kB
  • ctags: 9,196
  • sloc: cpp: 62,895; sh: 175; makefile: 13
file content (73 lines) | stat: -rw-r--r-- 1,340 bytes parent folder | download | duplicates (2)
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
#include "SNAPOpenGL.h"
#include <vnl/vnl_math.h>
#include <vector>

void
gl_draw_circle_with_border(double x, double y, double r,
                           int vp_width, int vp_height,
                           Vector3ui color)
{
  static std::vector<double> cx, cy;
  if(cx.size() == 0)
    {
    for(double a = 0; a < 2 * vnl_math::pi - 1.0e-6; a += vnl_math::pi / 20)
      {
      cx.push_back(cos(a));
      cy.push_back(sin(a));
      }
    }

  glPushMatrix();
  glTranslated(x, y, 0.0);
  glScaled(1.2 / vp_width, 1.2 / vp_height, 1.0);

  glBegin(GL_TRIANGLE_FAN);
  glVertex2d(0, 0);
  for(size_t i = 0; i < cx.size(); i++)
    glVertex2d(r * cx[i], r * cy[i]);
  glVertex2d(r, 0);
  glEnd();

  glColor3ub(color(0), color(1), color(2));

  glBegin(GL_LINE_LOOP);
  for(size_t i = 0; i < cx.size(); i++)
    glVertex2d(r * cx[i], r * cy[i]);
  glEnd();

  glPopMatrix();
}


#ifdef __APPLE__

#include <Availability.h>

#if __MAC_10_8

#include <GLKit/GLKMatrix4.h>

void irisOrtho2D(double x, double w, double y, double h)
{
  GLKMatrix4 matrix = GLKMatrix4MakeOrtho(x, w, y, h, -1, 1);
  glLoadMatrixf(matrix.m);
}

#else

void irisOrtho2D(double x, double w, double y, double h)
{
  gluOrtho2D(x,w,y,h);
}

#endif // APPLE

#else

void irisOrtho2D(double x, double w, double y, double h)
{
  gluOrtho2D(x,w,y,h);
}

#endif