/* The tick is current time in milliseconds, width and height * are the image dimensions to be rendered. */ void appRender(long tick, int width, int height) { if (sStartTick == 0) sStartTick = tick; if (!gAppAlive) return; // Actual tick value is "blurred" a little bit. sTick = (sTick + tick - sStartTick) >> 1; // Terminate application after running through the demonstration once. if (sTick >= RUN_LENGTH) { gAppAlive = 0; return; } // Prepare OpenGL ES for rendering of the frame. prepareFrame(width, height); // Update the camera position and set the lookat. camTrack(); // Configure environment. configureLightAndMaterial(); // Draw the reflection by drawing models with negated Z-axis. glPushMatrix(); drawModels(-1); glPopMatrix(); // Blend the ground plane to the window. drawGroundPlane(); // Draw all the models normally. drawModels(1); // Draw fade quad over whole window (when changing cameras). drawFadeQuad(); }
void appRender(long tick, int width, int height) { if (sStartTick == 0) sStartTick = tick; if (!gAppAlive) return; sTick = (sTick + tick - sStartTick) >> 1; if (sTick >= RUN_LENGTH) { gAppAlive = 0; return; } prepareFrame(width, height); camTrack(); configureLightAndMaterial(); glPushMatrix(); drawModels(-1); glPopMatrix(); drawGroundPlane(); drawModels(1); drawFadeQuad(); }
GridElement::GridElement( const hydroqguielementutil::GuiElementInfo &guiElementInfo, double wireGridSpacing, double groundPlaneSquareSpacing ) : GuiElement3d(guiElementInfo), wireGridSpacing_(wireGridSpacing), groundPlaneSquareSpacing_(groundPlaneSquareSpacing) { root_ = new osg::Group(); drawGroundPlane(); root_->addChild( groundPlaneGeode_.get() ); drawOrigin(); root_->addChild( originGeode_.get() ); viewOffset_ = new osg::PositionAttitudeTransform(); root_->addChild( viewOffset_.get() ); drawWireGrid(); viewOffset_->addChild( wireGridGeode_.get() ); // drawLabels(); }
void View::paintGL() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); camera3D(); // Don't paint if we haven't gotten a resize yet #ifdef USE_SHADER_MATERIALS if (normalDepthTexture.getWidth() * normalDepthTexture.getHeight() == 0) return; #endif // position lights float position0[4] = { 0, 1, 0, 0 }; float position1[4] = { 0, -1, 0, 0 }; glLightfv(GL_LIGHT0, GL_POSITION, position0); glLightfv(GL_LIGHT1, GL_POSITION, position1); if (mode == MODE_SCULPT_MESH) { #ifdef USE_SHADER_MATERIALS normalDepthTexture.startDrawingTo(depthTexture); normalDepthShader.use(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); drawMesh(true); normalDepthShader.unuse(); normalDepthTexture.stopDrawingTo(); camera2D(); glDepthFunc(GL_ALWAYS); normalDepthTexture.bind(0); depthTexture.bind(1); finalCompositeShaders[currentMaterial].use(); finalCompositeShaders[currentMaterial].uniform("windowSize", width(), height()); finalCompositeShaders[currentMaterial].texture("depthTexture", 1); drawFullscreenQuad(); finalCompositeShaders[currentMaterial].unuse(); depthTexture.unbind(1); normalDepthTexture.unbind(0); glDepthFunc(GL_LESS); camera3D(); #else drawMesh(true); #endif drawGroundPlane(); } else if (mode == MODE_VIEW_MESH || mode == MODE_ANIMATE_MESH) { drawMesh(false); drawGroundPlane(); drawSkeleton(true); } else { drawSkeleton(false); drawGroundPlane(); } if (drawToolDebug) foreach (Tool *tool, tools) tool->drawDebug(mouseX, mouseY); }