libosmscout 1.1.1
Loading...
Searching...
No Matches
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
24
26
27#include <cassert>
28
29#include <GL/glew.h>
30
31namespace osmscout {
32
34 // TODO: add support for inclination
35 public:
36 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
#define OSMSCOUT_MAP_OPENGL_API
Definition MapOpenGLImportExport.h:45
double scaledLatDeriv
center scaled by gradtorad * scale
Definition MercatorProjection.h:53
double scale
Definition MercatorProjection.h:50
bool useLinearInterpolation
switch to enable linear interpolation of latitude to pixel computation
Definition MercatorProjection.h:55
double angleNegCos
Definition MercatorProjection.h:48
double latOffset
Absolute and untransformed screen position of lat coordinate.
Definition MercatorProjection.h:44
double scaleGradtorad
Precalculated scale*Gradtorad.
Definition MercatorProjection.h:51
double angleNegSin
Definition MercatorProjection.h:47
bool valid
projection is valid
Definition MercatorProjection.h:42
OpenGLProjection(OpenGLProjection &&)=default
OpenGLProjection(const OpenGLProjection &)=default
OpenGLProjection & operator=(OpenGLProjection &&)=default
OpenGLProjection & operator=(const OpenGLProjection &)=default
~OpenGLProjection() override=default
void SetShaderUniforms(GLuint shaderProgram) const
Definition OpenGLProjection.h:47
GeoCoord center
Coordinate of the center of the displayed area.
Definition Projection.h:48
size_t width
Width of image.
Definition Projection.h:52
size_t height
Height of image.
Definition Projection.h:53
double angle
Display rotation angle in radians, canvas clockwise.
Definition Projection.h:49
Definition Area.h:39