Permalink
Browse files

Initial implementation for DoubleOpenGL30Plan

  • Loading branch information...
hombit committed Aug 2, 2018
1 parent 2a5eff5 commit b5010c90eda8027794a05b17f6e144656687f9f0
Showing with 46 additions and 1 deletion.
  1. +15 −0 include/openglplan.h
  2. +30 −0 src/openglplan.cpp
  3. +1 −1 src/openglplanfactory.cpp
View
@@ -179,6 +179,21 @@ class FloatOpenGL33Plan:
virtual QString fragmentShaderSourceCode() const override;
};
class DoubleOpenGL30Plan:
public AbstractOpenGL2Plan<DoubleOpenGL3Texture> {
private:
DoubleOpenGL30Plan(const FITS::HeaderDataUnit<FITS::DataUnit<double>>& hdu, const std::pair<double, double>& minmax);
public:
explicit DoubleOpenGL30Plan(const FITS::HeaderDataUnit<FITS::DataUnit<double>>& hdu);
virtual ~DoubleOpenGL30Plan() override = default;
constexpr static bool satisfied(const ::OpenGLFeatures& features) {
return OpenGLRequiredFeatures{}.requireOpenGL30().requireARB_gpu_shader_fp64().satisfied(features);
}
virtual QString fragmentShaderSourceCode() const override;
};
class DoubleOpenGL33Plan:
public AbstractOpenGL33Plan<DoubleOpenGL3Texture> {
private:
View
@@ -397,6 +397,35 @@ QString FloatOpenGL33Plan::fragmentShaderSourceCode() const {
return source;
}
DoubleOpenGL30Plan::DoubleOpenGL30Plan(const FITS::HeaderDataUnit<FITS::DataUnit<double>>& hdu, const std::pair<double, double>& minmax):
AbstractOpenGL2Plan<DoubleOpenGL3Texture>("float64-opengl3.0", hdu, minmax, minmax, 1, 0) {
}
DoubleOpenGL30Plan::DoubleOpenGL30Plan(const FITS::HeaderDataUnit<FITS::DataUnit<double>>& hdu):
DoubleOpenGL30Plan(hdu, makeMinMax(hdu)) {
}
QString DoubleOpenGL30Plan::fragmentShaderSourceCode() const {
static const QString source = R"(
#version 130
#extension GL_ARB_gpu_shader_fp64 : require
varying vec2 UV;
uniform usampler2D image_texture;
uniform sampler1D colormap;
uniform float c;
uniform float z;
void main() {
double raw_value = packDouble2x32(texture(image_texture, UV).gr);
double value = c * (raw_value - z);
gl_FragColor = texture(colormap, float(clamp(value, 0.0, 1.0)));
}
)";
return source;
}
DoubleOpenGL33Plan::DoubleOpenGL33Plan(const FITS::HeaderDataUnit<FITS::DataUnit<double>>& hdu, const std::pair<double, double>& minmax):
AbstractOpenGL33Plan<DoubleOpenGL3Texture>("float64-opengl3.3", hdu, minmax, minmax, 1, 0) {
}
@@ -415,6 +444,7 @@ QString DoubleOpenGL33Plan::fragmentShaderSourceCode() const {
uniform sampler1D colormap;
uniform float c;
uniform float z;
void main() {
double raw_value = packDouble2x32(texture(image_texture, UV).gr);
double value = c * (raw_value - z);
@@ -27,7 +27,7 @@ AbstractOpenGLPlan* OpenGLPlanFactory::operator() (const FITS::HeaderDataUnit<FI
}
AbstractOpenGLPlan* OpenGLPlanFactory::operator() (const FITS::HeaderDataUnit<FITS::DataUnit<double>>& hdu) const {
return resolveOpenGLPlan<DoubleOpenGL33Plan>(features_, hdu);
return resolveOpenGLPlan<DoubleOpenGL33Plan, DoubleOpenGL30Plan>(features_, hdu);
}
AbstractOpenGLPlan* OpenGLPlanFactory::operator() (const FITS::HeaderDataUnit<FITS::EmptyDataUnit>&) const {

0 comments on commit b5010c9

Please sign in to comment.