Back to index

nux  3.0.0
Public Member Functions | Private Member Functions | Private Attributes | Friends
nux::GLTextureStates Class Reference

#include <GLTextureStates.h>

Collaboration diagram for nux::GLTextureStates:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 GLTextureStates (GLuint Type=GL_TEXTURE_2D)
 ~GLTextureStates ()
void ResetDefault ()
void ResetStateChangeToDefault ()
void SetRenderStates ()
void SetType (GLuint Type)
void SetFiltering (unsigned int MIN=GL_NEAREST, unsigned int MAG=GL_NEAREST)
void SetWrap (unsigned int U=GL_REPEAT, unsigned int V=GL_REPEAT, unsigned int W=GL_REPEAT)
void SetLOD (float MinLod=-1000.0f, float MaxLod=+1000.0f)
void SetMipLevel (unsigned int MinMip=0, unsigned int MaxMip=1000)
void SetBorderColor (float R, float G, float B, float A)

Private Member Functions

void HW_SetFiltering ()
void HW_SetWrap ()
void HW_SetLOD ()
void HW_SetMipLevel ()
void HW_SetBorderColor ()

Private Attributes

GLuint m_Type
TextureStateMap m_TextureStateChanges [GFXTS_MAX_TEXTURESTATES]

Friends

class GpuDevice

Detailed Description

Definition at line 66 of file GLTextureStates.h.


Constructor & Destructor Documentation

nux::GLTextureStates::GLTextureStates ( GLuint  Type = GL_TEXTURE_2D)

Definition at line 65 of file GLTextureStates.cpp.

Here is the call graph for this function:

Definition at line 71 of file GLTextureStates.cpp.

  {

  }

Member Function Documentation

Definition at line 184 of file GLTextureStates.cpp.

  {

  }

Definition at line 120 of file GLTextureStates.cpp.

  {
    if (m_TextureStateChanges[GFXTS_MINFILTER].Dirty || m_TextureStateChanges[GFXTS_MAGFILTER].Dirty)
    {
      CHECKGL(glTexParameteri(m_Type, GL_TEXTURE_MIN_FILTER,   m_TextureStateChanges[GFXTS_MINFILTER].iValue ));
      CHECKGL(glTexParameteri(m_Type, GL_TEXTURE_MAG_FILTER,   m_TextureStateChanges[GFXTS_MAGFILTER].iValue));
      m_TextureStateChanges[GFXTS_MINFILTER].Dirty = false;
      m_TextureStateChanges[GFXTS_MAGFILTER].Dirty = false;
    }
  }

Here is the caller graph for this function:

void nux::GLTextureStates::HW_SetLOD ( ) [private]

Definition at line 148 of file GLTextureStates.cpp.

  {
#ifndef NUX_OPENGLES_20
    if (m_Type == GL_TEXTURE_RECTANGLE_ARB)
    {
      // No support for mip LOP on rectangle texture.
      // ATI seems to not generate and Error.
      // Nvidia generates an error
      m_TextureStateChanges[GFXTS_MIN_LOD].Dirty = false;
      m_TextureStateChanges[GFXTS_MAX_LOD].Dirty = false;
      return;
    }

    if (m_TextureStateChanges[GFXTS_MIN_LOD].Dirty || m_TextureStateChanges[GFXTS_MAX_LOD].Dirty)
    {
      CHECKGL(glTexParameteri(m_Type, GL_TEXTURE_MIN_LOD,  m_TextureStateChanges[GFXTS_MIN_LOD].fValue));
      CHECKGL(glTexParameteri(m_Type, GL_TEXTURE_MAX_LOD,  m_TextureStateChanges[GFXTS_MAX_LOD].fValue));
      m_TextureStateChanges[GFXTS_MIN_LOD].Dirty = false;
      m_TextureStateChanges[GFXTS_MAX_LOD].Dirty = false;
    }
#endif
  }

Here is the caller graph for this function:

