SCM Library
Spherical Cube Map rendering library
 All Classes Files Functions Variables Friends Pages
scm-label.hpp
1 // Copyright (C) 2011-2012 Robert Kooima
2 //
3 // LIBSCM is free software; you can redistribute it and/or modify it under the
4 // terms of the GNU General Public License as published by the Free Software
5 // Foundation; either version 2 of the License, or (at your option) any later
6 // version.
7 //
8 // This program is distributed in the hope that it will be useful, but WITH-
9 // OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 // more details.
12 
13 #ifndef SCM_LABEL_HPP
14 #define SCM_LABEL_HPP
15 
16 #include <string>
17 #include <vector>
18 
19 #include <GL/glew.h>
20 
21 #include "util3d/type.h"
22 #include "util3d/glsl.h"
23 
24 //-----------------------------------------------------------------------------
25 
51 
52 class scm_label
53 {
54 public:
55 
56  scm_label(const std::string&, int);
57  ~scm_label();
58 
59  void draw(GLubyte r, GLubyte g, GLubyte b, GLubyte a);
60 
61 private:
62 
63  static const int strmax = 64;
64 
65  struct label
66  {
67  char str[strmax];
68  float lat;
69  float lon;
70  float dia;
71  float rad;
72  char typ[2];
73 
74  bool circle() const {
75  return ((typ[0] == 'A' && typ[1] == 'A')
76  || (typ[0] == 'S' && typ[1] == 'F'));
77  }
78  bool sprite() const {
79  return ((typ[0] == 'L' && typ[1] == 'F')
80  || (typ[0] == 'M' && typ[1] == 'O')
81  || (typ[0] == '@' && typ[1] == '*')
82  || (typ[0] == '@' && typ[1] == 'C'));
83  }
84  bool latlon() const {
85  return ((typ[0] == '@' && typ[1] == '#'));
86  }
87  };
88 
89  int scan (FILE *, label&);
90  void parse(const std::string&);
91  void apply(label *);
92 
93  font *label_font;
94  line *label_line;
95 
96  int num_circles;
97  int num_sprites;
98  int num_latlons;
99  int sprite_size;
100 
101  glsl circle_glsl;
102  glsl sprite_glsl;
103 
104  GLuint circle_vbo;
105  GLuint sprite_vbo;
106  GLuint latlon_vbo;
107  GLuint sprite_tex;
108 
109  std::vector<label> labels;
110 };
111 
112 //-----------------------------------------------------------------------------
113 
114 #endif
An scm_label renders annotations on the sphere.
Definition: scm-label.hpp:52
scm_label(const std::string &, int)
Create a new label.
Definition: scm-label.cpp:229
~scm_label()
Finalize all OpenGL state.
Definition: scm-label.cpp:374
void draw(GLubyte r, GLubyte g, GLubyte b, GLubyte a)
Draw all annotations using the given color and transparency.
Definition: scm-label.cpp:398