struct gl_texture_object **texObj)
{
GLenum maxLevelsTarget;
+ GLboolean err = GL_TRUE;
*texObj = NULL; /* This will get returned if texture = 0. */
/* The textarget, level, and zoffset parameters are only validated if
* texture is non-zero.
*/
- if (texture) {
- GLboolean err = GL_TRUE;
+ if (!texture)
+ return true;
+
+ *texObj = _mesa_lookup_texture(ctx, texture);
+ if (*texObj == NULL || (*texObj)->Target == 0) {
+ /* Can't render to a non-existent texture object.
+ *
+ * The OpenGL 4.5 core spec (02.02.2015) in Section 9.2 Binding and
+ * Managing Framebuffer Objects specifies a different error
+ * depending upon the calling function (PDF pages 325-328).
+ * *FramebufferTexture (where *layered = GL_TRUE) throws invalid
+ * value, while the other commands throw invalid operation (where
+ * *layered = GL_FALSE).
+ */
+ const GLenum error = *layered ? GL_INVALID_VALUE :
+ GL_INVALID_OPERATION;
+ _mesa_error(ctx, error,
+ "%s(non-existent texture %u)", caller, texture);
+ return false;
+ }
- *texObj = _mesa_lookup_texture(ctx, texture);
- if (*texObj != NULL && (*texObj)->Target != 0) {
if (textarget == 0) {
if (*layered) {
/* We're being called by gl*FramebufferTexture() and textarget
? !_mesa_is_cube_face(textarget)
: ((*texObj)->Target != textarget);
}
- }
- else {
- /* Can't render to a non-existent texture object.
- *
- * The OpenGL 4.5 core spec (02.02.2015) in Section 9.2 Binding and
- * Managing Framebuffer Objects specifies a different error
- * depending upon the calling function (PDF pages 325-328).
- * *FramebufferTexture (where *layered = GL_TRUE) throws invalid
- * value, while the other commands throw invalid operation (where
- * *layered = GL_FALSE).
- */
- const GLenum error = *layered ? GL_INVALID_VALUE :
- GL_INVALID_OPERATION;
- _mesa_error(ctx, error,
- "%s(non-existent texture %u)", caller, texture);
- return false;
- }
if (err) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(invalid level %d)", caller, level);
return false;
}
- }
return true;
}