Panda3D
Public Types | Public Member Functions | Static Public Member Functions

Shader Class Reference

Inheritance diagram for Shader:
TypedReferenceCount TypedObject ReferenceCount MemoryBase MemoryBase

List of all members.

Public Types

enum  ShaderLanguage { SLNone = 0, SLCg = 1, SLGLSL = 2 }
enum  ShaderType { STNone = 0, STVertex = 1, STFragment = 2, STGeometry = 3 }

Public Member Functions

bool getErrorFlag ()
 Returns true if the shader contains a compile-time error.
Filename const getFilename (ShaderType type)
 Return the Shader's filename for the given shader type.
Filename const getFilename ()
 Return the Shader's filename for the given shader type.
ShaderLanguage getLanguage ()
 Returns the shader language in which this shader was written.
int getRefCount ()
 Returns the current reference count.
string getText ()
 Return the Shader's text for the given shader type.
string getText (ShaderType type)
 Return the Shader's text for the given shader type.
TypeHandle getType ()
int getTypeIndex ()
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.
bool isExactType (TypeHandle handle)
 Returns true if the current object is the indicated type exactly.
bool isOfType (TypeHandle handle)
 Returns true if the current object is or derives from the indicated type.
bool isPrepared (PreparedGraphicsObjects prepared_objects)
 Returns true if the shader has already been prepared or enqueued for preparation on the indicated GSG, false otherwise.
 prepare (PreparedGraphicsObjects prepared_objects)
 Indicates that the shader should be enqueued to be prepared in the indicated prepared_objects at the beginning of the next frame.
ShaderContext prepareNow (PreparedGraphicsObjects prepared_objects, GraphicsStateGuardianBase gsg)
 Creates a context for the shader on the particular GSG, if it does not already exist.
 ref ()
 Explicitly increments the reference count.
bool release (PreparedGraphicsObjects prepared_objects)
 Frees the texture context only on the indicated object, if it exists there.
int releaseAll ()
 Frees the context allocated on all objects for which the texture has been declared.
bool testRefCountIntegrity ()
 Does some easy checks to make sure that the reference count isn't completely bogus.
bool testRefCountNonzero ()
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus.
bool unref ()
 Explicitly decrements the reference count.

Static Public Member Functions

static TypeHandle getClassType ()
static ShaderUtilization getShaderUtilization ()
 This flag returns SUT_none, SUT_basic, or SUT_advanced and controls the automatic generation of shaders.
static bool haveShaderUtilization ()
 If true, then get_shader_utilization has been set using set_shader_utilization.
static Shader load (Filename const file)
 Loads the shader with the given filename.
static Shader load (ShaderLanguage lang, Filename const vertex, Filename const fragment)
 This variant of Shader.load loads all shader programs separately.
static Shader load (Filename const file, ShaderLanguage lang)
 Loads the shader with the given filename.
static Shader load (ShaderLanguage lang, Filename const vertex, Filename const fragment, Filename const geometry)
 This variant of Shader.load loads all shader programs separately.
static Shader make (ShaderLanguage lang, string vertex, string fragment)
 Loads the shader, using the strings as shader bodies.
static Shader make (ShaderLanguage lang, string vertex, string fragment, string geometry)
 Loads the shader, using the strings as shader bodies.
static Shader make (string body)
 Loads the shader, using the string as shader body.
static Shader make (string body, ShaderLanguage lang)
 Loads the shader, using the string as shader body.
static setShaderUtilization (ShaderUtilization utl)
 Set this flag to SUT_none, SUT_basic, or SUT_advanced to limit panda's automatic shader generation facilities.

Member Enumeration Documentation

Enumerator:
SLNone 
SLCg 
SLGLSL 
enum ShaderType
Enumerator:
STNone 
STVertex 
STFragment 
STGeometry 

Member Function Documentation

static TypeHandle getClassType ( ) [static]

Reimplemented from TypedReferenceCount.

bool getErrorFlag ( )

Returns true if the shader contains a compile-time error.

This doesn't tell you whether or not the shader is supported on the current video card.

Filename const getFilename ( )

Return the Shader's filename for the given shader type.

Filename const getFilename ( ShaderType  type)

Return the Shader's filename for the given shader type.

ShaderLanguage getLanguage ( )

Returns the shader language in which this shader was written.

int getRefCount ( ) [inherited]

Returns the current reference count.

