GteGLSLProgramFactory.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
11 #include <Graphics/GL4/GteOpenGL.h>
12 
13 namespace gte
14 {
15 
17 {
18 public:
19  // The 'defaultVersion' can be set once on application initialization if
20  // you want a GLSL version different from our default when constructing a
21  // program factory.
22  static std::string defaultVersion; // "#version 430"
23  static std::string defaultVSEntry; // "main"
24  static std::string defaultPSEntry; // "main"
25  static std::string defaultGSEntry; // "main"
26  static std::string defaultCSEntry; // "main"
27  static unsigned int defaultFlags; // 0
28 
29  // Construction. The 'version' member is set to 'defaultVersion'. The
30  // 'defines' are empty.
32 
33  // The returned value is used as a lookup index into arrays of strings
34  // corresponding to shader programs.
35  inline virtual int GetAPI() const override;
36 
37  // GLSLVisualProgram and GLSLComputeProgram objects are responsible
38  // for destroying the shaders and program. The factory wraps the
39  // program objects as shared pointers to allow automatic clean-up.
40 
41 private:
42  // Create a program for GPU display. This program is associated with the
43  // active GL4Engine object. The returned program is valid only when the
44  // program handle is positive. The files are loaded, converted to
45  // strings, and passed to CreateFromNamedSources. The filenames are
46  // passed as the 'xsName' parameters in case the shader compiler needs
47  // this for #include path searches.
48  virtual std::shared_ptr<VisualProgram> CreateFromNamedSources(
49  std::string const& vsName, std::string const& vsSource,
50  std::string const& psName, std::string const& psSource,
51  std::string const& gsName, std::string const& gsSource) override;
52 
53  // Create a program for GPU computing. This program is associated with
54  // the active GL4Engine object. The returned program is valid only when
55  // the program handle is positive. The file is loaded, converted to
56  // a string, and passed to CreateFromNamedSource. The filename is passed
57  // as the 'csName' parameters in case the shader compiler needs this for
58  // #include path searches.
59  virtual std::shared_ptr<ComputeProgram> CreateFromNamedSource(
60  std::string const& csName, std::string const& csSource) override;
61 
62  GLuint Compile(GLenum shaderType, std::string const& source);
63  bool Link(GLuint programHandle);
64 };
65 
66 inline int GLSLProgramFactory::GetAPI() const
67 {
68  return PF_GLSL;
69 }
70 
71 }
unsigned int GLuint
Definition: glcorearb.h:89
static std::string defaultCSEntry
static std::string defaultGSEntry
static std::string defaultVSEntry
unsigned int GLenum
Definition: glcorearb.h:83
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:798
GLsizei const GLchar *const * string
Definition: glcorearb.h:809
static unsigned int defaultFlags
static std::string defaultVersion
virtual int GetAPI() const override
static std::string defaultPSEntry
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:00