Fix broken test.

As-is, if the texture was too large for the target, an assertion would fail.
Now check proxy texture first and if it works, then test non-proxy target.
This commit is contained in:
Brian
2008-02-12 16:56:18 -07:00
parent edc7cfa6e6
commit 22ab7fa466

View File

@@ -113,44 +113,67 @@ static void Init( void )
minDim = imgWidth < imgHeight ? imgWidth : imgHeight; minDim = imgWidth < imgHeight ? imgWidth : imgHeight;
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, imgWidth, 0,
imgFormat, GL_UNSIGNED_BYTE, image);
assert(glGetError() == GL_NO_ERROR);
/*
* 1D Texture. Test proxy first, if that works, test non-proxy target.
*/
glTexImage1D(GL_PROXY_TEXTURE_1D, 0, GL_RGB, imgWidth, 0, glTexImage1D(GL_PROXY_TEXTURE_1D, 0, GL_RGB, imgWidth, 0,
imgFormat, GL_UNSIGNED_BYTE, image); imgFormat, GL_UNSIGNED_BYTE, image);
glGetTexLevelParameteriv(GL_PROXY_TEXTURE_1D, 0, GL_TEXTURE_WIDTH, &w); glGetTexLevelParameteriv(GL_PROXY_TEXTURE_1D, 0, GL_TEXTURE_WIDTH, &w);
assert(w == imgWidth); assert(w == imgWidth || w == 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, imgWidth, imgHeight, 0, if (w) {
imgFormat, GL_UNSIGNED_BYTE, image); glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, imgWidth, 0,
assert(glGetError() == GL_NO_ERROR); imgFormat, GL_UNSIGNED_BYTE, image);
assert(glGetError() == GL_NO_ERROR);
}
/*
* 2D Texture
*/
glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGB, imgWidth, imgHeight, 0, glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGB, imgWidth, imgHeight, 0,
imgFormat, GL_UNSIGNED_BYTE, image); imgFormat, GL_UNSIGNED_BYTE, image);
glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w); glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
assert(w == imgWidth); assert(w == imgWidth || w == 0);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, imgWidth, imgHeight, 1, 0, if (w) {
imgFormat, GL_UNSIGNED_BYTE, image); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, imgWidth, imgHeight, 0,
assert(glGetError() == GL_NO_ERROR); imgFormat, GL_UNSIGNED_BYTE, image);
assert(glGetError() == GL_NO_ERROR);
}
/*
* 3D Texture
*/
glTexImage3D(GL_PROXY_TEXTURE_3D, 0, GL_RGB, imgWidth, imgHeight, 1, 0, glTexImage3D(GL_PROXY_TEXTURE_3D, 0, GL_RGB, imgWidth, imgHeight, 1, 0,
imgFormat, GL_UNSIGNED_BYTE, image); imgFormat, GL_UNSIGNED_BYTE, image);
glGetTexLevelParameteriv(GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_WIDTH, &w); glGetTexLevelParameteriv(GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_WIDTH, &w);
assert(w == imgWidth); assert(w == imgWidth || w == 0);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, if (w) {
minDim, minDim, 0, glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, imgWidth, imgHeight, 1, 0,
imgFormat, GL_UNSIGNED_BYTE, image); imgFormat, GL_UNSIGNED_BYTE, image);
assert(glGetError() == GL_NO_ERROR); assert(glGetError() == GL_NO_ERROR);
}
/*
* Cube Texture
*/
glTexImage2D(GL_PROXY_TEXTURE_CUBE_MAP, 0, GL_RGB, glTexImage2D(GL_PROXY_TEXTURE_CUBE_MAP, 0, GL_RGB,
minDim, minDim, 0, minDim, minDim, 0,
imgFormat, GL_UNSIGNED_BYTE, image); imgFormat, GL_UNSIGNED_BYTE, image);
glGetTexLevelParameteriv(GL_PROXY_TEXTURE_CUBE_MAP, 0, GL_TEXTURE_WIDTH, &w); glGetTexLevelParameteriv(GL_PROXY_TEXTURE_CUBE_MAP, 0, GL_TEXTURE_WIDTH, &w);
assert(w == minDim); assert(w == minDim || w == 0);
if (w) {
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB,
minDim, minDim, 0,
imgFormat, GL_UNSIGNED_BYTE, image);
assert(glGetError() == GL_NO_ERROR);
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);