mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-02-16 12:05:24 +00:00
Fix "idle" preset by re-enabling custom textures on shapes.
Renamed the parameter to "image" and fixed texture wrapping/sizing.
This commit is contained in:
@ -124,6 +124,9 @@ CustomShape::CustomShape(int _id)
|
||||
MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0), &this->param_tree);
|
||||
}
|
||||
|
||||
// projectM custom addition: Specify a texture file for use on shapes!
|
||||
ParamUtils::insert(Param::new_param_string("image", P_FLAG_READONLY, &this->image), &this->text_properties_tree);
|
||||
|
||||
}
|
||||
|
||||
/* Frees a custom shape form object */
|
||||
|
||||
@ -75,17 +75,17 @@ std::string IdlePresets::presetText()
|
||||
"mv_b=1.000000\n" <<
|
||||
"mv_a=0.000000\n" <<
|
||||
"shapecode_3_enabled=1\n" <<
|
||||
"shapecode_3_sides=20\n" <<
|
||||
"shapecode_3_sides=4\n" <<
|
||||
"shapecode_3_additive=0\n" <<
|
||||
"shapecode_3_thickOutline=0\n" <<
|
||||
"shapecode_3_textured=1\n" <<
|
||||
"shapecode_3_ImageURL=M.tga\n" <<
|
||||
"shapecode_3_image=m\n" <<
|
||||
"shapecode_3_x=0.68\n" <<
|
||||
"shapecode_3_y=0.5\n" <<
|
||||
"shapecode_3_rad=0.41222\n" <<
|
||||
"shapecode_3_ang=0\n" <<
|
||||
"shapecode_3_tex_ang=0\n" <<
|
||||
"shapecode_3_tex_zoom=0.71\n" <<
|
||||
"shapecode_3_tex_zoom=0.5\n" <<
|
||||
"shapecode_3_r=1\n" <<
|
||||
"shapecode_3_g=1\n" <<
|
||||
"shapecode_3_b=1\n" <<
|
||||
@ -111,13 +111,13 @@ std::string IdlePresets::presetText()
|
||||
"shapecode_4_additive=0\n" <<
|
||||
"shapecode_4_thickOutline=0\n" <<
|
||||
"shapecode_4_textured=1\n" <<
|
||||
"shapecode_4_ImageURL=headphones.tga\n" <<
|
||||
"shapecode_4_image=headphones\n" <<
|
||||
"shapecode_4_x=0.68\n" <<
|
||||
"shapecode_4_y=0.58\n" <<
|
||||
"shapecode_4_rad=0.6\n" <<
|
||||
"shapecode_4_ang=0\n" <<
|
||||
"shapecode_4_tex_ang=0\n" <<
|
||||
"shapecode_4_tex_zoom=0.71\n" <<
|
||||
"shapecode_4_tex_zoom=0.5\n" <<
|
||||
"shapecode_4_r=1\n" <<
|
||||
"shapecode_4_g=1\n" <<
|
||||
"shapecode_4_b=1\n" <<
|
||||
@ -141,13 +141,13 @@ std::string IdlePresets::presetText()
|
||||
// "shapecode_6_additive=0\n" <<
|
||||
// "shapecode_6_thickOutline=0\n" <<
|
||||
// "shapecode_6_textured=1\n" <<
|
||||
// "shapecode_6_ImageURL=project.tga\n" <<
|
||||
// "shapecode_6_image=project.tga\n" <<
|
||||
// "shapecode_6_x=0.38\n" <<
|
||||
// "shapecode_6_y=0.435\n" <<
|
||||
// "shapecode_6_rad=0.8\n" <<
|
||||
// "shapecode_6_ang=0\n" <<
|
||||
// "shapecode_6_tex_ang=0\n" <<
|
||||
// "shapecode_6_tex_zoom=0.71\n" <<
|
||||
// "shapecode_6_tex_zoom=0.5\n" <<
|
||||
// "shapecode_6_r=1\n" <<
|
||||
// "shapecode_6_g=1\n" <<
|
||||
// "shapecode_6_b=1\n" <<
|
||||
|
||||
@ -120,7 +120,7 @@ protected:
|
||||
target.enabled = interpolate(lhs->enabled, rhs->enabled, ratio);
|
||||
|
||||
target.masterAlpha = interpolate(lhs->masterAlpha, rhs->masterAlpha, ratio);
|
||||
target.imageUrl = (ratio > 0.5) ? lhs->imageUrl : rhs->imageUrl;
|
||||
target.image = (ratio > 0.5) ? lhs->image : rhs->image;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -92,8 +92,27 @@ void Shape::Draw(RenderContext& context)
|
||||
|
||||
if (textured)
|
||||
{
|
||||
auto textureAspectY = context.aspectY;
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, context.textureManager->getMainTexture()->texID);
|
||||
if (image.empty())
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, context.textureManager->getMainTexture()->texID);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto texture = context.textureManager->getTexture(image, GL_CLAMP_TO_BORDER, GL_LINEAR);
|
||||
if (texture.first)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, texture.first->texID);
|
||||
glBindSampler(0, texture.second->samplerID);
|
||||
textureAspectY = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No texture found, fall back to main texture.
|
||||
glBindTexture(GL_TEXTURE_2D, context.textureManager->getMainTexture()->texID);
|
||||
}
|
||||
}
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
@ -102,7 +121,7 @@ void Shape::Draw(RenderContext& context)
|
||||
const float cornerProgress = static_cast<float>(i - 1) / static_cast<float>(sides);
|
||||
|
||||
vertexData[i].tex_x =
|
||||
0.5f + 0.5f * cosf(cornerProgress * pi * 2.0f + ang + pi * 0.25f) / tex_zoom * context.aspectY;
|
||||
0.5f + 0.5f * cosf(cornerProgress * pi * 2.0f + ang + pi * 0.25f) / tex_zoom * textureAspectY;
|
||||
vertexData[i].tex_y = 0.5f + 0.5f * sinf(cornerProgress * pi * 2.0f + ang + pi * 0.25f) / tex_zoom;
|
||||
}
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ public:
|
||||
|
||||
virtual void Draw(RenderContext& context);
|
||||
|
||||
std::string imageUrl; //!< Texture filename to be rendered on this shape
|
||||
std::string image; //!< Texture filename to be rendered on this shape
|
||||
|
||||
int sides{ 4 }; //!< Number of sides (vertices)
|
||||
bool thickOutline{ false }; //!< If true, the shape is rendered with a thick line, otherwise a single-pixel line.
|
||||
|
||||
@ -153,9 +153,9 @@ void TextureManager::Preload()
|
||||
,&width,&height);
|
||||
|
||||
|
||||
Texture * newTex = new Texture("M", tex, GL_TEXTURE_2D, width, height, true);
|
||||
Texture * newTex = new Texture("m", tex, GL_TEXTURE_2D, width, height, true);
|
||||
newTex->getSampler(GL_CLAMP_TO_EDGE, GL_LINEAR);
|
||||
textures["M"] = newTex;
|
||||
textures["m"] = newTex;
|
||||
|
||||
// tex = SOIL_load_OGL_texture_from_memory(
|
||||
// project_data,
|
||||
|
||||
Reference in New Issue
Block a user