-/* $Id: image.c,v 1.6 1999/10/13 18:42:50 brianp Exp $ */
+/* $Id: image.c,v 1.7 1999/10/19 20:31:08 brianp Exp $ */
/*
* Mesa 3-D graphics library
gl_error( ctx, GL_INVALID_VALUE, msg );
return GL_TRUE;
}
+ else if (!gl_is_legal_format_and_type(image->Format, image->Type)) {
+ return GL_TRUE;
+ }
else {
return GL_FALSE;
}
GLushort *sDst;
GLuint *iDst;
GLint i, j;
+ GLboolean errorType;
+
+ errorType = type != GL_BYTE &&
+ type != GL_UNSIGNED_BYTE &&
+ type != GL_SHORT &&
+ type != GL_UNSIGNED_SHORT &&
+ type != GL_INT &&
+ type != GL_UNSIGNED_INT &&
+ type != GL_FLOAT;
image = alloc_image();
if (image) {
image->Depth = 1;
image->Components = 1;
image->Format = GL_DEPTH_COMPONENT;
+ if (errorType) {
+ image->Type = type;
+ image->Data = NULL;
+ }
if (type==GL_UNSIGNED_SHORT) {
image->Type = GL_UNSIGNED_SHORT;
image->Data = MALLOC( width * height * sizeof(GLushort));
return NULL;
}
+ if (errorType)
+ return image;
+
fDst = (GLfloat *) image->Data;
sDst = (GLushort *) image->Data;
iDst = (GLuint *) image->Data;
struct gl_image *image;
GLubyte *dst;
GLint i, j;
+ GLboolean errorType;
assert(sizeof(GLstencil) == sizeof(GLubyte));
+ errorType = type != GL_BYTE &&
+ type != GL_UNSIGNED_BYTE &&
+ type != GL_SHORT &&
+ type != GL_UNSIGNED_SHORT &&
+ type != GL_INT &&
+ type != GL_UNSIGNED_INT &&
+ type != GL_FLOAT &&
+ type != GL_BITMAP;
+
image = alloc_image();
if (image) {
image->Width = width;
image->Depth = 1;
image->Components = 1;
image->Format = GL_STENCIL_INDEX;
- image->Type = GL_UNSIGNED_BYTE;
- image->Data = MALLOC( width * height * sizeof(GLubyte));
+ if (errorType) {
+ image->Type = type;
+ image->Data = NULL;
+ }
+ else {
+ image->Type = GL_UNSIGNED_BYTE;
+ image->Data = MALLOC( width * height * sizeof(GLubyte));
+ }
image->RefCount = 0;
if (!image->Data)
return image;
return NULL;
}
+ if (errorType)
+ return image; /* error will be generated later */
+
dst = (GLubyte *) image->Data;
for (i=0;i<height;i++) {