Beatmup
Beatmup::GL::VertexShader Class Reference

GLSL vertex shader. More...

#include <program.h>

Inheritance diagram for Beatmup::GL::VertexShader:
Beatmup::GL::Shader

Public Member Functions

 VertexShader (const GraphicPipeline &gpu)
 
 VertexShader (const GraphicPipeline &gpu, const std::string &source, Extensions extensions=Extensions::NONE)
 
void compile (const GraphicPipeline &gpu, const std::string &source, Extensions extensions=Extensions::NONE)
 
- Public Member Functions inherited from Beatmup::GL::Shader
 ~Shader ()
 

Additional Inherited Members

- Protected Member Functions inherited from Beatmup::GL::Shader
 Shader (const GraphicPipeline &gpu, const uint32_t type)
 
handle_t getHandle () const
 
uint32_t getType () const
 
void compile (const GraphicPipeline &gpu, const char *source)
 

Detailed Description

GLSL vertex shader.

Definition at line 93 of file program.h.

Constructor & Destructor Documentation

◆ VertexShader() [1/2]

VertexShader::VertexShader ( const GraphicPipeline gpu)

Definition at line 75 of file program.cpp.

75  : Shader(gpu, GL_VERTEX_SHADER) {
76 }
Shader(const Shader &)=delete
disabling copying constructor

◆ VertexShader() [2/2]

Beatmup::GL::VertexShader::VertexShader ( const GraphicPipeline gpu,
const std::string &  source,
Extensions  extensions = Extensions::NONE 
)
inline

Definition at line 96 of file program.h.

96  : VertexShader(gpu)
97  {
98  compile(gpu, source.c_str(), extensions);
99  }
VertexShader(const GraphicPipeline &gpu)
Definition: program.cpp:75
void compile(const GraphicPipeline &gpu, const std::string &source, Extensions extensions=Extensions::NONE)
Definition: program.cpp:78

Member Function Documentation

◆ compile()

void VertexShader::compile ( const GraphicPipeline gpu,
const std::string &  source,
Extensions  extensions = Extensions::NONE 
)

Definition at line 78 of file program.cpp.

78  {
79  std::string src(source);
80  Extensions ext = extensions;
81  if (ext & Extensions::BEATMUP_DIALECT) {
83 
84  if (gpu.isGlEsCompliant())
85  if (gpu.getGlslVersion() == 100)
86  // ES 2.0 case
87  src = "#version 100\n"
88  "#line 0\n" + source;
89  else
90  // ES 3.0+
91  src = "#version 300 es\n"
92  "#define attribute in\n"
93  "#define varying out\n"
94  "#line 0\n" + source;
95  else
96  if (gpu.getGlslVersion() < 130)
97  // GLSL < 1.20 not supported; falling back to ES 2.0
98  src = "#version 100\n"
99  "#line 0\n" + source;
100  else
101  // 1.30+: capping at 1.30
102  src = "#version 130\n"
103  "#define attribute in\n"
104  "#define varying out\n"
105  "#line 0\n" + source;
106  }
107  if (ext & Extensions::EXTERNAL_TEXTURE) {
109  // nothing to do for this extension in the vertex shader
110  }
111  if (ext)
112  throw GL::GLException("Cannot interpret extensions set " + std::to_string(extensions));
113 
114  Shader::compile(gpu, src.c_str());
115 }
GPU exception.
Definition: bgl.h:56
void compile(const GraphicPipeline &gpu, const char *source)
Definition: program.cpp:50
int getGlslVersion() const
Returns GLSL language version supported by the GPU context being used.
Definition: pipeline.cpp:956
bool isGlEsCompliant() const
Returns true if the GPU context is OpenGL ES-compliant.
Definition: pipeline.cpp:961
Extensions
Supported OpenGL estensions.
Definition: program.h:63
@ BEATMUP_DIALECT
pseudo-extension enabling Beatmup GLSL dialect
Definition: program.h:65
@ EXTERNAL_TEXTURE
GL_OES_EGL_image_external_essl3 if available or GL_OES_EGL_image_external.
Definition: program.h:66
std::string to_string(Beatmup::NNets::ActivationFunction function)
return(jlong) new Beatmup jlong jstring src

The documentation for this class was generated from the following files: