Ensure that a surface is present before writing to it

TRAC #13595 This fixes a bug where glTexSubImage is called on a mipmapped texture before calling glTexImage. Signed-off-by: Daniel Koch git-svn-id: https://angleproject.googlecode.com/svn/trunk@434 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent ecd7cf35
...@@ -777,6 +777,13 @@ bool Texture::subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig ...@@ -777,6 +777,13 @@ bool Texture::subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig
return false; return false;
} }
if (!img->surface)
{
createSurface(img->width, img->height, format, type, img);
}
if (pixels != NULL && img->surface != NULL)
{
D3DLOCKED_RECT locked; D3DLOCKED_RECT locked;
HRESULT result = img->surface->LockRect(&locked, NULL, 0); HRESULT result = img->surface->LockRect(&locked, NULL, 0);
...@@ -789,6 +796,8 @@ bool Texture::subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig ...@@ -789,6 +796,8 @@ bool Texture::subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig
} }
img->dirty = true; img->dirty = true;
}
return true; return true;
} }
...@@ -806,6 +815,13 @@ bool Texture::subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GL ...@@ -806,6 +815,13 @@ bool Texture::subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GL
return false; return false;
} }
if (!img->surface)
{
createSurface(img->width, img->height, format, GL_UNSIGNED_BYTE, img);
}
if (pixels != NULL && img->surface != NULL)
{
RECT updateRegion; RECT updateRegion;
updateRegion.left = xoffset; updateRegion.left = xoffset;
updateRegion.right = xoffset + width; updateRegion.right = xoffset + width;
...@@ -829,6 +845,8 @@ bool Texture::subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GL ...@@ -829,6 +845,8 @@ bool Texture::subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GL
} }
img->dirty = true; img->dirty = true;
}
return true; return true;
} }
......
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