Fix some issues with glDrawBuffer(GL_NONE), bug 14198
[mesa.git] / src / mesa / swrast / s_triangle.c
index 5036020b7c48665c4c91afbd988637c08a0568a6..59e15645f3f5f851baded0f95b6ad63bdfa909e1 100644 (file)
@@ -130,7 +130,7 @@ _swrast_culltriangle( GLcontext *ctx,
 #define T_SCALE theight
 
 #define SETUP_CODE                                                     \
-   struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];\
+   struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; \
    struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D;     \
    const GLint b = obj->BaseLevel;                                     \
    const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width;           \
@@ -139,8 +139,7 @@ _swrast_culltriangle( GLcontext *ctx,
    const GLchan *texture = (const GLchan *) obj->Image[0][b]->Data;    \
    const GLint smask = obj->Image[0][b]->Width - 1;                    \
    const GLint tmask = obj->Image[0][b]->Height - 1;                   \
-   if (!texture) {                                                     \
-      /* this shouldn't happen */                                      \
+   if (!rb || !texture) {                                              \
       return;                                                          \
    }
 
@@ -182,7 +181,7 @@ _swrast_culltriangle( GLcontext *ctx,
 #define T_SCALE theight
 
 #define SETUP_CODE                                                     \
-   struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];\
+   struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; \
    struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D;     \
    const GLint b = obj->BaseLevel;                                     \
    const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width;           \
@@ -191,8 +190,7 @@ _swrast_culltriangle( GLcontext *ctx,
    const GLchan *texture = (const GLchan *) obj->Image[0][b]->Data;    \
    const GLint smask = obj->Image[0][b]->Width - 1;                    \
    const GLint tmask = obj->Image[0][b]->Height - 1;                   \
-   if (!texture) {                                                     \
-      /* this shouldn't happen */                                      \
+   if (!rb || !texture) {                                              \
       return;                                                          \
    }