diff options
Diffstat (limited to 'src/mesa/main/nvprogram.c')
-rw-r--r-- | src/mesa/main/nvprogram.c | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/src/mesa/main/nvprogram.c b/src/mesa/main/nvprogram.c index 1e255ba0288..4e371620c57 100644 --- a/src/mesa/main/nvprogram.c +++ b/src/mesa/main/nvprogram.c @@ -1,4 +1,4 @@ -/* $Id: nvprogram.c,v 1.7 2003/03/10 00:26:24 brianp Exp $ */ +/* $Id: nvprogram.c,v 1.8 2003/03/14 15:40:59 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -260,35 +260,41 @@ _mesa_BindProgramNV(GLenum target, GLuint id) /* NOTE: binding to a non-existant program is not an error. * That's supposed to be caught in glBegin. */ - prog = (struct program *) _mesa_HashLookup(ctx->Shared->Programs, id); - - if (!prog && id > 0){ - /* allocate new program */ - if (target == GL_VERTEX_PROGRAM_NV) { - struct vertex_program *vprog = CALLOC_STRUCT(vertex_program); - if (!vprog) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindProgramNV"); - return; + if (id == 0) { + /* OK, the null program object */ + prog = NULL; + } + else { + prog = (struct program *) _mesa_HashLookup(ctx->Shared->Programs, id); + + if (!prog && id > 0){ + /* allocate new program */ + if (target == GL_VERTEX_PROGRAM_NV) { + struct vertex_program *vprog = CALLOC_STRUCT(vertex_program); + if (!vprog) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindProgramNV"); + return; + } + prog = &(vprog->Base); } - prog = &(vprog->Base); - } - else if (target == GL_FRAGMENT_PROGRAM_NV) { - struct fragment_program *fprog = CALLOC_STRUCT(fragment_program); - if (!fprog) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindProgramNV"); + else if (target == GL_FRAGMENT_PROGRAM_NV) { + struct fragment_program *fprog = CALLOC_STRUCT(fragment_program); + if (!fprog) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindProgramNV"); + return; + } + prog = &(fprog->Base); + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glBindProgramNV(target)"); return; } - prog = &(fprog->Base); + prog->Id = id; + prog->Target = target; + prog->Resident = GL_TRUE; + prog->RefCount = 1; + _mesa_HashInsert(ctx->Shared->Programs, id, prog); } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glBindProgramNV(target)"); - return; - } - prog->Id = id; - prog->Target = target; - prog->Resident = GL_TRUE; - prog->RefCount = 1; - _mesa_HashInsert(ctx->Shared->Programs, id, prog); } /* bind now */ |