static ShaderUtilization getShaderUtilization ( ) [static]

This flag returns SUT_none, SUT_basic, or SUT_advanced and controls the automatic generation of shaders.

It is initialized from the config variable of the same name, but it can be subsequently adjusted.

string getText ( ShaderType  type)

Return the Shader's text for the given shader type.

string getText ( )

Return the Shader's text for the given shader type.

TypeHandle getType ( ) [inherited]

Reimplemented in AnimChannelBase.

int getTypeIndex ( ) [inherited]

Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.

This is equivalent to get_type().get_index().

static bool haveShaderUtilization ( ) [static]

If true, then get_shader_utilization has been set using set_shader_utilization.

If false, then get_shader_utilization simply returns the config variable of the same name.

bool isExactType ( TypeHandle  handle) [inherited]

Returns true if the current object is the indicated type exactly.

bool isOfType ( TypeHandle  handle) [inherited]

Returns true if the current object is or derives from the indicated type.

bool isPrepared ( PreparedGraphicsObjects  prepared_objects)

Returns true if the shader has already been prepared or enqueued for preparation on the indicated GSG, false otherwise.

static Shader load ( ShaderLanguage  lang,
Filename const  vertex,
Filename const  fragment 
) [static]

This variant of Shader.load loads all shader programs separately.

static Shader load ( Filename const  file) [static]

Loads the shader with the given filename.

static Shader load ( ShaderLanguage  lang,
Filename const  vertex,
Filename const  fragment,
Filename const  geometry 
) [static]

This variant of Shader.load loads all shader programs separately.

static Shader load ( Filename const  file,
ShaderLanguage  lang 
) [static]

Loads the shader with the given filename.

static Shader make ( string  body) [static]

Loads the shader, using the string as shader body.

static Shader make ( ShaderLanguage  lang,
string  vertex,
string  fragment,
string  geometry 
) [static]

Loads the shader, using the strings as shader bodies.

static Shader make ( ShaderLanguage  lang,
string  vertex,
string  fragment 
) [static]

Loads the shader, using the strings as shader bodies.

static Shader make ( string  body,
ShaderLanguage  lang 
) [static]

Loads the shader, using the string as shader body.

prepare ( PreparedGraphicsObjects  prepared_objects)

Indicates that the shader should be enqueued to be prepared in the indicated prepared_objects at the beginning of the next frame.

This will ensure the texture is already loaded into texture memory if it is expected to be rendered soon.

Use this function instead of prepare_now() to preload textures from a user interface standpoint.

ShaderContext prepareNow ( PreparedGraphicsObjects  prepared_objects,
GraphicsStateGuardianBase  gsg 
)

Creates a context for the shader on the particular GSG, if it does not already exist.

Returns the new (or old) ShaderContext. This assumes that the GraphicsStateGuardian is the currently active rendering context and that it is ready to accept new textures. If this is not necessarily the case, you should use prepare() instead.

Normally, this is not called directly except by the GraphicsStateGuardian; a shader does not need to be explicitly prepared by the user before it may be rendered.

ref ( ) [inherited]

Explicitly increments the reference count.

User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.

This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

bool release ( PreparedGraphicsObjects  prepared_objects)

Frees the texture context only on the indicated object, if it exists there.

Returns true if it was released, false if it had not been prepared.

int releaseAll ( )

Frees the context allocated on all objects for which the texture has been declared.

Returns the number of contexts which have been freed.

static setShaderUtilization ( ShaderUtilization  utl) [static]

Set this flag to SUT_none, SUT_basic, or SUT_advanced to limit panda's automatic shader generation facilities.

bool testRefCountIntegrity ( ) [inherited]

Does some easy checks to make sure that the reference count isn't completely bogus.

Returns true if ok, false otherwise.

Reimplemented in NodeReferenceCount, CachedTypedWritableReferenceCount, and NodeCachedReferenceCount.

bool testRefCountNonzero ( ) [inherited]

Does some easy checks to make sure that the reference count isn't zero, or completely bogus.

Returns true if ok, false otherwise.

bool unref ( ) [inherited]

Explicitly decrements the reference count.

Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic.) However, see the helper function unref_delete().

User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.

This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

The return value is true if the new reference count is nonzero, false if it is zero.

Reimplemented in GeomVertexArrayFormat, and GeomVertexFormat.

 All Classes Namespaces Functions Variables Enumerations Enumerator Properties