clightman.h

来自「Ion Team Lord Of The Rings Demo 模拟指环王的3」· C头文件 代码 · 共 81 行

H
81
字号
/////////////////////////////////////////////////////////////////
//			This code was done by HiperBlaster
//			Takes care of the gl light parameters
//////////////////////////////////////////////////////////////////

class CLightMan
  {
  public:
    //CLightMan();	//constructor

    // self explainatory?
    void EnableLights()
    {
      glEnable(GL_LIGHTING);
    }
    void DisableLights()
    {
      glDisable(GL_LIGHTING);
    }

    //set's "light"'s position
    void SetPosition(GLenum light,float x,float y,float z, float fourth);

    // oh come on, the function name says it all ;)
    void SetDiffuseColor(GLenum light,float r,float g,float b, float fourth);
    void SetAmbientColor(GLenum light,float r,float g,float b, float fourth);

    void Enable(GLenum light)
    {
      glEnable(light);
    }
    void Disable(GLenum light)
    {
      glDisable(light);
    }

  private:
    float Array4f[4];	//very useful
  }LightManager;

/////////////////////////////////////////////////////////////////////////

void CLightMan::SetPosition(GLenum light,float x,float y,float z, float fourth=1.0f)
{
  Array4f[0]=x;
  Array4f[1]=y;
  Array4f[2]=z;
  Array4f[3]=fourth;

  glLightfv(light,GL_POSITION,Array4f);
  //glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER,temp);
}

//////////////////////////////////////////////////////////////////////////


void CLightMan::SetAmbientColor(GLenum light,float r,float g,float b, float fourth=1.0f)
{

  Array4f[0]=r;
  Array4f[1]=g;
  Array4f[2]=b;
  Array4f[3]=fourth;

  glLightfv(light,GL_AMBIENT,Array4f);

}

//////////////////////////////////////////////////////////////////////////

void CLightMan::SetDiffuseColor(GLenum light,float r,float g,float b,float fourth=1.0f)
{
  Array4f[0]=r;
  Array4f[1]=g;
  Array4f[2]=b;
  Array4f[3]=fourth;

  glLightfv(light,GL_DIFFUSE,Array4f);

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?