Definition at line 171 of file GLTextureStates.cpp.

  {
#ifndef NUX_OPENGLES_20
    if (m_TextureStateChanges[GFXTS_MIN_LOD].Dirty || m_TextureStateChanges[GFXTS_MAX_LOD].Dirty)
    {
      CHECKGL(glTexParameteri(m_Type, GL_TEXTURE_MIN_LOD,  m_TextureStateChanges[GFXTS_MIN_LOD].fValue));
      CHECKGL(glTexParameteri(m_Type, GL_TEXTURE_MAX_LOD,  m_TextureStateChanges[GFXTS_MAX_LOD].fValue));
      m_TextureStateChanges[GFXTS_MIN_LOD].Dirty = false;
      m_TextureStateChanges[GFXTS_MAX_LOD].Dirty = false;
    }
#endif
  }

Here is the caller graph for this function:

Definition at line 131 of file GLTextureStates.cpp.

  {
    if (m_TextureStateChanges[GFXTS_ADDRESSU].Dirty ||
        m_TextureStateChanges[GFXTS_ADDRESSV].Dirty ||
        m_TextureStateChanges[GFXTS_ADDRESSW].Dirty)
    {
      CHECKGL(glTexParameteri(m_Type, GL_TEXTURE_WRAP_S,       m_TextureStateChanges[GFXTS_ADDRESSU].iValue));
      CHECKGL(glTexParameteri(m_Type, GL_TEXTURE_WRAP_T,       m_TextureStateChanges[GFXTS_ADDRESSV].iValue));
#ifndef NUX_OPENGLES_20
      CHECKGL(glTexParameteri(m_Type, GL_TEXTURE_WRAP_R,       m_TextureStateChanges[GFXTS_ADDRESSW].iValue));
#endif
      m_TextureStateChanges[GFXTS_ADDRESSU].Dirty = false;
      m_TextureStateChanges[GFXTS_ADDRESSV].Dirty = false;
      m_TextureStateChanges[GFXTS_ADDRESSW].Dirty = false;
    }
  }

Here is the caller graph for this function:

Definition at line 95 of file GLTextureStates.cpp.

  {

  }

Definition at line 100 of file GLTextureStates.cpp.

  {

  }
void nux::GLTextureStates::SetBorderColor ( float  R,
float  G,
float  B,
float  A 
)

Definition at line 362 of file GLTextureStates.cpp.

  {
    unsigned int r, g, b, a;
    r = 255 * Clamp(R, 0.0f, 1.0f);
    g = 255 * Clamp(G, 0.0f, 1.0f);
    b = 255 * Clamp(B, 0.0f, 1.0f);
    a = 255 * Clamp(A, 0.0f, 1.0f);
    unsigned int color = (unsigned int) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b));

    SET_TS_VALUE(m_TextureStateChanges[GFXTS_BORDERCOLOR], color);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void nux::GLTextureStates::SetFiltering ( unsigned int  MIN = GL_NEAREST,
unsigned int  MAG = GL_NEAREST 
)

