mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-16 10:08:36 +03:00
0026891: Visualization, TKOpenGl - define more texture types within OpenGl_TextureFormatSelector
This commit is contained in:
parent
95081657f1
commit
fbef84f9eb
@ -49,6 +49,11 @@ struct OpenGl_TextureFormatSelector<GLubyte>
|
|||||||
return GL_NONE;
|
return GL_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GLint DataType()
|
||||||
|
{
|
||||||
|
return GL_UNSIGNED_BYTE;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
@ -70,6 +75,11 @@ struct OpenGl_TextureFormatSelector<GLushort>
|
|||||||
return GL_NONE;
|
return GL_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GLint DataType()
|
||||||
|
{
|
||||||
|
return GL_UNSIGNED_SHORT;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
@ -91,8 +101,120 @@ struct OpenGl_TextureFormatSelector<GLfloat>
|
|||||||
return GL_NONE;
|
return GL_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GLint DataType()
|
||||||
|
{
|
||||||
|
return GL_FLOAT;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct OpenGl_TextureFormatSelector<GLuint>
|
||||||
|
{
|
||||||
|
static GLint Internal (GLuint theChannels)
|
||||||
|
{
|
||||||
|
switch (theChannels)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
return GL_RED;
|
||||||
|
case 2:
|
||||||
|
return GL_RG;
|
||||||
|
case 3:
|
||||||
|
return GL_RGB;
|
||||||
|
case 4:
|
||||||
|
return GL_RGBA;
|
||||||
|
default:
|
||||||
|
return GL_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static GLint DataType()
|
||||||
|
{
|
||||||
|
return GL_UNSIGNED_INT;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Only unsigned formats are available in OpenGL ES 2.0
|
||||||
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
|
template<>
|
||||||
|
struct OpenGl_TextureFormatSelector<GLbyte>
|
||||||
|
{
|
||||||
|
static GLint Internal (GLuint theChannels)
|
||||||
|
{
|
||||||
|
switch (theChannels)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
return GL_R8_SNORM;
|
||||||
|
case 2:
|
||||||
|
return GL_RG8_SNORM;
|
||||||
|
case 3:
|
||||||
|
return GL_RGB8_SNORM;
|
||||||
|
case 4:
|
||||||
|
return GL_RGBA8_SNORM;
|
||||||
|
default:
|
||||||
|
return GL_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static GLint DataType()
|
||||||
|
{
|
||||||
|
return GL_BYTE;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct OpenGl_TextureFormatSelector<GLshort>
|
||||||
|
{
|
||||||
|
static GLint Internal (GLuint theChannels)
|
||||||
|
{
|
||||||
|
switch (theChannels)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
return GL_R16_SNORM;
|
||||||
|
case 2:
|
||||||
|
return GL_RG16_SNORM;
|
||||||
|
case 3:
|
||||||
|
return GL_RGB16_SNORM;
|
||||||
|
case 4:
|
||||||
|
return GL_RGBA16_SNORM;
|
||||||
|
default:
|
||||||
|
return GL_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static GLint DataType()
|
||||||
|
{
|
||||||
|
return GL_SHORT;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct OpenGl_TextureFormatSelector<GLint>
|
||||||
|
{
|
||||||
|
static GLint Internal (GLuint theChannels)
|
||||||
|
{
|
||||||
|
switch (theChannels)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
return GL_RED_SNORM;
|
||||||
|
case 2:
|
||||||
|
return GL_RG_SNORM;
|
||||||
|
case 3:
|
||||||
|
return GL_RGB_SNORM;
|
||||||
|
case 4:
|
||||||
|
return GL_RGBA_SNORM;
|
||||||
|
default:
|
||||||
|
return GL_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static GLint DataType()
|
||||||
|
{
|
||||||
|
return GL_INT;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
//! Stores parameters of OpenGL texture format.
|
//! Stores parameters of OpenGL texture format.
|
||||||
class OpenGl_TextureFormat
|
class OpenGl_TextureFormat
|
||||||
{
|
{
|
||||||
@ -124,25 +246,36 @@ public:
|
|||||||
return myInternal;
|
return myInternal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Returns OpenGL data type of the pixel data.
|
||||||
|
inline GLint DataType() const
|
||||||
|
{
|
||||||
|
return myDataType;
|
||||||
|
}
|
||||||
|
|
||||||
//! Returns texture format for specified type and number of channels.
|
//! Returns texture format for specified type and number of channels.
|
||||||
template<class T, int N>
|
template<class T, int N>
|
||||||
static OpenGl_TextureFormat Create()
|
static OpenGl_TextureFormat Create()
|
||||||
{
|
{
|
||||||
return OpenGl_TextureFormat (N, OpenGl_TextureFormatSelector<T>::Internal (N));
|
return OpenGl_TextureFormat (N,
|
||||||
|
OpenGl_TextureFormatSelector<T>::Internal(N),
|
||||||
|
OpenGl_TextureFormatSelector<T>::DataType());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Creates new texture format.
|
//! Creates new texture format.
|
||||||
OpenGl_TextureFormat (const GLint theChannels,
|
OpenGl_TextureFormat (const GLint theChannels,
|
||||||
const GLint theInternal)
|
const GLint theInternal,
|
||||||
|
const GLint theDataType)
|
||||||
: myInternal (theInternal),
|
: myInternal (theInternal),
|
||||||
myChannels (theChannels) {}
|
myChannels (theChannels),
|
||||||
|
myDataType (theDataType) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
GLint myInternal; //!< OpenGL internal format of the pixel data
|
GLint myInternal; //!< OpenGL internal format of the pixel data
|
||||||
GLint myChannels; //!< Number of channels for each pixel (from 1 to 4)
|
GLint myChannels; //!< Number of channels for each pixel (from 1 to 4)
|
||||||
|
GLint myDataType; //!< OpenGL data type of input pixel data
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user