Changeset View
Changeset View
Standalone View
Standalone View
source/renderer/backend/gl/DeviceCommandContext.cpp
Show First 20 Lines • Show All 222 Lines • ▼ Show 20 Lines | void CDeviceCommandContext::UploadTextureRegion( | ||||
ENSURE(destinationTexture); | ENSURE(destinationTexture); | ||||
CTexture* texture = destinationTexture->As<CTexture>(); | CTexture* texture = destinationTexture->As<CTexture>(); | ||||
ENSURE(width > 0 && height > 0); | ENSURE(width > 0 && height > 0); | ||||
if (texture->GetType() == CTexture::Type::TEXTURE_2D) | if (texture->GetType() == CTexture::Type::TEXTURE_2D) | ||||
{ | { | ||||
ENSURE(layer == 0); | ENSURE(layer == 0); | ||||
if (texture->GetFormat() == Format::R8G8B8A8_UNORM || | if (texture->GetFormat() == Format::R8G8B8A8_UNORM || | ||||
texture->GetFormat() == Format::R8G8B8_UNORM || | texture->GetFormat() == Format::R8G8B8_UNORM || | ||||
texture->GetFormat() == Format::R8_UNORM || | |||||
texture->GetFormat() == Format::A8_UNORM) | texture->GetFormat() == Format::A8_UNORM) | ||||
{ | { | ||||
ENSURE(texture->GetFormat() == dataFormat); | ENSURE(texture->GetFormat() == dataFormat); | ||||
size_t bytesPerPixel = 4; | size_t bytesPerPixel = 4; | ||||
GLenum pixelFormat = GL_RGBA; | GLenum pixelFormat = GL_RGBA; | ||||
switch (dataFormat) | switch (dataFormat) | ||||
{ | { | ||||
case Format::R8G8B8A8_UNORM: | case Format::R8G8B8A8_UNORM: | ||||
break; | break; | ||||
case Format::R8G8B8_UNORM: | case Format::R8G8B8_UNORM: | ||||
pixelFormat = GL_RGB; | pixelFormat = GL_RGB; | ||||
bytesPerPixel = 3; | bytesPerPixel = 3; | ||||
break; | break; | ||||
case Format::R8_UNORM: | |||||
pixelFormat = GL_RED; | |||||
bytesPerPixel = 1; | |||||
break; | |||||
case Format::A8_UNORM: | case Format::A8_UNORM: | ||||
pixelFormat = GL_ALPHA; | pixelFormat = GL_ALPHA; | ||||
bytesPerPixel = 1; | bytesPerPixel = 1; | ||||
break; | break; | ||||
case Format::L8_UNORM: | case Format::L8_UNORM: | ||||
pixelFormat = GL_LUMINANCE; | pixelFormat = GL_LUMINANCE; | ||||
bytesPerPixel = 1; | bytesPerPixel = 1; | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 868 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator