void shader_program_set_texture(shader_program* p, char* name, int index, asset_hndl t) { GLint location = glGetUniformLocation(shader_program_handle(p), name); if ( location == -1) { warning("Shader has no uniform called '%s'", name); } else { glActiveTexture(GL_TEXTURE0 + index); glBindTexture(texture_type(asset_hndl_ptr(&t)), texture_handle(asset_hndl_ptr(&t))); glUniform1i(location, index); } }
static v8::Handle<v8::Value> validate_arguments( texture_compiler_args_t *args, image::buffer_t *source) { v8::HandleScope scope; bool mipmaps = args->build_mipmaps; size_t channels = source->channel_count; if (TEXTURE_TYPE_UNKNOWN == texture_type(args->texture_type, channels)) { return scope.Close(ex("The type field has an invalid value.")); } if (TEXTURE_FORMAT_UNKNOWN == texture_format(args->target_format, channels)) { return scope.Close(ex("The format field has an invalid value.")); } if (TEXTURE_TARGET_UNKNOWN == texture_target(args->texture_target)) { return scope.Close(ex("The target field has an invalid value.")); } if (TEXTURE_WRAP_UNKNOWN == texture_wrap(args->wrap_mode_s)) { return scope.Close(ex("The wrapModeS field has an invalid value.")); } if (TEXTURE_WRAP_UNKNOWN == texture_wrap(args->wrap_mode_t)) { return scope.Close(ex("The wrapModeT field has an invalid value.")); } if (TEXTURE_FILTER_UNKNOWN == magnify_filter(args->magnify_filter)) { return scope.Close(ex("The magnifyFilter field has an invalid value.")); } if (TEXTURE_FILTER_UNKNOWN == minify_filter(args->minify_filter, mipmaps)) { return scope.Close(ex("The minifyFilter field has an invalid value.")); } return scope.Close(v8::Undefined()); }