return GL_NONE;
}
}
+
+ static GLint DataType()
+ {
+ return GL_UNSIGNED_BYTE;
+ }
};
template<>
return GL_NONE;
}
}
+
+ static GLint DataType()
+ {
+ return GL_UNSIGNED_SHORT;
+ }
};
template<>
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.
class OpenGl_TextureFormat
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.
template<class T, int N>
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:
//! Creates new texture format.
OpenGl_TextureFormat (const GLint theChannels,
- const GLint theInternal)
+ const GLint theInternal,
+ const GLint theDataType)
: myInternal (theInternal),
- myChannels (theChannels) {}
+ myChannels (theChannels),
+ myDataType (theDataType) {}
private:
GLint myInternal; //!< OpenGL internal format of the pixel data
GLint myChannels; //!< Number of channels for each pixel (from 1 to 4)
+ GLint myDataType; //!< OpenGL data type of input pixel data
};