void MGuiSlide::draw(void) { MRenderingContext * render = MGui::getInstance()->getRenderingContext(); if(! isVisible()) return; if(! isPressed()) updateFromVariable(); if(isPressed()) // pressed { render->setColor4(getPressedColor()); if(hasPressedTexture()) { render->enableTexture(); m_button.drawTexturedQuad(getPressedTexture()); } else { render->disableTexture(); m_button.drawQuad(); } } else if(isHighLight()) // highLight { render->setColor4(getHighLightColor()); if(hasHighLightTexture()){ render->enableTexture(); m_button.drawTexturedQuad(getHighLightTexture()); } else { render->disableTexture(); m_button.drawQuad(); } } else // normal { render->setColor4(getNormalColor()); if(hasNormalTexture()) { render->enableTexture(); m_button.drawTexturedQuad(getNormalTexture()); } else { render->disableTexture(); m_button.drawQuad(); } } MGuiEvent guiEvent; guiEvent.type = MGUI_EVENT_DRAW; if(m_pointerEvent) m_pointerEvent(this, &guiEvent); }
void MGuiImage::draw(void) { MRenderingContext * render = MGui::getInstance()->getRenderingContext(); if(! isVisible()) return; if(hasNormalTexture()) { render->setColor4(getNormalColor()); render->enableTexture(); drawTexturedQuad(getNormalTexture()); return; } render->setColor4(getNormalColor()); render->disableTexture(); drawQuad(); }
bool Material::isCompatible(const Material& other) const { if (this == &other) return true; // compatible, if using the same textures, or one uses textures and the // other doesn't, or both don't use any textures at all if (hasDiffuseTexture() && other.hasDiffuseTexture()) { if (getDiffuseTexture() != other.getDiffuseTexture()) return false; } if (hasSpecularTexture() && other.hasSpecularTexture()) { if (getSpecularTexture() != other.getSpecularTexture()) return false; } if (hasEmissiveTexture() && other.hasEmissiveTexture()) { if (getEmissiveTexture() != other.getEmissiveTexture()) return false; } if (hasGlossyTexture() && other.hasGlossyTexture()) { if (getGlossyTexture() != other.getGlossyTexture()) return false; } if (hasAlphaTexture() && other.hasAlphaTexture()) { if (getAlphaTexture() != other.getAlphaTexture()) return false; } if (hasNormalTexture() && other.hasNormalTexture()) { if (getNormalTexture() != other.getNormalTexture()) return false; } if (hasAmbientTexture() && other.hasAmbientTexture()) { if (getAmbientTexture() != other.getAmbientTexture()) return false; } return true; }
std::vector<const Image *> Material::getTextures() const { std::vector<const Image *> textures = {getDiffuseTexture(), getNormalTexture()}; return textures; }
void MGui2d::draw(void) { MRenderingContext * render = MGui::getInstance()->getRenderingContext(); if(! isVisible()) return; if(isPressed()) // pressed { render->setColor4(getPressedColor()); if(hasPressedTexture()) { render->enableTexture(); drawTexturedQuad(getPressedTexture()); } else { render->disableTexture(); drawQuad(); } } else if(isHighLight()) // highLight { render->setColor4(getHighLightColor()); if(hasHighLightTexture()){ render->enableTexture(); drawTexturedQuad(getHighLightTexture()); } else { render->disableTexture(); drawQuad(); } } else // normal { render->setColor4(getNormalColor()); if(hasNormalTexture()) { render->enableTexture(); drawTexturedQuad(getNormalTexture()); } else { render->disableTexture(); drawQuad(); } } if(isDrawingText() && (getText() != NULL)) { render->enableTexture(); render->setColor4(getTextColor()); getFont()->draw(getText(), getPosition(), getTextSize()); } // draw shadows if(hasShadow()) { render->pushMatrix(); render->translate(MVector3(getPosition().x, getPosition().y, 0)); drawShadow(); render->popMatrix(); } }
void MGuiWindow::draw(void) { MRenderingContext * render = MGui::getInstance()->getRenderingContext(); if(! isVisible()) return; MWindow * window = MWindow::getInstance(); rescaleScrollingBar(); render->enableScissorTest(); render->setScissor((int)getPosition().x, window->getHeight() - (int)getPosition().y - (unsigned int)getScale().y, (unsigned int)getScale().x, (unsigned int)getScale().y); // normal clear if((getNormalColor().w >= 1.0f) && (! hasNormalTexture())) { render->setClearColor(getNormalColor()); render->clear(M_BUFFER_COLOR); MGuiEvent guiEvent; guiEvent.type = MGUI_EVENT_DRAW; if(m_pointerEvent) m_pointerEvent(this, &guiEvent); // 2d mode set2dMode(render); render->disableDepthTest(); render->disableCullFace(); render->disableLighting(); render->enableBlending(); render->setBlendingMode(M_BLENDING_ALPHA); render->enableTexture(); } else { // background set2dMode(render); render->disableDepthTest(); render->disableCullFace(); render->disableLighting(); render->enableBlending(); render->setBlendingMode(M_BLENDING_ALPHA); if(hasNormalTexture()) // texture clear { render->enableTexture(); render->setColor4(getNormalColor()); drawTexturedQuad(getNormalTexture()); } else if(getNormalColor().w < 1.0f) { render->disableTexture(); render->setColor4(getNormalColor()); drawQuad(); } if(m_pointerEvent) { MGuiEvent guiEvent; guiEvent.type = MGUI_EVENT_DRAW; m_pointerEvent(this, &guiEvent); // 2d mode set2dMode(render); render->disableDepthTest(); render->disableCullFace(); render->disableLighting(); render->enableBlending(); render->setBlendingMode(M_BLENDING_ALPHA); render->enableTexture(); } } // gui render->pushMatrix(); render->translate(MVector3(getPosition().x, getPosition().y, 0)); render->pushMatrix(); render->translate(MVector3(getScroll().x, getScroll().y, 0)); // drawing unsigned int i; unsigned int oSize = m_objects.size(); for(i=0; i<oSize; i++) m_objects[i]->draw(); render->popMatrix(); // draw shadows if(hasShadow()) { render->disableScissorTest(); drawShadow(); render->enableScissorTest(); } // scolling slides if(isHorizontalScroll()) m_hScrollSlide.draw(); if(isVerticalScroll()) m_vScrollSlide.draw(); render->popMatrix(); }