VIZ++ Class: OpenGLFog

 VIZ++ Class Library  VIZ++ Samples  VIZ++ ClassTree 

Source code

/*
 * OpenGLFog.h 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */



#pragma once

#include <viz++/Exception.h>
#include <viz++/opengl/OpenGLObject.h>
#include <math.h>

namespace VIZ {

class OpenGLFog :public OpenGLObject {
 
public:
  OpenGLFog()
  :OpenGLObject()
  {
    glEnable(GL_FOG);
  } 

  ~OpenGLFog()
  {
    glDisable(GL_FOG);
  }
 
  //mode = GL_LINEARr, AGL_EXP, AGL_EXP2 
  void mode(GLfloat mode = GL_LINEAR)
  {
    glFogi(GL_FOG_MODE, mode);
  }

  void density(GLfloat value)
  {
    glFogf(GL_FOG_DENSITY, value);
  }

  //Specify start position for GL_LINEAR mode
  void start(GLfloat value)
  {
    glFogf(GL_FOG_START, value);
  }
  
  //Specify end position for GL_LINEAR mode
  void end(GLfloat value)
  {
    glFogf(GL_FOG_END, value);
  }
  
  //Specify color index
  void index(GLfloat value)
  {
    glFogf(GL_FOG_INDEX, value);    
  }
  
  //Specify color index
  void color(GLfloat* value)
  {
    assert(value);
    glFogfv(GL_FOG_COLOR, value);    
  }

  void color(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
  {
    GLfloat value[] = {r, g, b, a};
    glFogfv(GL_FOG_COLOR, value);
  }

  void color(GLint* value)
  {
    assert(value);
    glFogiv(GL_FOG_COLOR, value);
  }
};
}


Last modified: 10 Feb 2017

Copyright (c) 2009-2017 Antillia.com ALL RIGHTS RESERVED.