Implements missing Image::loadData cases.

TRAC #22347 Author: Shannon Woods Signed-off-by: Geoff Lang Signed-off-by: Daniel Koch git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1675 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 5dd4502f
......@@ -45,6 +45,20 @@ void Image::loadAlphaDataToBGRA(GLsizei width, GLsizei height,
}
}
void Image::loadAlphaDataToNative(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output)
{
const unsigned char *source = NULL;
unsigned char *dest = NULL;
for (int y = 0; y < height; y++)
{
source = static_cast<const unsigned char*>(input) + y * inputPitch;
dest = static_cast<unsigned char*>(output) + y * outputPitch;
memcpy(dest, source, width);
}
}
void Image::loadAlphaFloatDataToRGBA(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output)
{
......@@ -133,6 +147,25 @@ void Image::loadLuminanceFloatDataToRGBA(GLsizei width, GLsizei height,
}
}
void Image::loadLuminanceFloatDataToRGB(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output)
{
const float *source = NULL;
float *dest = NULL;
for (int y = 0; y < height; y++)
{
source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch);
dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputPitch);
for (int x = 0; x < width; x++)
{
dest[3 * x + 0] = source[x];
dest[3 * x + 1] = source[x];
dest[3 * x + 2] = source[x];
}
}
}
void Image::loadLuminanceHalfFloatDataToRGBA(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output)
{
......
......@@ -127,7 +127,7 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig
switch (mInternalFormat)
{
case GL_ALPHA8_EXT:
UNIMPLEMENTED(); // TODO - new function for D3D11-supported formats
loadAlphaDataToNative(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
break;
case GL_LUMINANCE8_EXT:
loadLuminanceDataToNativeOrBGRA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData, false);
......@@ -136,7 +136,7 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig
loadAlphaFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
break;
case GL_LUMINANCE32F_EXT:
UNIMPLEMENTED(); // TODO - new function for D3D11-supported formats
loadLuminanceFloatDataToRGB(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
break;
case GL_ALPHA16F_EXT:
loadAlphaHalfFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment