mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-05 23:40:02 +01:00
Added option to choose mirror or repeat texture on source
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
|
||||
Surface::Surface(Shader *s) : Primitive(s), textureindex_(0)
|
||||
Surface::Surface(Shader *s) : Primitive(s), textureindex_(0), mirror_(true)
|
||||
{
|
||||
// geometry for a trianglulated simple rectangle surface with UV
|
||||
// (0,0) B +---+ D (1,0)
|
||||
@@ -89,12 +89,8 @@ void Surface::draw(glm::mat4 modelview, glm::mat4 projection)
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
if ( textureindex_ ) {
|
||||
glBindTexture(GL_TEXTURE_2D, textureindex_);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
|
||||
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // TODO add user input to select mode
|
||||
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, mirror_ ? GL_MIRRORED_REPEAT : GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, mirror_ ? GL_MIRRORED_REPEAT : GL_REPEAT);
|
||||
}
|
||||
else
|
||||
glBindTexture(GL_TEXTURE_2D, Resource::getTextureBlack());
|
||||
|
||||
@@ -30,8 +30,12 @@ public:
|
||||
inline void setTextureIndex(uint t) { textureindex_ = t; }
|
||||
inline uint textureIndex() const { return textureindex_; }
|
||||
|
||||
inline void setMirrorTexture(bool m) { mirror_ = m; }
|
||||
inline bool mirrorTexture() { return mirror_; }
|
||||
|
||||
protected:
|
||||
uint textureindex_;
|
||||
bool mirror_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -521,7 +521,12 @@ void SessionLoader::visit (Source& s)
|
||||
if (xmlCurrent_) s.groupNode(View::LAYER)->accept(*this);
|
||||
|
||||
xmlCurrent_ = sourceNode->FirstChildElement("Texture");
|
||||
if (xmlCurrent_) s.groupNode(View::TEXTURE)->accept(*this);
|
||||
if (xmlCurrent_) {
|
||||
s.groupNode(View::TEXTURE)->accept(*this);
|
||||
bool m = true;
|
||||
xmlCurrent_->QueryBoolAttribute("mirrored", &m);
|
||||
s.setTextureMirrored(m);
|
||||
}
|
||||
|
||||
xmlCurrent_ = sourceNode->FirstChildElement("Blending");
|
||||
if (xmlCurrent_) s.blendingShader()->accept(*this);
|
||||
|
||||
@@ -345,6 +345,7 @@ void SessionVisitor::visit (Source& s)
|
||||
s.groupNode(View::LAYER)->accept(*this);
|
||||
|
||||
xmlCurrent_ = xmlDoc_->NewElement( "Texture" );
|
||||
xmlCurrent_->SetAttribute("mirrored", s.textureMirrored() );
|
||||
sourceNode->InsertEndChild(xmlCurrent_);
|
||||
s.groupNode(View::TEXTURE)->accept(*this);
|
||||
|
||||
|
||||
10
Source.cpp
10
Source.cpp
@@ -350,6 +350,16 @@ void Source::setImageProcessingEnabled (bool on)
|
||||
texturesurface_->replaceShader(renderingshader_);
|
||||
}
|
||||
|
||||
void Source::setTextureMirrored (bool on)
|
||||
{
|
||||
texturesurface_->setMirrorTexture(on);
|
||||
}
|
||||
|
||||
bool Source::textureMirrored ()
|
||||
{
|
||||
return texturesurface_->mirrorTexture();
|
||||
}
|
||||
|
||||
bool Source::imageProcessingEnabled()
|
||||
{
|
||||
return ( renderingshader_ == processingshader_ );
|
||||
|
||||
2
Source.h
2
Source.h
@@ -119,6 +119,8 @@ public:
|
||||
|
||||
// a Source shall define a way to get a texture
|
||||
virtual uint texture () const = 0;
|
||||
void setTextureMirrored (bool on);
|
||||
bool textureMirrored ();
|
||||
|
||||
// a Source shall define how to render into the frame buffer
|
||||
virtual void render ();
|
||||
|
||||
@@ -828,6 +828,16 @@ void TextureView::draw()
|
||||
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(0.36f, 0.36f, 0.36f, 0.44f));
|
||||
Source *s = Mixer::manager().currentSource();
|
||||
if (s != nullptr) {
|
||||
|
||||
if (s->textureMirrored()) {
|
||||
if (ImGui::Selectable( ICON_FA_TH " Repeat " ))
|
||||
s->setTextureMirrored(false);
|
||||
} else {
|
||||
if (ImGui::Selectable( ICON_FA_TH " Mirror " ))
|
||||
s->setTextureMirrored(true);
|
||||
}
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::Selectable( ICON_FA_VECTOR_SQUARE " Reset" )){
|
||||
s->group(mode_)->scale_ = glm::vec3(1.f);
|
||||
s->group(mode_)->rotation_.z = 0;
|
||||
|
||||
Reference in New Issue
Block a user