Exemplo n.º 1
0
static inline void clear_tex_params(struct darray *in_params)
{
	struct pass_shaderparam *params = in_params->array;

	for (size_t i = 0; i < in_params->num; i++) {
		struct pass_shaderparam *param = params+i;
		struct shader_param_info info;

		shader_getparaminfo(param->sparam, &info);
		if (info.type == SHADER_PARAM_TEXTURE)
			shader_settexture(param->sparam, NULL);
	}
}
Exemplo n.º 2
0
void shader_setval(shader_t shader, sparam_t param, const void *val,
		size_t size)
{
	int count = param->array_count;
	size_t expected_size = 0;
	if (!count)
		count = 1;

	if (!matching_shader(shader, param))
		return;

	switch ((uint32_t)param->type) {
	case SHADER_PARAM_FLOAT:     expected_size = sizeof(float); break;
	case SHADER_PARAM_BOOL:
	case SHADER_PARAM_INT:       expected_size = sizeof(int); break;
	case SHADER_PARAM_VEC2:      expected_size = sizeof(float)*2; break;
	case SHADER_PARAM_VEC3:      expected_size = sizeof(float)*3; break;
	case SHADER_PARAM_VEC4:      expected_size = sizeof(float)*4; break;
	case SHADER_PARAM_MATRIX4X4: expected_size = sizeof(float)*4*4; break;
	case SHADER_PARAM_TEXTURE:   expected_size = sizeof(void*); break;
	default:                     expected_size = 0;
	}

	expected_size *= count;
	if (!expected_size)
		return;

	if (expected_size != size) {
		blog(LOG_ERROR, "shader_setval (GL): Size of shader param does "
		                "not match the size of the input");
		return;
	}

	if (param->type == SHADER_PARAM_TEXTURE)
		shader_settexture(shader, param, *(texture_t*)val);
	else
		shader_setval_data(shader, param, val, count);
}