MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/MaterialX / renderFrame

Method renderFrame

source/MaterialXGraphEditor/RenderView.cpp:743–861  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

741}
742
743void RenderView::renderFrame()
744{
745 // Initialize OpenGL state
746 glDisable(GL_BLEND);
747 glEnable(GL_DEPTH_TEST);
748 glDepthMask(GL_TRUE);
749 glDepthFunc(GL_LEQUAL);
750 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
751 glDisable(GL_CULL_FACE);
752 glDisable(GL_FRAMEBUFFER_SRGB);
753
754 // Update lighting state.
755 _lightHandler->setLightTransform(mx::Matrix44::createRotationY(_lightRotation / 180.0f * PI));
756
757 // Update shadow state.
758 mx::ShadowState shadowState;
759 mx::NodePtr dirLight = _lightHandler->getFirstLightOfCategory(DIR_LIGHT_NODE_CATEGORY);
760 if (_genContext.getOptions().hwShadowMap && dirLight)
761 {
762 mx::ImagePtr shadowMap = getShadowMap();
763 if (shadowMap)
764 {
765 shadowState.shadowMap = shadowMap;
766 shadowState.shadowMatrix = _viewCamera->getWorldMatrix().getInverse() *
767 _shadowCamera->getWorldViewProjMatrix();
768 }
769 else
770 {
771 _genContext.getOptions().hwShadowMap = false;
772 }
773 }
774
775 // Initialize viewport render.
776 if (!_renderFrame ||
777 _renderFrame->getWidth() != (unsigned int) _viewWidth ||
778 _renderFrame->getHeight() != (unsigned int) _viewHeight)
779 {
780 _renderFrame = mx::GLFramebuffer::create((unsigned int) _viewWidth, (unsigned int) _viewHeight,
781 4, mx::Image::BaseType::UINT8);
782 }
783
784 _renderFrame->bind();
785
786 mx::Color3 screenColor(mx::DEFAULT_SCREEN_COLOR_SRGB);
787 glClearColor(screenColor[0], screenColor[1], screenColor[2], 1.0f);
788 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
789 glEnable(GL_FRAMEBUFFER_SRGB);
790
791 // Enable backface culling if requested.
792 if (!_renderDoubleSided)
793 {
794 glEnable(GL_CULL_FACE);
795 glCullFace(GL_BACK);
796 }
797
798 // Opaque pass
799 for (const auto& assignment : _materialAssignments)
800 {

Callers

nothing calls this directly

Calls 15

createValueFunction · 0.85
findParentMeshMethod · 0.80
elapsedTimeMethod · 0.80
hasTransparencyMethod · 0.80
createFunction · 0.50
bindMethod · 0.45
bindShaderMethod · 0.45
bindMeshMethod · 0.45
hasUniformMethod · 0.45
getProgramMethod · 0.45
bindUniformMethod · 0.45
bindTimeAndFrameMethod · 0.45

Tested by

no test coverage detected