Back

OglTexture

sofa::gl::component::shader::OglTexture
VisualModel
Doc (from source)

Load a texture to be used in a shader. Defines an uniform sampler (texture) for a OglShader. This is an abstract class which passes a texture id to an uniform sampler variable defined into the shader and load the image into OpenGL. At the moment, only texture2D is supported.

Abstract (AI generated)

The `OglTexture` component manages texture loading and manipulation for use in OpenGL shaders, supporting configuration options such as interpolation methods, mipmaps generation, and repeat mode.

Metadata
module
Sofa.GL.Component.Shader
namespace
sofa::gl::component::shader
include
sofa/gl/component/shader/OglTexture.h
inherits
  • VisualModel
description

The OglTexture class in the SOFA framework is primarily concerned with graphical visualization rather than physical or mechanical simulation. It serves as an abstract base class for managing textures used within shaders and does not directly contribute to any governing equations, constitutive laws, or kinematic models relevant to computational mechanics or the Finite Element Method (FEM). Instead, it provides functionality for loading and manipulating textures that can be bound to shader uniforms in OpenGL, facilitating textural details in graphical representations. The component supports texture2D and offers various configuration options such as interpolation methods, mipmaps generation, and texture parameters like repeat mode. It interacts with the OpenGL rendering pipeline through methods related to binding and unbinding textures and integrates with SOFA's visualization system via inheritance from VisualModel.

