[cogl/wip/out-of-memory-checks: 2/2] stash: check for texture-3d out-of-memory errors
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/wip/out-of-memory-checks: 2/2] stash: check for texture-3d out-of-memory errors
- Date: Thu, 25 Oct 2012 16:15:38 +0000 (UTC)
commit e37182800fe69564ea99a21e231995038af3d6c3
Author: Robert Bragg <robert linux intel com>
Date: Thu Oct 25 17:09:09 2012 +0100
stash: check for texture-3d out-of-memory errors
TODO: allow texture_driver->upload_to_gl_3d() to report out-of-memory
errors
cogl/cogl-texture-3d.c | 26 +++++++++++++++++++-------
1 files changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/cogl/cogl-texture-3d.c b/cogl/cogl-texture-3d.c
index 6000b37..1a53532 100644
--- a/cogl/cogl-texture-3d.c
+++ b/cogl/cogl-texture-3d.c
@@ -38,6 +38,7 @@
#include "cogl-pipeline-private.h"
#include "cogl-pipeline-opengl-private.h"
#include "cogl-error-private.h"
+#include "cogl-util-gl-private.h"
#include <string.h>
#include <math.h>
@@ -137,7 +138,7 @@ _cogl_texture_3d_create_base (CoglContext *ctx,
tex_3d->format = internal_format;
- return tex_3d;
+ return _cogl_texture_3d_object_new (tex_3d);
}
static CoglBool
@@ -209,10 +210,11 @@ cogl_texture_3d_new_with_size (CoglContext *ctx,
CoglPixelFormat internal_format,
CoglError **error)
{
- CoglTexture3D *tex_3d;
- GLenum gl_intformat;
- GLenum gl_format;
- GLenum gl_type;
+ CoglTexture3D *tex_3d;
+ GLenum gl_intformat;
+ GLenum gl_format;
+ GLenum gl_type;
+ GLenum gl_error;
/* Since no data, we need some internal format */
if (internal_format == COGL_PIXEL_FORMAT_ANY)
@@ -238,10 +240,20 @@ cogl_texture_3d_new_with_size (CoglContext *ctx,
_cogl_bind_gl_texture_transient (GL_TEXTURE_3D,
tex_3d->gl_texture,
FALSE);
+ /* Clear any GL errors */
+ while ((gl_error = ctx->glGetError ()) != GL_NO_ERROR)
+ ;
+
GE( ctx, glTexImage3D (GL_TEXTURE_3D, 0, gl_intformat,
width, height, depth, 0, gl_format, gl_type, NULL) );
- return _cogl_texture_3d_object_new (tex_3d);
+ if (_cogl_gl_util_catch_out_of_memory (ctx, error))
+ {
+ cogl_object_unref (tex_3d);
+ return NULL;
+ }
+
+ return tex_3d;
}
CoglTexture3D *
@@ -325,7 +337,7 @@ cogl_texture_3d_new_from_bitmap (CoglBitmap *bmp,
cogl_object_unref (dst_bmp);
- return _cogl_texture_3d_object_new (tex_3d);
+ return tex_3d;
}
CoglTexture3D *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]