void GUIFrame::addOrReplaceTexCoordsInfo(GUITexCoordDescriptor &info) { for (size_t t = 0; t < texCoords.size(); t++) if (texCoords[t].getType() == info.getType()) { texCoords[t].setTexCoords(info.getTexCoords()); return; } texCoords.push_back(info); }
void GUICheckBox::render(float clockTick) { if (!parent || !visible) return; modifyCurrentAlpha(clockTick); getCenter(); GUITexCoordDescriptor *descriptor = parent->getTexCoordsInfo(primaryTexDesc), *descriptorCB = parent->getTexCoordsInfo(secondaryTexDesc); int yCenter = (windowBounds.y + windowBounds.w)/2; glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4fv(color); if (descriptor) { const Tuple4f &texCoords = descriptor->getTexCoords(); parent->enableGUITexture(); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(texCoords.x, texCoords.y); glVertex2i(windowBounds.x, windowBounds.y); glTexCoord2f(texCoords.x, texCoords.w); glVertex2i(windowBounds.x, windowBounds.w); glTexCoord2f(texCoords.z, texCoords.y); glVertex2i(windowBounds.x + extra, windowBounds.y); glTexCoord2f(texCoords.z, texCoords.w); glVertex2i(windowBounds.x + extra, windowBounds.w); glEnd(); parent->disableGUITexture(); } else { glBegin(GL_TRIANGLE_STRIP); glVertex2i(windowBounds.x, windowBounds.y); glVertex2i(windowBounds.x, windowBounds.w); glVertex2i(windowBounds.x + extra, windowBounds.y); glVertex2i(windowBounds.x + extra, windowBounds.w); glEnd(); } if (!checked) setAlphaMark(alphaMark - clockTick*alphaFadeScale*4.0f); else setAlphaMark(alphaMark + clockTick*alphaFadeScale*4.0f); if (alphaMark != minAlphaMark) { glColor4f(1.0f, 1.0f, 1.0f, alphaMark); if (descriptorCB) { const Tuple4f &texCoords = descriptorCB->getTexCoords(); parent->enableGUITexture(); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(texCoords.x, texCoords.y); glVertex2i(windowBounds.x + markOffset, windowBounds.y + markOffset); glTexCoord2f(texCoords.x, texCoords.w); glVertex2i(windowBounds.x + markOffset, windowBounds.w - markOffset); glTexCoord2f(texCoords.z, texCoords.y); glVertex2i(windowBounds.x - markOffset + extra, windowBounds.y + markOffset); glTexCoord2f(texCoords.z, texCoords.w); glVertex2i(windowBounds.x - markOffset + extra, windowBounds.w - markOffset); glEnd(); parent->disableGUITexture(); } else { glBegin(GL_TRIANGLE_STRIP); glVertex2i(windowBounds.x + markOffset, windowBounds.y + markOffset); glVertex2i(windowBounds.x + markOffset, windowBounds.w - markOffset); glVertex2i(windowBounds.x - markOffset + extra, windowBounds.y + markOffset); glVertex2i(windowBounds.x - markOffset + extra, windowBounds.w - markOffset); glEnd(); } } glDisable(GL_BLEND); label.printCenteredY(windowBounds.x + extra + 2, yCenter); }