From 2504d5fdaa31d4aff3fceb25030887673d60f97e Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Fri, 30 Sep 2016 09:23:54 +0300 Subject: [PATCH] Refactor TextureMappingMode::draw() --- src/Application/Modes/TextureMappingMode.cpp | 24 ++++++++------------ 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/Application/Modes/TextureMappingMode.cpp b/src/Application/Modes/TextureMappingMode.cpp index 65e9d8a..f962359 100644 --- a/src/Application/Modes/TextureMappingMode.cpp +++ b/src/Application/Modes/TextureMappingMode.cpp @@ -24,10 +24,12 @@ void TextureMappingMode::update(Application * app){ } void TextureMappingMode::draw(Application * app){ - ofPushMatrix(); - ofTranslate(_canvasTranslate.x, _canvasTranslate.y); - + + // TODO: Make state classes out of the following anti-code. + if(_drawMode == 0){ // Semi-transparent surfaces on front + ofPushMatrix(); + ofTranslate(_canvasTranslate.x, _canvasTranslate.y); drawTexture(app); ofPopMatrix(); @@ -35,10 +37,9 @@ void TextureMappingMode::draw(Application * app){ ofSetColor(255, 255, 255, 150); app->getSurfaceManager()->draw(); ofPopStyle(); - + }else if(_drawMode == 1){ // Opaque surfaces on front ofPushMatrix(); ofTranslate(_canvasTranslate.x, _canvasTranslate.y); - }else if(_drawMode == 1){ // Opaque surfaces on front drawTexture(app); ofPopMatrix(); @@ -46,30 +47,25 @@ void TextureMappingMode::draw(Application * app){ ofSetColor(255, 255, 255, 255); app->getSurfaceManager()->draw(); ofPopStyle(); - - ofPushMatrix(); - ofTranslate(_canvasTranslate.x, _canvasTranslate.y); }else if(_drawMode == 2){ // Draw texture only + ofPushMatrix(); ofTranslate(_canvasTranslate.x, _canvasTranslate.y); drawTexture(app); + ofPopMatrix(); }else{ _drawMode = 0; } if(_drawMode != 2){ - ofPopMatrix(); - Gui::instance()->getSurfaceHighlightWidget().setSurfaceManager(app->getSurfaceManager()); Gui::instance()->getSurfaceHighlightWidget().draw(); - - ofPushMatrix(); - ofTranslate(_canvasTranslate.x, _canvasTranslate.y); } + ofPushMatrix(); + ofTranslate(_canvasTranslate.x, _canvasTranslate.y); Gui::instance()->getTextureHighlightWidget().setSurfaceManager(app->getSurfaceManager()); Gui::instance()->getTextureHighlightWidget().draw(); Gui::instance()->getTextureEditorWidget().draw(); - ofPopMatrix(); }