Support Forum       G3D Web Page     
Classes | Namespaces | Macros
Shader.h File Reference

G3D Innovation Engine http://casual-effects.com/g3d Copyright 2000-2019, Morgan McGuire All rights reserved Available under the BSD License. More...

Classes

class  G3D::Shader::ShaderProgram::AttributeDeclaration
 Vertex Attribute (stream) variable declaration discovered in the program. More...
 
class  G3D::Shader::PreprocessedShaderSource
 A structure containing the individual parts of the code of a load-time preprocessed (by g3d, not the driver) shader. More...
 
class  G3D::Shader
 Abstraction of the programmable hardware pipeline with G3D preprocessor extensions. More...
 
class  G3D::Shader::ShaderProgram
 A wrapper around an actual openGL shader program object. More...
 
class  G3D::Shader::Source
 Stores either a filename or a shader source string (that has not gone through the g3d preprocessor) for a single shader stage. More...
 
class  G3D::Shader::Specification
 Consists of up to one Shader::Source per shader stage. More...
 
class  G3D::Shader::ShaderProgram::UniformDeclaration
 Uniform variable declaration discovered in the program. More...
 

Namespaces

 G3D
 

Macros

#define G3D_gfx_Shader_h
 
#define LAUNCH_SHADER(pattern, args)
 Get a shader from the cache, loading it if necessary, and launch it on the current RenderDevice using args. More...
 
#define LAUNCH_SHADER_PTR(shader, args)
 Launch an already-loaded shader. More...
 
#define LAUNCH_SHADER_PTR_WITH_HINT(shader, args, hint)
 
#define LAUNCH_SHADER_WITH_HINT(pattern, args, hint)
 

Detailed Description

G3D Innovation Engine http://casual-effects.com/g3d Copyright 2000-2019, Morgan McGuire All rights reserved Available under the BSD License.

Macro Definition Documentation

◆ G3D_gfx_Shader_h

#define G3D_gfx_Shader_h

◆ LAUNCH_SHADER

#define LAUNCH_SHADER (   pattern,
  args 
)
Value:
{ \
LAUNCH_SHADER_WITH_HINT(pattern, args, "") \
}

Get a shader from the cache, loading it if necessary, and launch it on the current RenderDevice using args.

Avoids much of the boilerplate of declaring and initializing shader member variables.

The first argument is a pattern to match all source files for the shader. The pattern is first passed directly to G3D::System::findDataFile. If this fails, the pattern is searched for an underscore. If there is an underscore, everything up to the first underscore is used as a directory name. For example,

LAUNCH_SHADER("Film_foo.*", args)

first searches for files matching "Film_foo.*". If no files match, then the pattern "Film/Film_foo.*" is tried. The part of the pattern up to the first underscore is both the directory name and part of the filename.

It is an error if neither of the above two patterns matches any files. It is also an error if the first pattern doesn't match any files and the pattern begins with an underscore.

Note that the underlying G3D::Shader class and G3D::RenderDevice::apply call are available for usage scenarios that do not fit the common pattern.

// Example of use:
LAUNCH_SHADER("SVO_updateLevelIndexBuffer.*", args);
See also
LAUNCH_SHADER_PTR

◆ LAUNCH_SHADER_PTR

#define LAUNCH_SHADER_PTR (   shader,
  args 
)
Value:
{ \
LAUNCH_SHADER_PTR_WITH_HINT(shader, args, "") \
}

Launch an already-loaded shader.

LAUNCH_SHADER_PTR(m_shader, args);
See also
LAUNCH_SHADER

◆ LAUNCH_SHADER_PTR_WITH_HINT

#define LAUNCH_SHADER_PTR_WITH_HINT (   shader,
  args,
  hint 
)
Value:
{ \
const bool __shaderTimingsEnabled = G3D::Profiler::LAUNCH_SHADER_timingEnabled();\
if (__shaderTimingsEnabled) {\
G3D::Profiler::beginEvent(shader->name(), __FILE__, __LINE__, hint);\
}\
if (__shaderTimingsEnabled) {\
}\
}
static void beginEvent(const String &name, const String &file, int line, const String &hint="")
Calls to beginEvent may be nested on a single thread.
static thread_local RenderDevice * current
RenderDevice active on this thread, nullptr if there is not one.
Definition: RenderDevice.h:397
static void endEvent()
Ends the most recent pending event on the current thread.
static bool LAUNCH_SHADER_timingEnabled()
Whether to make profile events in every LAUNCH_SHADER call.
void apply(const shared_ptr< class Shader > &s, Args &args)

◆ LAUNCH_SHADER_WITH_HINT

#define LAUNCH_SHADER_WITH_HINT (   pattern,
  args,
  hint 
)
Value:
{\
static const shared_ptr<G3D::Shader> __theShader = G3D::Shader::getShaderFromPattern(pattern); \
const bool __shaderTimingsEnabled = G3D::Profiler::LAUNCH_SHADER_timingEnabled();\
if (__shaderTimingsEnabled) {\
G3D::Profiler::beginEvent(__theShader->name(), __FILE__, __LINE__, hint);\
}\
G3D::RenderDevice::current->apply(__theShader, (args)); \
if (__shaderTimingsEnabled) {\
}\
}
static void beginEvent(const String &name, const String &file, int line, const String &hint="")
Calls to beginEvent may be nested on a single thread.
static shared_ptr< Shader > getShaderFromPattern(const String &pattern)
Create a shader using all shaders specified by the given pattern.
static thread_local RenderDevice * current
RenderDevice active on this thread, nullptr if there is not one.
Definition: RenderDevice.h:397
static void endEvent()
Ends the most recent pending event on the current thread.
static bool LAUNCH_SHADER_timingEnabled()
Whether to make profile events in every LAUNCH_SHADER call.
void apply(const shared_ptr< class Shader > &s, Args &args)

documentation generated on Wed Nov 24 2021 08:01:51 using doxygen 1.8.15