summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/render/bgfx/paramuniformreader.cpp
blob: 8c5cd2651950c651cbcbbbec5ccc67bac9b4cf85 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
//====================================================================
//
//  paramuniformreader.cpp - BGFX chain entry parameter mapper reader
//
//====================================================================

#include "paramuniformreader.h"

#include "entryuniform.h"
#include "parameter.h"
#include "paramuniform.h"

bgfx_entry_uniform* param_uniform_reader::read_from_value(const Value& value, const std::string &prefix, bgfx_uniform* uniform, std::map<std::string, bgfx_parameter*>& params)
{
	if (!validate_parameters(value, prefix))
	{
		return nullptr;
	}

	std::string parameter = value["parameter"].GetString();

	return new bgfx_param_uniform(uniform, params[parameter]);
}

bool param_uniform_reader::validate_parameters(const Value& value, const std::string &prefix)
{
	if (!READER_CHECK(value.HasMember("parameter"), "%sMust have string value 'parameter' (what parameter is being mapped?)\n", prefix)) return false;
	if (!READER_CHECK(value["parameter"].IsString(), "%sValue 'parameter' must be a string\n", prefix)) return false;
	return true;
}