bool NormalsPlugin::init() { tuiTab = new coTUITab("Normals", coVRTui::instance()->mainFolder->getID()); tuiTab->setPos(0, 0); faceNorm = new coTUIToggleButton("Face Normals", tuiTab->getID()); vertNorm = new coTUIToggleButton("Vertex Normals", tuiTab->getID()); faceNorm->setPos(0, 0); faceNorm->setEventListener(this); vertNorm->setPos(1, 0); vertNorm->setEventListener(this); scaleValue = 1.f; scaleLabel = new coTUILabel("Scale factor (log10)", tuiTab->getID()); scaleLabel->setPos(0, 1); scaleSlider = new coTUIFloatSlider("Scale", tuiTab->getID()); scaleSlider->setPos(1, 1); scaleSlider->setEventListener(this); scaleSlider->setMin(-5.f); scaleSlider->setMax(5.f); scaleSlider->setValue(log(scaleValue) / log(10.f)); update = new coTUIButton("Update", tuiTab->getID()); update->setPos(2, 2); applyState(); return true; }
FS_STATE* FontPlatformData::scaledFont(float scale) const { ASSERT(scale > 0.0); if (m_scale == scale && m_scaledFont) return m_scaledFont; // This must be an SVG Font. It seems like there is an upstream bug where web and SVG fonts // are used in one TextRun. Other ports seem to be able to deal with having an SVG Font in // this path so bail out instead of crash. if (!m_font) return 0; if (m_scaledFont) { BlackBerry::Platform::Graphics::clearGlyphCacheForFont(m_scaledFont); if (FS_end_client(m_scaledFont) != SUCCESS) CRASH(); } m_scaledFont = FS_new_client(m_font, 0); if (!applyState(m_scaledFont, scale)) { if (FS_end_client(m_scaledFont) != SUCCESS) CRASH(); m_scaledFont = 0; return 0; } m_scale = scale; return m_scaledFont; }
void StateManager::pushState(const std::string &s) { std::string state = s; stringToLower(state); if (canChangeState()) { if (states_full()) { debugLog("state stack overflow!!"); return; } StateData *s = new StateData; s->name = state; states[++statesTopIndex] = s; applyState(state); if (stateObjects[state]) { s->stateObject = stateObjects[state]; stateObjects[state]->applyState(); } stateChangeFlag = true; } }
void Openable::upgrade(DescriptionPtr dsc) { OpenableDescriptionPtr oDsc = std::dynamic_pointer_cast<OpenableDescription>(dsc); if ( oDsc ) { if ( oDsc->lockId ) _lockId = *oDsc->lockId; if ( oDsc->lockLevel ) _lockLevel = *oDsc->lockLevel; if ( oDsc->locked ) _locked = *oDsc->locked; if ( oDsc->scriptId ) _scriptId = *oDsc->scriptId; if ( oDsc->closed ) _closed = *oDsc->closed; if ( oDsc->openedState ) _openedState = *oDsc->openedState; if ( oDsc->closedState ) _closedState = *oDsc->closedState; } isClosed() ? applyState(_closedState) : applyState(_openedState); }
void QgsMapThemes::presetTriggered() { QAction *actionPreset = qobject_cast<QAction *>( sender() ); if ( !actionPreset ) return; applyState( actionPreset->text() ); }
void FontPlatformData::platformDataInit(const FontPlatformData& source) { m_harfbuzzFace = source.m_harfbuzzFace; m_scaledFont = 0; if (source.m_font && source.m_font != hashTableDeletedFontValue()) { m_font = FS_new_client(source.m_font, 0); m_name = fastStrDup(source.name()); bool ret = applyState(m_font); ASSERT_UNUSED(ret, ret); } else m_font = source.m_font; }
const FontPlatformData& FontPlatformData::platformDataAssign(const FontPlatformData& other) { m_harfbuzzFace = other.m_harfbuzzFace; m_scaledFont = 0; if (other.m_font && other.m_font != hashTableDeletedFontValue()) { m_font = FS_new_client(other.m_font, 0); fastFree(m_name); m_name = fastStrDup(other.name()); bool ret = applyState(m_font); ASSERT_UNUSED(ret, ret); } else m_font = other.m_font; return *this; }
FontPlatformData::FontPlatformData(FILECHAR* name, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, TextOrientation textOrientation, FontWidthVariant widthVariant) : m_syntheticBold(syntheticBold) , m_syntheticOblique(syntheticOblique) , m_orientation(orientation) , m_textOrientation(textOrientation) , m_size(size) , m_widthVariant(widthVariant) , m_font(0) , m_name(fastStrDup(name)) , m_scaledFont(0) , m_harfbuzzFace() , m_isColorBitmapFont(false) { ASSERT(name); m_font = FS_new_client(BlackBerry::Platform::Graphics::getIType(), 0); ASSERT(m_font); applyState(m_font); }
bool Openable::close(ActorPtr executor) { bool r = false; if ( !isClosed() ) { if ( applyState(_closedState) && executeScript("onClose", executor) ) { r = true; _closed = true; ActorPtr owner = getOwner().lock(); if ( owner ) owner->interract(executor); } } return r; }
// Render the bucket contents void OpenGLShaderPass::render(OpenGLState& current, unsigned int flagsMask, const Vector3& viewer) { // Reset the texture matrix glMatrixMode(GL_TEXTURE); glLoadMatrixd(Matrix4::getIdentity()); glMatrixMode(GL_MODELVIEW); // Apply our state to the current state object applyState(current, flagsMask, viewer); // If RENDER_SCREEN is set, just render a quad, otherwise render all // objects. if ((flagsMask & _state.renderFlags & RENDER_SCREEN) != 0) { glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadMatrixd(Matrix4::getIdentity()); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadMatrixd(Matrix4::getIdentity()); glBegin(GL_QUADS); glVertex3f(-1, -1, 0); glVertex3f(1, -1, 0); glVertex3f(1, 1, 0); glVertex3f(-1, 1, 0); glEnd(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); } else if(!_renderables.empty()) { renderAllContained(current, viewer); } }
void NormalsPlugin::keyEvent(int type, int keySym, int mod) { if (type == osgGA::GUIEventAdapter::KEYDOWN && (mod & osgGA::GUIEventAdapter::MODKEY_ALT) && keySym == 14) { // ALT+N pressed if (normalsState == NORM_ALL) { normalsState = NORM_NONE; } else normalsState = NormalsState(int(normalsState) + 1); } else { return; } applyState(); }
void NormalsPlugin::tabletEvent(coTUIElement *tUIItem) { bool changed = false; int s = normalsState; if (tUIItem == faceNorm) { changed = true; if (faceNorm->getState()) { s |= NORM_FACE; } else { s &= ~NORM_FACE; } } if (tUIItem == vertNorm) { changed = true; if (vertNorm->getState()) { s |= NORM_VERTEX; } else { s &= ~NORM_VERTEX; } } normalsState = NormalsState(s); if (tUIItem == scaleSlider) { changed = true; scaleValue = powf(10.f, scaleSlider->getValue()); } if (changed) applyState(); }
void StateManager::pushState(const std::string &s) { std::string state = s; stringToLower(state); if (canChangeState()) { StateData *s = new StateData; s->name = state; states.push (s); applyState(state); if (stateObjects[state]) { s->stateObject = stateObjects[state]; stateObjects[state]->applyState(); } stateChangeFlag = true; } }
void FontPlatformData::setFakeItalic(bool fakeItalic) { m_syntheticOblique = fakeItalic; applyState(m_font); }
gl::Error RendererD3D::drawArrays(const gl::Data &data, GLenum mode, GLint first, GLsizei count, GLsizei instances) { gl::Program *program = data.state->getProgram(); ASSERT(program != NULL); program->updateSamplerMapping(); gl::Error error = generateSwizzles(data); if (error.isError()) { return error; } if (!applyPrimitiveType(mode, count, program->usesPointSize())) { return gl::Error(GL_NO_ERROR); } error = applyRenderTarget(data, mode, false); if (error.isError()) { return error; } error = applyState(data, mode); if (error.isError()) { return error; } applyTransformFeedbackBuffers(*data.state); error = applyVertexBuffer(*data.state, mode, first, count, instances, nullptr); if (error.isError()) { return error; } error = applyShaders(data); if (error.isError()) { return error; } error = applyTextures(data); if (error.isError()) { return error; } error = program->applyUniformBuffers(data); if (error.isError()) { return error; } if (!skipDraw(data, mode)) { error = drawArrays(data, mode, count, instances, program->usesPointSize()); if (error.isError()) { return error; } if (data.state->isTransformFeedbackActiveUnpaused()) { markTransformFeedbackUsage(data); } } return gl::Error(GL_NO_ERROR); }
gl::Error RendererD3D::drawElements(const gl::Data &data, GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instances, const gl::RangeUI &indexRange) { if (data.state->isPrimitiveRestartEnabled()) { UNIMPLEMENTED(); return gl::Error(GL_INVALID_OPERATION, "Primitive restart not implemented"); } gl::Program *program = data.state->getProgram(); ASSERT(program != NULL); program->updateSamplerMapping(); gl::Error error = generateSwizzles(data); if (error.isError()) { return error; } if (!applyPrimitiveType(mode, count, program->usesPointSize())) { return gl::Error(GL_NO_ERROR); } error = applyRenderTarget(data, mode, false); if (error.isError()) { return error; } error = applyState(data, mode); if (error.isError()) { return error; } gl::VertexArray *vao = data.state->getVertexArray(); TranslatedIndexData indexInfo; indexInfo.indexRange = indexRange; SourceIndexData sourceIndexInfo; error = applyIndexBuffer(indices, vao->getElementArrayBuffer().get(), count, mode, type, &indexInfo, &sourceIndexInfo); if (error.isError()) { return error; } applyTransformFeedbackBuffers(*data.state); // Transform feedback is not allowed for DrawElements, this error should have been caught at the API validation // layer. ASSERT(!data.state->isTransformFeedbackActiveUnpaused()); GLsizei vertexCount = indexInfo.indexRange.length() + 1; error = applyVertexBuffer(*data.state, mode, indexInfo.indexRange.start, vertexCount, instances, &sourceIndexInfo); if (error.isError()) { return error; } error = applyShaders(data); if (error.isError()) { return error; } error = applyTextures(data); if (error.isError()) { return error; } error = program->applyUniformBuffers(data); if (error.isError()) { return error; } if (!skipDraw(data, mode)) { error = drawElements(mode, count, type, indices, vao->getElementArrayBuffer().get(), indexInfo, instances, program->usesPointSize()); if (error.isError()) { return error; } } return gl::Error(GL_NO_ERROR); }
void FontPlatformData::setFakeBold(bool fakeBold) { m_syntheticBold = fakeBold; applyState(m_font); }