Definition at line 189 of file GLTextureStates.cpp.

  {
    nuxAssertMsg(
      (MinFilter == GL_LINEAR) ||
      (MinFilter == GL_NEAREST) ||
      (MinFilter == GL_NEAREST_MIPMAP_NEAREST) ||
      (MinFilter == GL_LINEAR_MIPMAP_NEAREST) ||
      (MinFilter == GL_NEAREST_MIPMAP_LINEAR) ||
      (MinFilter == GL_LINEAR_MIPMAP_LINEAR),
      "Error[GLTextureStates::SetFiltering]: Invalid MinFilter state");

    nuxAssertMsg(
      (MagFilter == GL_LINEAR) ||
      (MagFilter == GL_NEAREST),
      "Error[GLTextureStates::SetFiltering]: Invalid MagFilter state");

    //    nuxAssertMsg(
    //        (MIP == GL_LINEAR) ||
    //        (MIP == GL_NEAREST),
    //        "Error[GLTextureStates::SetFiltering]: Invalid Mipmap Filter State");

#ifndef NUX_OPENGLES_20
    if (m_Type == GL_TEXTURE_RECTANGLE_ARB)
    {
      if ((MinFilter != GL_NEAREST) && (MinFilter != GL_LINEAR))
      {
        nuxError("[GLTextureStates::SetFiltering] Incorrect MinFilter for rectangle texture.");
        SET_TS_VALUE(m_TextureStateChanges[GFXTS_MINFILTER], GL_LINEAR);
      }
      else
      {
        SET_TS_VALUE(m_TextureStateChanges[GFXTS_MINFILTER], MinFilter);
      }

      if ((MagFilter != GL_NEAREST) && (MagFilter != GL_LINEAR))
      {
        nuxError("[GLTextureStates::SetFiltering] Incorrect MagFilter for rectangle texture.");
        SET_TS_VALUE(m_TextureStateChanges[GFXTS_MAGFILTER], GL_LINEAR);
      }
      else
      {
        SET_TS_VALUE(m_TextureStateChanges[GFXTS_MAGFILTER], MagFilter);
      }
    }
    else
    {
      SET_TS_VALUE(m_TextureStateChanges[GFXTS_MINFILTER], MinFilter);
      SET_TS_VALUE(m_TextureStateChanges[GFXTS_MAGFILTER], MagFilter);
    }
#else
    SET_TS_VALUE(m_TextureStateChanges[GFXTS_MINFILTER], MinFilter);
    SET_TS_VALUE(m_TextureStateChanges[GFXTS_MAGFILTER], MagFilter);
#endif

    //SET_TS_VALUE(m_TextureStateChanges[GFXTS_MIPFILTER], MIP);
  }

Here is the caller graph for this function:

void nux::GLTextureStates::SetLOD ( float  MinLod = -1000.0f,
float  MaxLod = +1000.0f 
)

Definition at line 347 of file GLTextureStates.cpp.

Here is the caller graph for this function:

void nux::GLTextureStates::SetMipLevel ( unsigned int  MinMip = 0,
unsigned int  MaxMip = 1000 
)

Definition at line 354 of file GLTextureStates.cpp.

Here is the caller graph for this function:

Definition at line 105 of file GLTextureStates.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void nux::GLTextureStates::SetType ( GLuint  Type)

Definition at line 76 of file GLTextureStates.cpp.

  {
#ifndef NUX_OPENGLES_20
    nuxAssertMsg(
      (Type == GL_TEXTURE_1D) ||
      (Type == GL_TEXTURE_2D) ||
      (Type == GL_TEXTURE_RECTANGLE_ARB) ||
      (Type == GL_TEXTURE_3D) ||
      (Type == GL_TEXTURE_CUBE_MAP_ARB),
      "Error[GLTextureStates::GLTextureStates]: Invalid texture type.");
#else
    nuxAssertMsg(
      (Type == GL_TEXTURE_2D),
      "Error[GLTextureStates::GLTextureStates]: Invalid texture type.");
#endif

    m_Type = Type;
  }

Here is the caller graph for this function:

void nux::GLTextureStates::SetWrap ( unsigned int  U = GL_REPEAT,
unsigned int  V = GL_REPEAT,
unsigned int  W = GL_REPEAT 
)