Data Fields
NameTypeDefaultHelp
textureUnit unsigned short Set the texture unit
enabled bool enabled ?
repeat bool Repeat Texture ?
linearInterpolation bool Interpolate Texture ?
generateMipmaps bool Generate mipmaps ?
srgbColorspace bool SRGB colorspace ?
minLod float Minimum mipmap lod ?
maxLod float Maximum mipmap lod ?
proceduralTextureWidth unsigned int Width of procedural Texture
proceduralTextureHeight unsigned int Height of procedural Texture
proceduralTextureNbBits unsigned int Nb bits per color
Methods
void init () virtual
void doInitVisual (const core::visual::VisualParams * vparams) virtual
void reinit () virtual
void fwdDraw (core::visual::VisualParams * ) virtual
void bwdDraw (core::visual::VisualParams * ) virtual
int getTextureName ()
unsigned short getTextureUnit ()
void bind ()
void unbind ()
void setActiveTexture (unsigned short unit)
ShaderElementType getSEType () virtual
const core::objectmodel::BaseData * getSEValue () virtual
{
  "name": "OglTexture",
  "namespace": "sofa::gl::component::shader",
  "module": "Sofa.GL.Component.Shader",
  "include": "sofa/gl/component/shader/OglTexture.h",
  "doc": "Load a texture to be used in a shader.\n\nDefines an uniform sampler (texture) for a OglShader.\n This is an abstract class which passes a texture id to an uniform\n sampler variable defined into the shader and load the image into OpenGL.\n At the moment, only texture2D is supported.",
  "inherits": [
    "VisualModel"
  ],
  "templates": [],
  "data_fields": [
    {
      "name": "textureUnit",
      "type": "unsigned short",
      "xmlname": "textureUnit",
      "help": "Set the texture unit"
    },
    {
      "name": "enabled",
      "type": "bool",
      "xmlname": "enabled",
      "help": "enabled ?"
    },
    {
      "name": "repeat",
      "type": "bool",
      "xmlname": "repeat",
      "help": "Repeat Texture ?"
    },
    {
      "name": "linearInterpolation",
      "type": "bool",
      "xmlname": "linearInterpolation",
      "help": "Interpolate Texture ?"
    },
    {
      "name": "generateMipmaps",
      "type": "bool",
      "xmlname": "generateMipmaps",
      "help": "Generate mipmaps ?"
    },
    {
      "name": "srgbColorspace",
      "type": "bool",
      "xmlname": "srgbColorspace",
      "help": "SRGB colorspace ?"
    },
    {
      "name": "minLod",
      "type": "float",
      "xmlname": "minLod",
      "help": "Minimum mipmap lod ?"
    },
    {
      "name": "maxLod",
      "type": "float",
      "xmlname": "maxLod",
      "help": "Maximum mipmap lod ?"
    },
    {
      "name": "proceduralTextureWidth",
      "type": "unsigned int",
      "xmlname": "proceduralTextureWidth",
      "help": "Width of procedural Texture"
    },
    {
      "name": "proceduralTextureHeight",
      "type": "unsigned int",
      "xmlname": "proceduralTextureHeight",
      "help": "Height of procedural Texture"
    },
    {
      "name": "proceduralTextureNbBits",
      "type": "unsigned int",
      "xmlname": "proceduralTextureNbBits",
      "help": "Nb bits per color"
    }
  ],
  "links": [],
  "methods": [
    {
      "name": "init",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "doInitVisual",
      "return_type": "void",
      "params": [
        {
          "name": "vparams",
          "type": "const core::visual::VisualParams *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "reinit",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "fwdDraw",
      "return_type": "void",
      "params": [
        {
          "name": "",
          "type": "core::visual::VisualParams *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "bwdDraw",
      "return_type": "void",
      "params": [
        {
          "name": "",
          "type": "core::visual::VisualParams *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getTextureName",
      "return_type": "int",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getTextureUnit",
      "return_type": "unsigned short",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "bind",
      "return_type": "void",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "unbind",
      "return_type": "void",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setActiveTexture",
      "return_type": "void",
      "params": [
        {
          "name": "unit",
          "type": "unsigned short"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": true,
      "access": "public"
    },
    {
      "name": "getSEType",
      "return_type": "ShaderElementType",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getSEValue",
      "return_type": "const core::objectmodel::BaseData *",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    }
  ],
  "description": "The `OglTexture` class in the SOFA framework is part of the visualization system and belongs to the `sofa::gl::component::shader` namespace. It serves as an abstract base class for loading and managing textures that can be used within shaders. Specifically, it provides a mechanism to define uniform sampler (texture) variables in OpenGL shaders and load image data into these textures. At present, only texture2D is supported.\n\n**Role and Purpose:**\nThe `OglTexture` component facilitates the integration of textural details into graphical representations within SOFA simulations by providing hooks for loading and manipulating textures that can be bound to shader uniforms. It supports various configuration options such as interpolation methods, mipmaps generation, and texture parameters like repeat mode.\n\n**Interactions with Other Components:**\nThe `OglTexture` interacts primarily with the OpenGL rendering pipeline through its methods related to binding and unbinding textures. Additionally, it integrates with the broader SOFA visualization system via inheritance from `VisualModel`, which is part of the core visualization infrastructure. The component provides methods like `getSEType()` and `getSEValue()`, enabling interaction with other shader elements within a simulation.\n\n**Practical Usage Guidance:**\nThe `OglTexture` has several configurable data fields:\n- **textureUnit**: Specifies the texture unit to which this texture is bound (type: unsigned short).\n- **enabled**: Toggles whether the texture should be enabled for use in shaders (type: bool).\n- **repeat**: Determines if the texture should repeat beyond its bounds (type: bool).\n- **linearInterpolation**: Enables linear interpolation between pixels (type: bool).\n- **generateMipmaps**: Specifies whether mipmaps are to be generated for this texture (type: bool).\n- **srgbColorspace**: Indicates if the color space of the texture is sRGB (type: bool).\n- **minLod** and **maxLod**: Set the minimum and maximum levels-of-detail for mipmapping (types: float).\n- **proceduralTextureWidth**, **proceduralTextureHeight**, and **proceduralTextureNbBits**: Configure dimensions and bit depth of procedural textures (types: unsigned int).\n\nThese fields allow users to customize how a texture behaves in the rendering pipeline, including appearance settings like interpolation and mipmap generation. Methods such as `bind()` and `unbind()` are crucial for managing the context within which textures are active during shader execution.",
  "maths": "The `OglTexture` class in the SOFA framework is primarily concerned with graphical visualization rather than physical or mechanical simulation. It serves as an abstract base class for managing textures used within shaders and does not directly contribute to any governing equations, constitutive laws, or kinematic models relevant to computational mechanics or the Finite Element Method (FEM). Instead, it provides functionality for loading and manipulating textures that can be bound to shader uniforms in OpenGL, facilitating textural details in graphical representations. The component supports texture2D and offers various configuration options such as interpolation methods, mipmaps generation, and texture parameters like repeat mode. It interacts with the OpenGL rendering pipeline through methods related to binding and unbinding textures and integrates with SOFA's visualization system via inheritance from `VisualModel`.",
  "abstract": "The `OglTexture` component manages texture loading and manipulation for use in OpenGL shaders, supporting configuration options such as interpolation methods, mipmaps generation, and repeat mode.",
  "sheet": "# OglTexture\n\n**Overview**\n\nThe `OglTexture` is an abstract base class within the SOFA framework that facilitates the integration of textures into graphical representations by defining uniform sampler variables in OpenGL shaders. It supports texture2D and provides methods for binding, unbinding, and managing texture parameters.\n\n**Parameters and Data**\n\n- **textureUnit**: Specifies the texture unit to which this texture is bound (type: unsigned short).\n- **enabled**: Toggles whether the texture should be enabled for use in shaders (type: bool).\n- **repeat**: Determines if the texture should repeat beyond its bounds (type: bool).\n- **linearInterpolation**: Enables linear interpolation between pixels (type: bool).\n- **generateMipmaps**: Specifies whether mipmaps are to be generated for this texture (type: bool).\n- **srgbColorspace**: Indicates if the color space of the texture is sRGB (type: bool).\n- **minLod** and **maxLod**: Set the minimum and maximum levels-of-detail for mipmapping (types: float).\n- **proceduralTextureWidth**, **proceduralTextureHeight**, and **proceduralTextureNbBits**: Configure dimensions and bit depth of procedural textures (types: unsigned int).\n\n**Dependencies and Connections**\n\nThe `OglTexture` component integrates with the OpenGL rendering pipeline through methods related to binding and unbinding textures. It also interacts with SOFA's visualization system via inheritance from `VisualModel`, enabling interaction with other shader elements within a simulation."
}