void Texture::init() { registerAttributes(); _type = "texture"; _timestamp = chrono::high_resolution_clock::now(); }
void Texture::init() { _type = "texture"; registerAttributes(); // If the root object weak_ptr is expired, this means that // this object has been created outside of a World or Scene. // This is used for getting documentation "offline" if (_root.expired()) return; _timestamp = Timer::getTime(); }
void Image_GPhoto::init() { _type = "image_gphoto"; registerAttributes(); // This is used for getting documentation "offline" if (!_root) return; lock_guard<recursive_mutex> lock(_gpMutex); _gpContext = gp_context_new(); gp_abilities_list_new(&_gpCams); gp_abilities_list_load(_gpCams, _gpContext); Log::get() << Log::MESSAGE << "Image_GPhoto::" << __FUNCTION__ << " - Loaded " << gp_abilities_list_count(_gpCams) << " camera drivers" << Log::endl; detectCameras(); }
Window::Window(RootObjectWeakPtr root) : BaseObject(root) { _type = "window"; ScenePtr scene = dynamic_pointer_cast<Scene>(root.lock()); GlWindowPtr w = scene->getNewSharedWindow(); if (w.get() == nullptr) return; _window = w; _isInitialized = setProjectionSurface(); if (!_isInitialized) Log::get() << Log::WARNING << "Window::" << __FUNCTION__ << " - Error while creating the Window" << Log::endl; else Log::get() << Log::MESSAGE << "Window::" << __FUNCTION__ << " - Window created successfully" << Log::endl; _viewProjectionMatrix = glm::ortho(-1.f, 1.f, -1.f, 1.f); setEventsCallbacks(); registerAttributes(); showCursor(false); // Get the default window size and position glfwGetWindowPos(_window->get(), &_windowRect[0], &_windowRect[1]); glfwGetFramebufferSize(_window->get(), &_windowRect[2], &_windowRect[3]); // Create the render FBO glGetError(); glGenFramebuffers(1, &_renderFbo); setupRenderFBO(); glBindFramebuffer(GL_FRAMEBUFFER, _renderFbo); GLenum _status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (_status != GL_FRAMEBUFFER_COMPLETE) Log::get() << Log::WARNING << "Window::" << __FUNCTION__ << " - Error while initializing render framebuffer object: " << _status << Log::endl; else Log::get() << Log::MESSAGE << "Window::" << __FUNCTION__ << " - Render framebuffer object successfully initialized" << Log::endl; glBindFramebuffer(GL_FRAMEBUFFER, 0); // And the read framebuffer setupReadFBO(); }
void Filter::init() { _type = "filter"; // Intialize FBO, textures and everything OpenGL glGetError(); glGenFramebuffers(1, &_fbo); setOutput(); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _fbo); GLenum _status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (_status != GL_FRAMEBUFFER_COMPLETE) { Log::get() << Log::WARNING << "Filter::" << __FUNCTION__ << " - Error while initializing framebuffer object: " << _status << Log::endl; return; } else Log::get() << Log::MESSAGE << "Filter::" << __FUNCTION__ << " - Framebuffer object successfully initialized" << Log::endl; glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); GLenum error = glGetError(); if (error) { Log::get() << Log::WARNING << "Filter::" << __FUNCTION__ << " - Error while binding framebuffer" << Log::endl; _isInitialized = false; } else { Log::get() << Log::MESSAGE << "Filter::" << __FUNCTION__ << " - Filter correctly initialized" << Log::endl; _isInitialized = true; } registerAttributes(); }
LtcClock::LtcClock(bool masterClock, const string& deviceName) { registerAttributes(); _listener = unique_ptr<Listener>(new Listener()); _listener->setParameters(1, 0, Listener::SAMPLE_FMT_U8, deviceName); if (!_listener) { _listener.reset(); return; } _masterClock = masterClock; _continue = true; Log::get() << Log::MESSAGE << "LtcClock::" << __FUNCTION__ << " - Input clock enabled" << Log::endl; _ltcThread = thread([&]() { LTCDecoder* ltcDecoder = ltc_decoder_create(1920, 32); LTCFrameExt ltcFrame; vector<uint8_t> inputBuffer(256); long int total = 0; while (_continue) { if (!_listener->readFromQueue(inputBuffer)) { this_thread::sleep_for(chrono::milliseconds(5)); continue; } // Check all values to check whether the clock is paused or not bool paused = true; for (auto& v : inputBuffer) { if (v < 126 || v > 129) // This is for noise handling. There is not enough room for a clock in between. { paused = false; break; } } _clock.paused = paused; ltc_decoder_write(ltcDecoder, (ltcsnd_sample_t*)inputBuffer.data(), inputBuffer.size(), total); total += inputBuffer.size(); while (ltc_decoder_read(ltcDecoder, <cFrame)) { _ready = true; SMPTETimecode stime; ltc_frame_to_time(&stime, <cFrame.ltc, LTC_TC_CLOCK); Clock clock; clock.years = stime.years; clock.months = stime.months; clock.days = stime.days; clock.hours = stime.hours; clock.mins = stime.mins; clock.secs = stime.secs; // This updates the maximum frames per second, to be able to handle any framerate if (stime.frame == 0) { // Only accept some specific values if (_previousFrame == 24 || _previousFrame == 25 || _previousFrame == 30 || _previousFrame == 60) { // Small trick to handle errors if (_framerateChanged) { _maximumFramePerSec = _previousFrame + 1; _framerateChanged = false; } else { _framerateChanged = true; } } } _previousFrame = stime.frame; clock.frame = stime.frame * 120 / _maximumFramePerSec; _clock = clock; } if (_masterClock) { Values v; getClock(v); Timer::get().setMasterClock(v); } } ltc_decoder_free(ltcDecoder); }); }