void GLAPIENTRY _mesa_GetObjectParameterivARB(GLhandleARB object, GLenum pname, GLint *params) { GET_CURRENT_CONTEXT(ctx); /* Implement in terms of GetProgramiv, GetShaderiv */ if (is_program(ctx, object)) { if (pname == GL_OBJECT_TYPE_ARB) { *params = GL_PROGRAM_OBJECT_ARB; } else { get_programiv(ctx, object, pname, params); } } else if (is_shader(ctx, object)) { if (pname == GL_OBJECT_TYPE_ARB) { *params = GL_SHADER_OBJECT_ARB; } else { get_shaderiv(ctx, object, pname, params); } } else { _mesa_error(ctx, GL_INVALID_VALUE, "glGetObjectParameterivARB"); } }
void GLAPIENTRY _mesa_GetInfoLogARB(GLhandleARB object, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog) { GET_CURRENT_CONTEXT(ctx); if (is_program(ctx, object)) { get_program_info_log(ctx, object, maxLength, length, infoLog); } else if (is_shader(ctx, object)) { get_shader_info_log(ctx, object, maxLength, length, infoLog); } else { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetInfoLogARB"); } }
bool settings_parser_c::parse(int argc, char *argv[]) { arg_c = argc; arg_v = argv; position = 1; for (int i = 0; i < parsers.size(); ++i) { parsers[i]->invoke_initialization(*this); } while (current_position() < argc && !stopped) { for (auto parser = parsers.begin(); parser != parsers.end(); parser++) { fetch_current_position(); if ((*parser)->parse(*this)) { save_current_position((*parser)); } restore_position(); } if (saved_count() == 1) { try { pop_saved_parser()->invoke(*this); } catch (std::string error) { std::cerr << "Invalid parameter value: " << arg_v[position - 1] << " with error: " << error << std::endl; return false; } } else if (saved_count() > 1) { //ambiguous arguments //throw std::cerr << "ambiguous arguments" << std::endl; } else { if (is_program()) { parse_program(); //parse_program//until separator detected } else { //unknown_argument std::cerr << "unknown argument " << arg_v[position] << std::endl; //throw ""; return false; } } } return true; }
void GLAPIENTRY _mesa_DeleteObjectARB(GLhandleARB obj) { if (MESA_VERBOSE & VERBOSE_API) { GET_CURRENT_CONTEXT(ctx); _mesa_debug(ctx, "glDeleteObjectARB(%u)\n", obj); } if (obj) { GET_CURRENT_CONTEXT(ctx); FLUSH_VERTICES(ctx, 0); if (is_program(ctx, obj)) { delete_shader_program(ctx, obj); } else if (is_shader(ctx, obj)) { delete_shader(ctx, obj); } else { /* error? */ } } }
static void detach_shader(struct gl_context *ctx, GLuint program, GLuint shader) { struct gl_shader_program *shProg; GLuint n; GLuint i, j; shProg = _mesa_lookup_shader_program_err(ctx, program, "glDetachShader"); if (!shProg) return; n = shProg->NumShaders; for (i = 0; i < n; i++) { if (shProg->Shaders[i]->Name == shader) { /* found it */ struct gl_shader **newList; /* release */ _mesa_reference_shader(ctx, &shProg->Shaders[i], NULL); /* alloc new, smaller array */ newList = (struct gl_shader **) malloc((n - 1) * sizeof(struct gl_shader *)); if (!newList) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDetachShader"); return; } for (j = 0; j < i; j++) { newList[j] = shProg->Shaders[j]; } while (++i < n) newList[j++] = shProg->Shaders[i]; free(shProg->Shaders); shProg->Shaders = newList; shProg->NumShaders = n - 1; #ifdef DEBUG /* sanity check */ { for (j = 0; j < shProg->NumShaders; j++) { assert(shProg->Shaders[j]->Type == GL_VERTEX_SHADER || shProg->Shaders[j]->Type == GL_FRAGMENT_SHADER); assert(shProg->Shaders[j]->RefCount > 0); } } #endif return; } } /* not found */ { GLenum err; if (is_shader(ctx, shader)) err = GL_INVALID_OPERATION; else if (is_program(ctx, shader)) err = GL_INVALID_OPERATION; else err = GL_INVALID_VALUE; _mesa_error(ctx, err, "glDetachProgram(shader)"); return; } }
GLboolean GLAPIENTRY _mesa_IsProgram(GLuint name) { GET_CURRENT_CONTEXT(ctx); return is_program(ctx, name); }