Merge branch 'glsl' of github.com:projectM-visualizer/projectm into glsl

This commit is contained in:
Mischa Spiegelmock
2018-07-26 00:04:38 +03:00
10 changed files with 128 additions and 184 deletions

View File

@ -13,7 +13,6 @@ script:
- test -e src/projectM-sdl/projectMSDL
- test -e src/libprojectM/libprojectM.la
- test -e dist_install/share/projectM/fonts/Vera.ttf
- test -e dist_install/share/projectM/shaders/blur.cg
- test -d dist_install/share/projectM/presets
- test -e dist_install/lib/libprojectM.la
- test -e dist_install/include/libprojectM/projectM.hpp
@ -34,9 +33,8 @@ matrix:
- libsdl2-dev
- libglew-dev
- libftgl-dev
- libsdl2-dev
- libdevil-dev
- libglm-dev
- libc++-dev
env:
- MATRIX_EVAL="CC=clang-5.0 && CXX=clang++-5.0"
# linux/gcc
@ -50,9 +48,8 @@ matrix:
- libsdl2-dev
- libglew-dev
- libftgl-dev
- libsdl2-dev
- libdevil-dev
- libglm-dev
- libc++-dev
env:
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"

View File

@ -75,9 +75,12 @@ AC_CONFIG_FILES([src/libprojectM/config.inp.in])
AC_PREFIX_DEFAULT([/usr/local])
AC_PROG_MKDIR_P
AX_CHECK_COMPILE_FLAG([-stdlib=libc++], [
CXXFLAGS="$CXXFLAGS -stdlib=libc++"])
AX_CHECK_COMPILE_FLAG([-std=c++14], [
CXXFLAGS="$CXXFLAGS -std=c++14"])
AX_CHECK_COMPILE_FLAG([-std=c++11], [
CXXFLAGS="$CXXFLAGS -std=c++11"])
dnl Qt
AC_ARG_ENABLE([qt],

View File

@ -35,7 +35,7 @@ void PresetInputs::update(const BeatDetect & music, const PipelineContext & cont
float **alloc_mesh(size_t gx, size_t gy)
{
// round gy up to multiple 4 (for possible SSE optimization)
// gy = (gy+3) & ~(size_t)3;
gy = (gy+3) & ~(size_t)3;
float **mesh = (float **)wipe_aligned_alloc(gx * sizeof(float *));
float *m = (float *)wipe_aligned_alloc(gx * gy * sizeof(float));
@ -236,7 +236,7 @@ inline __m128 _mm_pow(__m128 x, __m128 y)
float X[4];
float Y[4];
_mm_store_ps(X,x);
_mm_store_ps(Y,x);
_mm_store_ps(Y,y);
X[0] = __builtin_powf(X[0],Y[0]);
X[1] = __builtin_powf(X[1],Y[1]);
X[2] = __builtin_powf(X[2],Y[2]);
@ -441,11 +441,11 @@ void PresetOutputs::PerPixelMath_sse(const PipelineContext &context)
void PresetOutputs::PerPixelMath(const PipelineContext &context)
{
//#ifdef __SSE2__
// PerPixelMath_sse(context);
//#else
#ifdef __SSE2__
PerPixelMath_sse(context);
#else
PerPixelMath_c(context);
//#endif
#endif
}

View File

@ -10,7 +10,7 @@
using namespace M4;
std::unique_ptr<std::string> HLSLTranslator::parse(const std::string & shaderType, const char *fileName, const std::string &fullSource) {
std::string HLSLTranslator::parse(const std::string & shaderType, const char *fileName, const std::string &fullSource) {
// alloc
GLSLGenerator generator;
Allocator allocator;
@ -37,7 +37,7 @@ std::unique_ptr<std::string> HLSLTranslator::parse(const std::string & shaderTyp
out2 << sourcePreprocessed;
out2.close();
#endif
return nullptr;
return std::string();
}
// generate GLSL
@ -50,10 +50,10 @@ std::unique_ptr<std::string> HLSLTranslator::parse(const std::string & shaderTyp
out2 << sourcePreprocessed;
out2.close();
#endif
return nullptr;
return std::string();
}
return std::make_unique<std::string>(generator.GetResult());
return std::string(generator.GetResult());
}

View File

@ -27,7 +27,7 @@
class HLSLTranslator {
public:
std::unique_ptr<std::string> parse(const std::string & shaderType, const char *fileName, const std::string &fullSource);
std::string parse(const std::string & shaderType, const char *fileName, const std::string &fullSource);
};
#endif

View File

@ -11,40 +11,57 @@
PerlinNoise::PerlinNoise()
{
for (int x = 0; x < 256;x++)
for (int y = 0; y < 256;y++)
noise_lq[x][y] = noise(x , y);
for (int x = 0; x < 256;x++) {
for (int y = 0; y < 256;y++) {
noise_lq[x][y][0] = noise(x , y);
noise_lq[x][y][1] = noise_lq[x][y][0];
noise_lq[x][y][2] = noise_lq[x][y][0];
}
}
for (int x = 0; x < 32;x++)
for (int y = 0; y < 32;y++)
noise_lq_lite[x][y] = noise(4*x,16*y);
for (int x = 0; x < 32;x++) {
for (int y = 0; y < 32;y++) {
noise_lq_lite[x][y][0] = noise(4*x,16*y);
noise_lq_lite[x][y][1] = noise_lq_lite[x][y][0];
noise_lq_lite[x][y][2] = noise_lq_lite[x][y][0];
}
}
for (int x = 0; x < 256;x++)
for (int y = 0; y < 256;y++)
noise_mq[x][y] = InterpolatedNoise((float)x/(float)2.0,(float)y/(float)2.0);
for (int x = 0; x < 256;x++) {
for (int y = 0; y < 256;y++) {
noise_mq[x][y][0] = InterpolatedNoise((float)x/(float)2.0,(float)y/(float)2.0);
noise_mq[x][y][1] = noise_mq[x][y][0];
noise_mq[x][y][2] = noise_mq[x][y][0];
}
}
for (int x = 0; x < 256;x++)
for (int y = 0; y < 256;y++)
noise_hq[x][y] = InterpolatedNoise((float)x/(float)3.0,(float)y/(float)3.0);
for (int x = 0; x < 256;x++) {
for (int y = 0; y < 256;y++) {
noise_hq[x][y][0] = InterpolatedNoise((float)x/(float)3.0,(float)y/(float)3.0);
noise_hq[x][y][1] = noise_hq[x][y][0];
noise_hq[x][y][2] = noise_hq[x][y][0];
}
}
for (int x = 0; x < 32;x++)
for (int y = 0; y < 32;y++)
for (int z = 0; z < 32;z++)
noise_lq_vol[x][y][z] = noise(x,y,z);
for (int x = 0; x < 32;x++) {
for (int y = 0; y < 32;y++) {
for (int z = 0; z < 32;z++) {
noise_lq_vol[x][y][z][0] = noise(x,y,z);
noise_lq_vol[x][y][z][1] = noise_lq_vol[x][y][z][0];
noise_lq_vol[x][y][z][2] = noise_lq_vol[x][y][z][0];
}
}
}
for (int x = 0; x < 32;x++)
for (int y = 0; y < 32;y++)
for (int z = 0; z < 32;z++)
noise_hq_vol[x][y][z] = noise(x,y,z);//perlin_noise_3d(x,y,z,6121,7,seed3,0.5,64);
int seed = rand()%1000;
int size = 512;
int octaves = sqrt((double)size);
for (int x = 0; x < size;x++)
for (int y = 0; y < size;y++)
noise_perlin[x][y] = perlin_noise_2d(x,y,6321,octaves,seed,0.5,size/4);
for (int x = 0; x < 32;x++) {
for (int y = 0; y < 32;y++) {
for (int z = 0; z < 32;z++) {
noise_hq_vol[x][y][z][0] = noise(x,y,z);
noise_hq_vol[x][y][z][1] = noise_hq_vol[x][y][z][0];
noise_hq_vol[x][y][z][2] = noise_hq_vol[x][y][z][0];
}
}
}
}
PerlinNoise::~PerlinNoise()

View File

@ -14,13 +14,12 @@ class PerlinNoise
{
public:
float noise_lq[256][256];
float noise_lq_lite[32][32];
float noise_mq[256][256];
float noise_hq[256][256];
float noise_perlin[512][512];
float noise_lq_vol[32][32][32];
float noise_hq_vol[32][32][32];
float noise_lq[256][256][3];
float noise_lq_lite[32][32][3];
float noise_mq[256][256][3];
float noise_hq[256][256][3];
float noise_lq_vol[32][32][32][3];
float noise_hq_vol[32][32][32][3];
PerlinNoise();
@ -46,14 +45,6 @@ private:
return noise(n);
}
static inline float cos_interp(float a, float b, float x)
{
float ft = x * 3.1415927;
float f = (1 - cos(ft)) * .5;
return a*(1-f) + b*f;
}
static inline float cubic_interp(float v0, float v1, float v2, float v3, float x)
{
float P = (v3 - v2) - (v0 - v1);
@ -100,53 +91,6 @@ private:
}
static inline float perlin_octave_2d(float x,float y, int width, int seed, float period)
{
float freq=1/(float)(period);
int num=(int)(width*freq);
int step_x=(int)(x*freq);
int step_y=(int)(y*freq);
float zone_x=x*freq-step_x;
float zone_y=y*freq-step_y;
int box=step_x+step_y*num;
int noisedata=(box+seed);
float u=cubic_interp(noise(noisedata-num-1),noise(noisedata-num),noise(noisedata-num+1),noise(noisedata-num+2),zone_x);
float a=cubic_interp(noise(noisedata-1),noise(noisedata),noise(noisedata+1),noise(noisedata+2),zone_x);
float b=cubic_interp(noise(noisedata+num -1),noise(noisedata+num),noise(noisedata+1+num),noise(noisedata+2+num),zone_x);
float v=cubic_interp(noise(noisedata+2*num -1),noise(noisedata+2*num),noise(noisedata+1+2*num),noise(noisedata+2+2*num),zone_x);
float value=cubic_interp(u,a,b,v,zone_y);
return value;
}
static inline float perlin_octave_2d_cos(float x,float y, int width, int seed, float period)
{
float freq=1/(float)(period);
int num=(int)(width*freq);
int step_x=(int)(x*freq);
int step_y=(int)(y*freq);
float zone_x=x*freq-step_x;
float zone_y=y*freq-step_y;
int box=step_x+step_y*num;
int noisedata=(box+seed);
float a=cos_interp(noise(noisedata),noise(noisedata+1),zone_x);
float b=cos_interp(noise(noisedata+num),noise(noisedata+1+num),zone_x);
float value=cos_interp(a,b,zone_y);
return value;
}
static inline float perlin_octave_3d(float x,float y, float z,int width, int seed, float period)
{
float freq=1/(float)(period);
@ -204,21 +148,6 @@ private:
}
static inline float perlin_noise_2d(int x, int y, int width, int octaves, int seed, float persistance, float basePeriod)
{
float p = persistance;
float val = 0.0;
for (int i = 0; i<octaves;i++)
{
val += perlin_octave_2d_cos(x,y,width,seed,basePeriod) * p;
basePeriod *= 0.5;
p *= persistance;
}
return val;
}
static inline float perlin_noise_3d(int x, int y, int z, int width, int octaves, int seed, float persistance, float basePeriod)
{
float p = persistance;

View File

@ -711,8 +711,8 @@ GLuint ShaderEngine::compilePresetShader(const PresentShaderType shaderType, Sha
// transpile from HLSL (aka preset shader aka directX shader) to GLSL (aka OpenGL shader lang)
HLSLTranslator translator = HLSLTranslator();
std::unique_ptr<std::string> glslSource = translator.parse(shaderTypeString, shaderFilename.c_str(), fullSource);
if (!glslSource) {
std::string glslSource = translator.parse(shaderTypeString, shaderFilename.c_str(), fullSource);
if (glslSource.empty()) {
std::cerr << "Failed to translate " << shaderTypeString << std::endl;
return GL_FALSE;
}
@ -721,9 +721,9 @@ GLuint ShaderEngine::compilePresetShader(const PresentShaderType shaderType, Sha
// copmile the preset shader fragment shader with the standard vertex shader and cross our fingers
GLuint ret = 0;
if (shaderType == PresentWarpShader) {
ret = CompileShaderProgram(presetWarpVertexShader, *glslSource.get(), shaderTypeString); // returns new program
ret = CompileShaderProgram(presetWarpVertexShader, glslSource, shaderTypeString); // returns new program
} else {
ret = CompileShaderProgram(presetCompVertexShader, *glslSource.get(), shaderTypeString); // returns new program
ret = CompileShaderProgram(presetCompVertexShader, glslSource, shaderTypeString); // returns new program
}
if (ret != GL_FALSE) {
@ -735,7 +735,7 @@ GLuint ShaderEngine::compilePresetShader(const PresentShaderType shaderType, Sha
std::cerr << "Source:" << std::endl << *glslSource.get() << std::endl;
#else
std::ofstream out2("/tmp/shader_glsl_" + shaderTypeString + ".txt");
out2 << *glslSource.get();
out2 << glslSource;
out2.close();
#endif
}
@ -755,40 +755,40 @@ void ShaderEngine::SetupShaderVariables(GLuint program, const Pipeline &pipeline
float mip_y = logf((float)texsizeX)/logf(2.0f);
float mip_avg = 0.5f*(mip_x + mip_y);
glProgramUniform4f(program, glGetUniformLocation(program, "rand_frame"), (rand() % 100) * .01, (rand() % 100) * .01, (rand()% 100) * .01, (rand() % 100) * .01);
glProgramUniform4f(program, glGetUniformLocation(program, "rand_preset"), rand_preset[0], rand_preset[1], rand_preset[2], rand_preset[3]);
glUniform4f(glGetUniformLocation(program, "rand_frame"), (rand() % 100) * .01, (rand() % 100) * .01, (rand()% 100) * .01, (rand() % 100) * .01);
glUniform4f(glGetUniformLocation(program, "rand_preset"), rand_preset[0], rand_preset[1], rand_preset[2], rand_preset[3]);
glProgramUniform4f(program, glGetUniformLocation(program, "_c0"), aspectX, aspectY, 1 / aspectX, 1 / aspectY);
glProgramUniform4f(program, glGetUniformLocation(program, "_c1"), 0.0, 0.0, 0.0, 0.0);
glProgramUniform4f(program, glGetUniformLocation(program, "_c2"), time_since_preset_start_wrapped, context.fps, context.frame, context.progress);
glProgramUniform4f(program, glGetUniformLocation(program, "_c3"), beatDetect->bass/100, beatDetect->mid/100, beatDetect->treb/100, beatDetect->vol/100);
glProgramUniform4f(program, glGetUniformLocation(program, "_c4"), beatDetect->bass_att/100, beatDetect->mid_att/100, beatDetect->treb_att/100, beatDetect->vol_att/100);
glProgramUniform4f(program, glGetUniformLocation(program, "_c5"), pipeline.blur1x-pipeline.blur1n, pipeline.blur1n, pipeline.blur2x-pipeline.blur2n, pipeline.blur2n);
glProgramUniform4f(program, glGetUniformLocation(program, "_c6"), pipeline.blur3x-pipeline.blur3n, pipeline.blur3n, pipeline.blur1n, pipeline.blur1x);
glProgramUniform4f(program, glGetUniformLocation(program, "_c7"), texsizeX, texsizeY, 1 / (float) texsizeX, 1 / (float) texsizeY);
glUniform4f(glGetUniformLocation(program, "_c0"), aspectX, aspectY, 1 / aspectX, 1 / aspectY);
glUniform4f(glGetUniformLocation(program, "_c1"), 0.0, 0.0, 0.0, 0.0);
glUniform4f(glGetUniformLocation(program, "_c2"), time_since_preset_start_wrapped, context.fps, context.frame, context.progress);
glUniform4f(glGetUniformLocation(program, "_c3"), beatDetect->bass/100, beatDetect->mid/100, beatDetect->treb/100, beatDetect->vol/100);
glUniform4f(glGetUniformLocation(program, "_c4"), beatDetect->bass_att/100, beatDetect->mid_att/100, beatDetect->treb_att/100, beatDetect->vol_att/100);
glUniform4f(glGetUniformLocation(program, "_c5"), pipeline.blur1x-pipeline.blur1n, pipeline.blur1n, pipeline.blur2x-pipeline.blur2n, pipeline.blur2n);
glUniform4f(glGetUniformLocation(program, "_c6"), pipeline.blur3x-pipeline.blur3n, pipeline.blur3n, pipeline.blur1n, pipeline.blur1x);
glUniform4f(glGetUniformLocation(program, "_c7"), texsizeX, texsizeY, 1 / (float) texsizeX, 1 / (float) texsizeY);
glProgramUniform4f(program, glGetUniformLocation(program, "_c8"), 0.5f+0.5f*cosf(context.time* 0.329f+1.2f),
glUniform4f(glGetUniformLocation(program, "_c8"), 0.5f+0.5f*cosf(context.time* 0.329f+1.2f),
0.5f+0.5f*cosf(context.time* 1.293f+3.9f),
0.5f+0.5f*cosf(context.time* 5.070f+2.5f),
0.5f+0.5f*cosf(context.time*20.051f+5.4f));
glProgramUniform4f(program, glGetUniformLocation(program, "_c9"), 0.5f+0.5f*sinf(context.time* 0.329f+1.2f),
glUniform4f(glGetUniformLocation(program, "_c9"), 0.5f+0.5f*sinf(context.time* 0.329f+1.2f),
0.5f+0.5f*sinf(context.time* 1.293f+3.9f),
0.5f+0.5f*sinf(context.time* 5.070f+2.5f),
0.5f+0.5f*sinf(context.time*20.051f+5.4f));
glProgramUniform4f(program, glGetUniformLocation(program, "_c10"), 0.5f+0.5f*cosf(context.time*0.0050f+2.7f),
glUniform4f(glGetUniformLocation(program, "_c10"), 0.5f+0.5f*cosf(context.time*0.0050f+2.7f),
0.5f+0.5f*cosf(context.time*0.0085f+5.3f),
0.5f+0.5f*cosf(context.time*0.0133f+4.5f),
0.5f+0.5f*cosf(context.time*0.0217f+3.8f));
glProgramUniform4f(program, glGetUniformLocation(program, "_c11"), 0.5f+0.5f*sinf(context.time*0.0050f+2.7f),
glUniform4f(glGetUniformLocation(program, "_c11"), 0.5f+0.5f*sinf(context.time*0.0050f+2.7f),
0.5f+0.5f*sinf(context.time*0.0085f+5.3f),
0.5f+0.5f*sinf(context.time*0.0133f+4.5f),
0.5f+0.5f*sinf(context.time*0.0217f+3.8f));
glProgramUniform4f(program, glGetUniformLocation(program, "_c12"), mip_x, mip_y, mip_avg, 0 );
glProgramUniform4f(program, glGetUniformLocation(program, "_c13"), pipeline.blur2n, pipeline.blur2x, pipeline.blur3n, pipeline.blur3x);
glUniform4f(glGetUniformLocation(program, "_c12"), mip_x, mip_y, mip_avg, 0 );
glUniform4f(glGetUniformLocation(program, "_c13"), pipeline.blur2n, pipeline.blur2x, pipeline.blur3n, pipeline.blur3x);
glm::mat4 temp_mat[24];
@ -825,36 +825,36 @@ void ShaderEngine::SetupShaderVariables(GLuint program, const Pipeline &pipeline
temp_mat[i] = my * temp_mat[i];
}
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_s1"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[0])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_s2"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[1])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_s3"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[2])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_s4"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[3])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_d1"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[4])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_d2"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[5])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_d3"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[6])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_d4"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[7])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_f1"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[8])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_f2"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[9])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_f3"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[10])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_f4"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[11])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_vf1"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[12])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_vf2"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[13])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_vf3"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[14])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_vf4"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[15])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_uf1"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[16])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_uf2"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[17])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_uf3"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[18])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_uf4"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[19])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_rand1"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[20])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_rand2"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[21])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_rand3"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[22])));
glProgramUniformMatrix4x3fv(program, glGetUniformLocation(program, "rot_rand4"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[23])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_s1"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[0])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_s2"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[1])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_s3"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[2])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_s4"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[3])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_d1"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[4])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_d2"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[5])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_d3"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[6])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_d4"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[7])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_f1"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[8])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_f2"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[9])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_f3"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[10])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_f4"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[11])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_vf1"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[12])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_vf2"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[13])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_vf3"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[14])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_vf4"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[15])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_uf1"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[16])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_uf2"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[17])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_uf3"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[18])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_uf4"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[19])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_rand1"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[20])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_rand2"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[21])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_rand3"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[22])));
glUniformMatrix4x3fv(glGetUniformLocation(program, "rot_rand4"), 1, GL_FALSE, glm::value_ptr(glm::mat4x3(temp_mat[23])));
// set program uniform "_q[a-h]" values (_qa.x, _qa.y, _qa.z, _qa.w, _qb.x, _qb.y ... ) alias q[1-32]
for (int i=0; i < 32; i+=4) {
std::string varName = "_q";
varName.push_back('a' + i/4);
glProgramUniform4f(program, glGetUniformLocation(program, varName.c_str()), pipeline.q[i], pipeline.q[i+1], pipeline.q[i+2], pipeline.q[i+3]);
glUniform4f(glGetUniformLocation(program, varName.c_str()), pipeline.q[i], pipeline.q[i+1], pipeline.q[i+2], pipeline.q[i+3]);
}
}
@ -887,8 +887,8 @@ void ShaderEngine::SetupTextures(GLuint program, const Shader &shader)
std::string texsizeName = "texsize_" + texName;
GLint textSizeParam = glGetUniformLocation(program, texsizeName.c_str());
if (param >= 0) {
glProgramUniform4f(program, textSizeParam, texture->width, texture->height,
1 / (float) texture->width, 1 / (float) texture->height);
glUniform4f(textSizeParam, texture->width, texture->height,
1 / (float) texture->width, 1 / (float) texture->height);
} else {
std::cerr << "invalid texsize name " << texsizeName << std::endl;
return;

View File

@ -82,7 +82,7 @@ TextureManager::TextureManager(const std::string _presetsURL, const int texsizeX
GLuint noise_texture_lq_lite;
glGenTextures(1, &noise_texture_lq_lite);
glBindTexture(GL_TEXTURE_2D, noise_texture_lq_lite);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_LUMINANCE, GL_FLOAT, noise.noise_lq_lite);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGB, GL_FLOAT, noise.noise_lq_lite);
Texture * textureNoise_lq_lite = new Texture(noise_texture_lq_lite, GL_TEXTURE_2D, 32, 32, false);
textureNoise_lq_lite->getSampler(GL_REPEAT, GL_LINEAR);
textures["noise_lq_lite"] = textureNoise_lq_lite;
@ -90,7 +90,7 @@ TextureManager::TextureManager(const std::string _presetsURL, const int texsizeX
GLuint noise_texture_lq;
glGenTextures(1, &noise_texture_lq);
glBindTexture(GL_TEXTURE_2D, noise_texture_lq);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_LUMINANCE, GL_FLOAT, noise.noise_lq);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGB, GL_FLOAT, noise.noise_lq);
Texture * textureNoise_lq = new Texture(noise_texture_lq, GL_TEXTURE_2D, 256, 256, false);
textureNoise_lq->getSampler(GL_REPEAT, GL_LINEAR);
textures["noise_lq"] = textureNoise_lq;
@ -98,7 +98,7 @@ TextureManager::TextureManager(const std::string _presetsURL, const int texsizeX
GLuint noise_texture_mq;
glGenTextures(1, &noise_texture_mq);
glBindTexture(GL_TEXTURE_2D, noise_texture_mq);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_LUMINANCE, GL_FLOAT, noise.noise_mq);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGB, GL_FLOAT, noise.noise_mq);
Texture * textureNoise_mq = new Texture(noise_texture_mq, GL_TEXTURE_2D, 256, 256, false);
textureNoise_mq->getSampler(GL_REPEAT, GL_LINEAR);
textures["noise_mq"] = textureNoise_mq;
@ -106,7 +106,7 @@ TextureManager::TextureManager(const std::string _presetsURL, const int texsizeX
GLuint noise_texture_hq;
glGenTextures(1, &noise_texture_hq);
glBindTexture(GL_TEXTURE_2D, noise_texture_hq);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_LUMINANCE, GL_FLOAT, noise.noise_hq);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGB, GL_FLOAT, noise.noise_hq);
Texture * textureNoise_hq = new Texture(noise_texture_hq, GL_TEXTURE_2D, 256, 256, false);
textureNoise_hq->getSampler(GL_REPEAT, GL_LINEAR);
textures["noise_hq"] = textureNoise_hq;
@ -114,7 +114,7 @@ TextureManager::TextureManager(const std::string _presetsURL, const int texsizeX
GLuint noise_texture_lq_vol;
glGenTextures( 1, &noise_texture_lq_vol );
glBindTexture( GL_TEXTURE_3D, noise_texture_lq_vol );
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 32 ,32 ,32 ,0 ,GL_LUMINANCE ,GL_FLOAT ,noise.noise_lq_vol);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 32 ,32 ,32 ,0 ,GL_RGB ,GL_FLOAT ,noise.noise_lq_vol);
Texture * textureNoise_lq_vol = new Texture(noise_texture_lq_vol, GL_TEXTURE_3D, 32, 32, false);
textureNoise_lq_vol->getSampler(GL_REPEAT, GL_LINEAR);
textures["noisevol_lq"] = textureNoise_lq_vol;
@ -122,7 +122,7 @@ TextureManager::TextureManager(const std::string _presetsURL, const int texsizeX
GLuint noise_texture_hq_vol;
glGenTextures( 1, &noise_texture_hq_vol );
glBindTexture( GL_TEXTURE_3D, noise_texture_hq_vol );
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 32, 32, 32, 0, GL_LUMINANCE, GL_FLOAT, noise.noise_hq_vol);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 32, 32, 32, 0, GL_RGB, GL_FLOAT, noise.noise_hq_vol);
Texture * textureNoise_hq_vol = new Texture(noise_texture_hq_vol, GL_TEXTURE_3D, 32, 32, false);
textureNoise_hq_vol->getSampler(GL_REPEAT, GL_LINEAR);
textures["noisevol_hq"] = textureNoise_hq_vol;
@ -196,7 +196,7 @@ TextureSamplerDesc TextureManager::getTexture(const std::string fullName, const
ExtractTextureSettings(fullName, wrap_mode, filter_mode, name);
if (textures.find(name) == textures.end())
{
return {NULL, NULL};
return TextureSamplerDesc(NULL, NULL);
}
if (fullName == name) {
@ -209,7 +209,7 @@ TextureSamplerDesc TextureManager::getTexture(const std::string fullName, const
Texture * texture = textures[name];
Sampler * sampler = texture->getSampler(wrap_mode, filter_mode);
return {texture, sampler};
return TextureSamplerDesc(texture, sampler);
}
@ -246,7 +246,7 @@ TextureSamplerDesc TextureManager::loadTexture(const std::string name, const std
if (tex == 0)
{
return {NULL, NULL};
return TextureSamplerDesc(NULL, NULL);
}
Texture * newTexture = new Texture(tex, GL_TEXTURE_2D, width, height, true);
@ -254,7 +254,7 @@ TextureSamplerDesc TextureManager::loadTexture(const std::string name, const std
textures[name] = newTexture;
return {newTexture, sampler};
return TextureSamplerDesc(newTexture, sampler);
}

View File

@ -13,8 +13,6 @@
#define FAKE_AUDIO 0
#if OGL_DEBUG
#include <GLES3/gl32.h>
void DebugLog(GLenum source,
GLenum type,
GLuint id,