217 mDepthTex.internalFormat = GL_DEPTH_COMPONENT32;
240 const GLenum buffers[] = {
241 GL_COLOR_ATTACHMENT0,
268 std::vector<RenderItem> items;
269 for (
auto iter =
scene->begin(); iter !=
scene->end(); iter++) {
270 for (
auto m : iter->graphicsPipeline()->activeModules()) {
271 if (
auto vm = std::dynamic_pointer_cast<GLVisualModule>(m))
272 items.push_back({ iter.get(), vm });
278 if (std::find(items.begin(), items.end(), item) == items.end())
279 item.visualModule->release();
290 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fbo);
294 glGetFramebufferParameteriv(GL_FRAMEBUFFER, GL_SAMPLES, &samples);
299 else if (samples > 0) {
321 const unsigned int attachments[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
325 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
332 Vec3f(this->
bgColor1.x, this->bgColor1.y, this->bgColor1.z));
341 GLint clearIndex[] = { -1, -1, -1, -1 };
342 glClearBufferiv(GL_COLOR, 1, clearIndex);
373 Vec4f(this->
planeColor.r, this->planeColor.g, this->planeColor.b, this->planeColor.a),
374 Vec4f(this->
rulerColor.r, this->rulerColor.g, this->rulerColor.b, this->rulerColor.a));
384 const int clear = 0xFFFFFFFF;
388 glBindImageTexture(0,
mHeadIndexTex.id, 0, GL_FALSE, 0, GL_READ_WRITE, GL_R32UI);
411 glDisable(GL_DEPTH_TEST);
413 glBlendEquationSeparate(GL_FUNC_ADD, GL_MAX);
415 glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
417 glEnable(GL_DEPTH_TEST);
425 auto p0 =
scene->getLowerBound();
426 auto p1 =
scene->getUpperBound();
433 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
437 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
447 glReadBuffer(GL_COLOR_ATTACHMENT0);
451 GL_COLOR_BUFFER_BIT, GL_LINEAR);
485 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fbo);
490 glReadBuffer(GL_COLOR_ATTACHMENT1);
491 glDrawBuffer(GL_COLOR_ATTACHMENT0);
492 glBlitFramebuffer(x, y, x+w, y+h, x, y, x+w, y+h, GL_COLOR_BUFFER_BIT, GL_NEAREST);
495 std::vector<glm::ivec4> indices(w * h);
498 glReadBuffer(GL_COLOR_ATTACHMENT0);
500 glReadPixels(x, y, w, h, GL_RGBA_INTEGER, GL_INT, indices.data());
503 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
508 std::unordered_set<glm::ivec4> uniqueIdx(indices.begin(), indices.end());
516 for (
const auto& idx : uniqueIdx) {
517 const int nodeIdx = idx.x;
518 const int instIdx = idx.y;
519 const int primIdx = idx.z;
static Program * createProgramSPIRV(const void *vs, size_t vs_len, const void *fs, size_t fs_len, const void *gs=0, size_t gs_len=0)