Definition at line 249 of file GLTextureStates.cpp.

  {
#ifndef NUX_OPENGLES_20
    nuxAssertMsg(
      (U == GL_CLAMP) ||
      (U == GL_CLAMP_TO_EDGE) ||
      (U == GL_CLAMP_TO_BORDER) ||
      (U == GL_MIRRORED_REPEAT) ||
      (U == GL_MIRROR_CLAMP_EXT) ||
      (U == GL_MIRROR_CLAMP_TO_EDGE_EXT) ||
      (U == GL_MIRROR_CLAMP_TO_BORDER_EXT) ||
      (U == GL_REPEAT),
      "Error[GLTextureStates::SetWrap]: Invalid U Wrap State");

    nuxAssertMsg(
      (V == GL_CLAMP) ||
      (V == GL_CLAMP_TO_EDGE) ||
      (V == GL_CLAMP_TO_BORDER) ||
      (V == GL_MIRRORED_REPEAT) ||
      (V == GL_MIRROR_CLAMP_EXT) ||
      (V == GL_MIRROR_CLAMP_TO_EDGE_EXT) ||
      (V == GL_MIRROR_CLAMP_TO_BORDER_EXT) ||
      (V == GL_REPEAT),
      "Error[GLTextureStates::SetWrap]: Invalid V Wrap State");
    nuxAssertMsg(
      (W == GL_CLAMP) ||
      (W == GL_CLAMP_TO_EDGE) ||
      (W == GL_CLAMP_TO_BORDER) ||
      (W == GL_MIRRORED_REPEAT) ||
      (W == GL_MIRROR_CLAMP_EXT) ||
      (W == GL_MIRROR_CLAMP_TO_EDGE_EXT) ||
      (W == GL_MIRROR_CLAMP_TO_BORDER_EXT) ||
      (W == GL_REPEAT),
      "Error[GLTextureStates::SetWrap]: Invalid W Wrap State");

    if (m_Type == GL_TEXTURE_RECTANGLE_ARB)
    {
      if ((U != GL_CLAMP) && (U != GL_CLAMP_TO_BORDER) && (U != GL_CLAMP_TO_EDGE))
      {
        nuxError("[GLTextureStates::SetFiltering] Incorrect warp for rectangle texture.");
        SET_TS_VALUE(m_TextureStateChanges[GFXTS_ADDRESSU], GL_CLAMP_TO_EDGE);
      }
      else
      {
        SET_TS_VALUE(m_TextureStateChanges[GFXTS_ADDRESSU], U);
      }

      if ((V != GL_CLAMP) && (V != GL_CLAMP_TO_BORDER) && (V != GL_CLAMP_TO_EDGE))
      {
        nuxError("[GLTextureStates::SetFiltering] Incorrect warp for rectangle texture.");
        SET_TS_VALUE(m_TextureStateChanges[GFXTS_ADDRESSV], GL_CLAMP_TO_EDGE);
      }
      else
      {
        SET_TS_VALUE(m_TextureStateChanges[GFXTS_ADDRESSV], V);
      }

      if ((W != GL_CLAMP) && (W != GL_CLAMP_TO_BORDER) && (W != GL_CLAMP_TO_EDGE))
      {
        nuxError("[GLTextureStates::SetFiltering] Incorrect warp for rectangle texture.");
        SET_TS_VALUE(m_TextureStateChanges[GFXTS_ADDRESSW], GL_CLAMP_TO_EDGE);
      }
      else
      {
        SET_TS_VALUE(m_TextureStateChanges[GFXTS_ADDRESSW], W);
      }
    }
    else
    {
      SET_TS_VALUE(m_TextureStateChanges[GFXTS_ADDRESSU], U);
      SET_TS_VALUE(m_TextureStateChanges[GFXTS_ADDRESSV], V);
      SET_TS_VALUE(m_TextureStateChanges[GFXTS_ADDRESSW], W);
    }
#else
    nuxAssertMsg(
      (U == GL_CLAMP) ||
      (U == GL_CLAMP_TO_EDGE) ||
      (U == GL_CLAMP_TO_BORDER) ||
      (U == GL_MIRRORED_REPEAT) ||
      (U == GL_REPEAT),
      "Error[GLTextureStates::SetWrap]: Invalid U Wrap State");

    nuxAssertMsg(
      (V == GL_CLAMP) ||
      (V == GL_CLAMP_TO_EDGE) ||
      (V == GL_CLAMP_TO_BORDER) ||
      (V == GL_MIRRORED_REPEAT) ||
      (V == GL_REPEAT),
      "Error[GLTextureStates::SetWrap]: Invalid V Wrap State");

    SET_TS_VALUE(m_TextureStateChanges[GFXTS_ADDRESSU], U);
    SET_TS_VALUE(m_TextureStateChanges[GFXTS_ADDRESSV], V);
#endif
  }

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class GpuDevice [friend]

Definition at line 112 of file GLTextureStates.h.


Member Data Documentation

Definition at line 110 of file GLTextureStates.h.

GLuint nux::GLTextureStates::m_Type [private]

Definition at line 109 of file GLTextureStates.h.


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