20 #include "../bitmap/pixel_arithmetic.h"
47 case MatrixParameter::Type::INT:
50 case MatrixParameter::Type::FLOAT:
68 param.
configure(MatrixParameter::Type::INT, 2);
69 GLint* data = param.
getData<GLint>();
76 param.
configure(MatrixParameter::Type::INT, 3);
77 GLint* data = param.
getData<GLint>();
85 param.
configure(MatrixParameter::Type::INT, 4);
86 GLint* data = param.
getData<GLint>();
99 param.
configure(MatrixParameter::Type::FLOAT, 2);
100 GLfloat* data = param.
getData<GLfloat>();
107 param.
configure(MatrixParameter::Type::FLOAT, 3);
108 GLfloat* data = param.
getData<GLfloat>();
116 param.
configure(MatrixParameter::Type::FLOAT, 4);
117 GLfloat* data = param.
getData<GLfloat>();
126 param.
configure(MatrixParameter::Type::FLOAT, 2, 2);
128 for (
const float* in = matrix; in < matrix + 4; ++in)
134 param.
configure(MatrixParameter::Type::FLOAT, 3, 3);
136 for (
const float* in = matrix; in < matrix + 9; ++in)
142 param.
configure(MatrixParameter::Type::FLOAT, 4, 4);
144 for (
const float* in = matrix; in < matrix + 16; ++in)
150 param.
configure(MatrixParameter::Type::FLOAT, 4, 4);
152 for (
int x = 0;
x < 4; ++
x) {
154 for (
int y = 0;
y < 4; ++
y)
166 return std::numeric_limits<float>::quiet_NaN();
172 program.
setInteger(var.first.c_str(), var.second);
175 program.
setFloat(var.first.c_str(), var.second);
177 for (
auto& var :
params) {
179 if (var.second.getHeight() == 1 && var.second.getCount() == 1)
180 switch (var.second.getType()) {
181 case MatrixParameter::Type::INT: {
182 GLint* data = var.second.getData<GLint>();
183 switch (var.second.getWidth()) {
188 glUniform3i(program.
getUniformLocation(var.first.c_str()), data[0], data[1], data[2]);
191 glUniform4i(program.
getUniformLocation(var.first.c_str()), data[0], data[1], data[2], data[3]);
197 case MatrixParameter::Type::FLOAT: {
198 GLfloat* data = var.second.getData<GLfloat>();
199 switch (var.second.getWidth()) {
204 glUniform3f(program.
getUniformLocation(var.first.c_str()), data[0], data[1], data[2]);
207 glUniform4f(program.
getUniformLocation(var.first.c_str()), data[0], data[1], data[2], data[3]);
216 else if (var.second.getHeight() == 1)
217 #define CASE(n,t,T) case n: glUniform##n##t##v(program.getUniformLocation(var.first.c_str()), var.second.getCount(), var.second.getData<T>()); break;
218 switch (var.second.getType()) {
219 case MatrixParameter::Type::INT:
220 switch (var.second.getWidth()) {
228 case MatrixParameter::Type::FLOAT:
229 switch (var.second.getWidth()) {
240 else if (var.second.getWidth() == var.second.getHeight())
242 #define CASE(n) case n: glUniformMatrix##n##fv(program.getUniformLocation(var.first.c_str()), var.second.getCount(), GL_FALSE, var.second.getData<GLfloat>()); break;
243 switch (var.second.getType()) {
244 case MatrixParameter::Type::FLOAT: {
245 switch (var.second.getWidth()) {
262 glUniform1fv(program.
getUniformLocation(var.first.c_str()), var.second.size(), var.second.data());
void setInteger(const std::string &name, const int value, bool safe=false)
Assigns a value to a specific integer variable in the program.
handle_t getUniformLocation(const std::string &name)
Retrieves uniform variable location by its name.
void setFloat(const std::string &name, const float value, bool safe=false)
Assigns a value to a specific floating point variable in the program.
static void check(const std::string &info)
void configure(Type type, unsigned short int width, unsigned short int height=1, unsigned int count=1)
T * getData(int index=0) const
MatrixParameter & operator=(MatrixParameter &&)
unsigned short int height
void setFloatMatrix4(std::string name, const float matrix[16])
Sets a float 4*4 matrix variable value.
float getFloat(const std::string &name) const
Retrieves a value of a scalar float uniform variable by its name.
void setInteger(std::string name, int value)
Sets a scalar integer uniform value.
void setFloat(std::string name, float value)
Sets a scalar float uniform value.
std::map< std::string, int > integers
std::map< std::string, MatrixParameter > params
void clear()
Removes all stored variables.
void setFloatMatrix3(std::string name, const float matrix[9])
Sets a float 3*3 matrix variable value.
void setFloatMatrix2(std::string name, const float matrix[4])
Sets a float 2*2 matrix variable value.
std::map< std::string, float > floats
void apply(Program &program)
void setFloatArray(std::string name, const std::vector< float > &values)
Sets a float array variable value.
std::map< std::string, std::vector< float > > floatArrays
static void insanity(const char *message)
4-channel floating point arithmetic
return(jlong) new Beatmup jlong jstring name
jlong jstring jint jint jint z
jobject jlong jint jint y
jlong jstring jint jint jint jint w
JNIEnv jlong jint jint count
return(jlong) new Beatmup jlong jstring src