Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5317 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
Oct 8, 2005, 11:43:09 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Shaders are now NOT renderen in 2D-mode.
After 2D-mode is left, the Shader will be reactivated

Location:
trunk/src/lib/graphics
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/render2D/render_2d.cc

    r5286 r5317  
    2222#include "list.h"
    2323#include "element_2d.h"
     24
     25#include "shader.h"
    2426
    2527#include <math.h>
     
    124126void Render2D::draw(unsigned int layer) const
    125127{
     128  Shader::suspendShader();
     129
    126130  GraphicsEngine::enter2DMode();
    127131
     
    146150  GraphicsEngine::leave2DMode();
    147151
     152  Shader::restoreShader();
    148153}
  • trunk/src/lib/graphics/shader.cc

    r5285 r5317  
    8181}
    8282
     83Shader* Shader::storedShader = NULL;
     84
    8385
    8486bool Shader::loadShaderProgramm(SHADER_TYPE type, const char* fileName)
     
    154156{
    155157  if (likely (this->shaderProgram != 0))
     158  {
    156159    glUseProgramObjectARB(this->shaderProgram);
     160    Shader::storedShader = this;
     161  }
    157162}
    158163
     
    160165{
    161166  glUseProgramObjectARB(0);
     167  Shader::storedShader = NULL;
    162168}
    163169
  • trunk/src/lib/graphics/shader.h

    r5266 r5317  
    3636  char* fileRead(const char* fileName);
    3737
     38  static bool checkShaderAbility();
     39
     40  inline static bool shaderActive() { return (Shader::storedShader != NULL)?true:false; };
     41  inline static void suspendShader() { Shader* currShader=storedShader; if (currShader!= NULL) { Shader::deactivateShader(); Shader::storedShader = currShader;} };
     42  inline static void restoreShader() { if (storedShader != NULL) storedShader->activateShader(); storedShader = NULL; };
     43
     44
    3845  void printError(GLenum program);
    3946  void debug() const;
     
    4754   GLenum                 vertexShader;
    4855   GLenum                 fragmentShader;
     56
     57   static Shader*         storedShader;
    4958};
    5059
Note: See TracChangeset for help on using the changeset viewer.