cut down on redundant gl uniform changes

This commit is contained in:
Konstantin Käfer
2014-02-13 16:21:51 +01:00
parent f5846e1ebb
commit da06a52056
15 changed files with 249 additions and 74 deletions

View File

@@ -56,10 +56,10 @@ public:
uint32_t height = 0;
// physical (framebuffer) dimensions
uint32_t fb_width = 0;
uint32_t fb_height = 0;
float fb_width = 0;
float fb_height = 0;
double pixelRatio = 1;
float pixelRatio = 1;
private:
double x = 0, y = 0; // pixel values of the map center in the current scale

View File

@@ -11,18 +11,38 @@ public:
void bind(char *offset);
int32_t a_pos;
int32_t a_extrude;
// int32_t a_linesofar;
void setExtrudeMatrix(const std::array<float, 16>& exmatrix);
void setColor(const std::array<float, 4>& color);
void setLineWidth(const std::array<float, 2>& linewidth);
void setRatio(float ratio);
void setDashArray(const std::array<float, 2>& dasharray);
void setDebug(float debug);
int32_t u_exmatrix;
int32_t u_linewidth;
int32_t u_color;
int32_t u_ratio;
int32_t u_dasharray;
int32_t u_debug;
private:
int32_t a_pos = -1;
int32_t a_extrude = -1;
// int32_t a_linesofar = -1;
std::array<float, 16> exmatrix = {};
int32_t u_exmatrix = -1;
std::array<float, 4> color = {};
int32_t u_color = -1;
std::array<float, 2> linewidth = {};
int32_t u_linewidth = -1;
float ratio = 0;
int32_t u_ratio = -1;
std::array<float, 2> dasharray = {};
int32_t u_dasharray = -1;
float debug = 0;
int32_t u_debug = -1;
};
}
#endif

View File

@@ -11,12 +11,25 @@ public:
void bind(char *offset);
int32_t a_pos;
void setColor(const std::array<float, 4>& color);
void setWorld(const std::array<float, 2>& world);
void setLineWidth(const std::array<float, 2>& linewidth);
void setSize(float size);
int32_t u_world;
int32_t u_linewidth;
int32_t u_color;
int32_t u_size;
private:
int32_t a_pos = -1;
std::array<float, 4> color = {};
int32_t u_color = -1;
std::array<float, 2> world = {};
int32_t u_world = -1;
std::array<float, 2> linewidth = {};
int32_t u_linewidth = -1;
float size = 0;
int32_t u_size = -1;
};
}

View File

@@ -13,14 +13,15 @@ public:
void setColor(const std::array<float, 4>& color);
void setWorld(const std::array<float, 2>& world);
private:
int32_t a_pos;
int32_t a_pos = -1;
std::array<float, 4> color;
int32_t u_color;
std::array<float, 4> color = {};
int32_t u_color = -1;
std::array<float, 2> world;
int32_t u_world;
std::array<float, 2> world = {};
int32_t u_world = -1;
};
}

View File

@@ -11,14 +11,33 @@ public:
void bind(char *offset);
int32_t a_pos;
int32_t u_color;
int32_t u_offset;
int32_t u_pattern_size;
int32_t u_pattern_tl;
int32_t u_pattern_br;
int32_t u_mix;
void setColor(const std::array<float, 4>& color);
void setOffset(const std::array<float, 2>& offset);
void setPatternSize(const std::array<float, 2>& pattern_size);
void setPatternTopLeft(const std::array<float, 2>& pattern_tl);
void setPatternBottomRight(const std::array<float, 2>& pattern_br);
void setMix(float mix);
private:
int32_t a_pos = -1;
std::array<float, 4> color = {};
int32_t u_color = -1;
std::array<float, 2> offset = {};
int32_t u_offset = -1;
std::array<float, 2> pattern_size = {};
int32_t u_pattern_size = -1;
std::array<float, 2> pattern_tl = {};
int32_t u_pattern_tl = -1;
std::array<float, 2> pattern_br = {};
int32_t u_pattern_br = -1;
float mix = 0;
int32_t u_mix = -1;
};
}

View File

@@ -15,10 +15,10 @@ public:
void setColor(const std::array<float, 4>& color);
private:
int32_t a_pos;
int32_t a_pos = -1;
std::array<float, 4> color;
int32_t u_color;
std::array<float, 4> color = {};
int32_t u_color = -1;
};
}

View File

@@ -2,8 +2,8 @@
#define LLMR_RENDERER_SHADER
#include <cstdint>
#include <array>
#include <llmr/util/noncopyable.hpp>
#include <llmr/util/mat4.hpp>
namespace llmr {
@@ -14,14 +14,14 @@ public:
bool valid;
uint32_t program;
void setMatrix(const mat4& matrix);
void setMatrix(const std::array<float, 16>& matrix);
private:
bool compileShader(uint32_t *shader, uint32_t type, const char *source);
protected:
int32_t u_matrix;
mat4 matrix;
std::array<float, 16> matrix = {};
int32_t u_matrix = -1;
};
}