TriEngine  v0.0.16
General-purpose engine in C#/OpenGL
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
TriDevs.TriEngine.Shaders.Shader Class Reference

GLSL shader object loaded and compiled from a *.glsl shader file. More...

Inheritance diagram for TriDevs.TriEngine.Shaders.Shader:
[legend]
Collaboration diagram for TriDevs.TriEngine.Shaders.Shader:
[legend]

Public Member Functions

 Shader (string name, string file, ShaderType type)
 Creates a new shader from specified GLSL source file. More...
 
void Dispose ()
 

Static Public Member Functions

static string GetDefaultName (string file)
 Returns an auto-generated shader name based on the file name. More...
 

Public Attributes

readonly int ID
 ID of the shader compiled by OpenGL. More...
 

Properties

string Name [get]
 The name of this shader object. More...
 
string File [get]
 The file containing the source for this shader. More...
 
- Properties inherited from TriDevs.TriEngine.Resources.IResource
string Name [get]
 Gets the name associated with this resource. More...
 

Detailed Description

GLSL shader object loaded and compiled from a *.glsl shader file.

Constructor & Destructor Documentation

TriDevs.TriEngine.Shaders.Shader.Shader ( string  name,
string  file,
ShaderType  type 
)

Creates a new shader from specified GLSL source file.

Parameters
nameThe name to give to this shader, or null to let constructor auto-generate a name based on the file name.
fileGLSL source to use.
typeThe type of shader to create.
63  {
64  _file = file;
65  _name = name ?? GetDefaultName(_file);
66  ID = GL.CreateShader(type);
67  var source = System.IO.File.ReadAllText(_file);
68  GL.ShaderSource(ID, source);
69  GL.CompileShader(ID);
70  }

Member Function Documentation

void TriDevs.TriEngine.Shaders.Shader.Dispose ( )
83  {
84  GL.DeleteShader(ID);
85  }
static string TriDevs.TriEngine.Shaders.Shader.GetDefaultName ( string  file)
static

Returns an auto-generated shader name based on the file name.

Parameters
fileThe file name.
Returns
The auto-generated shader name.
78  {
79  return Path.GetFileNameWithoutExtension(file);
80  }

Member Data Documentation

readonly int TriDevs.TriEngine.Shaders.Shader.ID

ID of the shader compiled by OpenGL.

Property Documentation

string TriDevs.TriEngine.Shaders.Shader.File
get

The file containing the source for this shader.

string TriDevs.TriEngine.Shaders.Shader.Name
get

The name of this shader object.


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