Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/atmospheric_engine/src/lib/graphics/shader.h @ 8180

Last change on this file since 8180 was 8176, checked in by amaechler, 19 years ago
File size: 2.0 KB
RevLine 
[4838]1/*!
[5261]2 * @file shader.h
3 * @brief Definition of the Shader rendering class
[3245]4*/
[1853]5
[5261]6#ifndef _SHADER_H
7#define _SHADER_H
[1853]8
[3543]9#include "base_object.h"
[5261]10#include "glincl.h"
[7164]11#include <vector>
[1853]12
[5261]13
14typedef enum
15{
16  SHADER_NONE       = 0,
17  SHADER_FRAGMENT   = 1,
18  SHADER_VERTEX     = 0,
19
20} SHADER_TYPE;
21
[4838]22// FORWARD DECLARATION
[3543]23
24
[3955]25//! A class for ...
[5261]26class Shader : public BaseObject {
[1853]27
[5323]28  public:
[7221]29  Shader(const std::string& vertexShaderFile = "", const std::string& fragmentShaderFile = "");
[5261]30  virtual ~Shader();
[7221]31  static Shader* getShader(const std::string& vertexShaderFile, const std::string& fragmentShaderFile);
[5323]32  static bool unload(Shader* shader);
[1853]33
[7221]34  bool loadShaderProgramm(SHADER_TYPE type, const std::string& fileName);
[5266]35  void activateShader();
[8176]36  void bindShader(const char* name, const float* value, size_t size);
[5266]37  static void deactivateShader();
[5262]38  void deleteProgram(SHADER_TYPE type);
[3245]39
[7221]40  char* fileRead(const std::string& fileName);
41  std::vector<char*>* fileReadArray(const std::string& fileName);
[5266]42
[5317]43  static bool checkShaderAbility();
44
[7195]45  inline static bool shaderActive() { return (Shader::storedShader != NULL)? true : false; };
[5323]46  inline static Shader* getActiveShader() { return Shader::storedShader; };
[5318]47  inline static void suspendShader() { Shader* currShader = storedShader; if (storedShader!= NULL) { Shader::deactivateShader(); Shader::storedShader = currShader;} };
[5317]48  inline static void restoreShader() { if (storedShader != NULL) storedShader->activateShader(); storedShader = NULL; };
49
[7785]50  GLhandleARB getProgram() { return this->shaderProgram; }
51  GLhandleARB getVertexS() { return this->vertexShader; }
52  GLhandleARB getFragmentS() { return this->fragmentShader; }
[5317]53
[5319]54  void printError(GLhandleARB program);
[5262]55  void debug() const;
56
57  private:
58
[3245]59 private:
[7221]60   std::string            fragmentShaderFile;
61   std::string            vertexShaderFile;
[5319]62   GLhandleARB            shaderProgram;
63   GLhandleARB            vertexShader;
64   GLhandleARB            fragmentShader;
[5317]65
66   static Shader*         storedShader;
[1853]67};
68
[5261]69#endif /* _SHADER_H */
Note: See TracBrowser for help on using the repository browser.