libosmscout
1.1.1
Toggle main menu visibility
Loading...
Searching...
No Matches
libosmscout-map-opengl
include
osmscoutmapopengl
OpenGLProjection.h
Go to the documentation of this file.
1
#ifndef LIBOSMSCOUT_OPENGLPROJECTION_H
2
#define LIBOSMSCOUT_OPENGLPROJECTION_H
3
4
/*
5
This source is part of the libosmscout-map library
6
Copyright (C) 2022 Lukas Karas
7
8
This library is free software; you can redistribute it and/or
9
modify it under the terms of the GNU Lesser General Public
10
License as published by the Free Software Foundation; either
11
version 2.1 of the License, or (at your option) any later version.
12
13
This library is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
Lesser General Public License for more details.
17
18
You should have received a copy of the GNU Lesser General Public
19
License along with this library; if not, write to the Free Software
20
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
*/
22
23
#include <
osmscoutmapopengl/MapOpenGLImportExport.h
>
24
25
#include <
osmscout/projection/MercatorProjection.h
>
26
27
#include <cassert>
28
29
#include <GL/glew.h>
30
31
namespace
osmscout
{
32
33
class
OSMSCOUT_MAP_OPENGL_API
OpenGLProjection
:
public
MercatorProjection
{
34
// TODO: add support for inclination
35
public
:
36
OpenGLProjection
() =
default
;
37
OpenGLProjection
(
const
OpenGLProjection
&) =
default
;
38
OpenGLProjection
(
OpenGLProjection
&&) =
default
;
39
OpenGLProjection
&
operator=
(
const
OpenGLProjection
&) =
default
;
40
OpenGLProjection
&
operator=
(
OpenGLProjection
&&) =
default
;
41
~OpenGLProjection
()
override
=
default
;
42
47
void
SetShaderUniforms
(GLuint shaderProgram)
const
48
{
49
assert(
valid
);
50
assert(
width
>0);
51
assert(
height
>0);
52
53
auto
SetGLf = [shaderProgram](
const
std::string_view& uniformName, GLfloat f) {
54
glUniform1f(glGetUniformLocation(shaderProgram, uniformName.data()), f);
55
};
56
auto
SetGLui = [shaderProgram](
const
std::string_view& uniformName, GLuint i) {
57
glUniform1ui(glGetUniformLocation(shaderProgram, uniformName.data()), i);
58
};
59
60
SetGLf(
"centerLat"
,
center
.GetLat());
61
SetGLf(
"centerLon"
,
center
.GetLon());
62
SetGLf(
"scaleGradtorad"
,
scaleGradtorad
);
63
SetGLui(
"useLinearInterpolation"
,
useLinearInterpolation
? 1 : 0);
64
SetGLf(
"scaledLatDeriv"
,
scaledLatDeriv
);
65
SetGLf(
"latOffset"
,
latOffset
);
66
SetGLf(
"scale"
,
scale
);
67
SetGLf(
"angle"
,
angle
);
68
SetGLf(
"angleNegSin"
,
angleNegSin
);
69
SetGLf(
"angleNegCos"
,
angleNegCos
);
70
SetGLf(
"windowHeight"
,
height
);
71
SetGLf(
"windowWidth"
,
width
);
72
}
73
};
74
}
75
76
#endif
//LIBOSMSCOUT_OPENGLPROJECTION_H
MapOpenGLImportExport.h
OSMSCOUT_MAP_OPENGL_API
#define OSMSCOUT_MAP_OPENGL_API
Definition
MapOpenGLImportExport.h:45
MercatorProjection.h
osmscout::MercatorProjection::MercatorProjection
MercatorProjection()=default
osmscout::MercatorProjection::scaledLatDeriv
double scaledLatDeriv
center scaled by gradtorad * scale
Definition
MercatorProjection.h:53
osmscout::MercatorProjection::scale
double scale
Definition
MercatorProjection.h:50
osmscout::MercatorProjection::useLinearInterpolation
bool useLinearInterpolation
switch to enable linear interpolation of latitude to pixel computation
Definition
MercatorProjection.h:55
osmscout::MercatorProjection::angleNegCos
double angleNegCos
Definition
MercatorProjection.h:48
osmscout::MercatorProjection::latOffset
double latOffset
Absolute and untransformed screen position of lat coordinate.
Definition
MercatorProjection.h:44
osmscout::MercatorProjection::scaleGradtorad
double scaleGradtorad
Precalculated scale*Gradtorad.
Definition
MercatorProjection.h:51
osmscout::MercatorProjection::angleNegSin
double angleNegSin
Definition
MercatorProjection.h:47
osmscout::MercatorProjection::valid
bool valid
projection is valid
Definition
MercatorProjection.h:42
osmscout::OpenGLProjection::OpenGLProjection
OpenGLProjection(OpenGLProjection &&)=default
osmscout::OpenGLProjection::OpenGLProjection
OpenGLProjection(const OpenGLProjection &)=default
osmscout::OpenGLProjection::operator=
OpenGLProjection & operator=(OpenGLProjection &&)=default
osmscout::OpenGLProjection::OpenGLProjection
OpenGLProjection()=default
osmscout::OpenGLProjection::operator=
OpenGLProjection & operator=(const OpenGLProjection &)=default
osmscout::OpenGLProjection::~OpenGLProjection
~OpenGLProjection() override=default
osmscout::OpenGLProjection::SetShaderUniforms
void SetShaderUniforms(GLuint shaderProgram) const
Definition
OpenGLProjection.h:47
osmscout::Projection::center
GeoCoord center
Coordinate of the center of the displayed area.
Definition
Projection.h:48
osmscout::Projection::width
size_t width
Width of image.
Definition
Projection.h:52
osmscout::Projection::height
size_t height
Height of image.
Definition
Projection.h:53
osmscout::Projection::angle
double angle
Display rotation angle in radians, canvas clockwise.
Definition
Projection.h:49
osmscout
Definition
Area.h:39
Generated by
1.17.0