void GrVkGpuRTCommandBuffer::executeDrawable(std::unique_ptr<SkDrawable::GpuDrawHandler> drawable) { GrVkRenderTarget* target = static_cast<GrVkRenderTarget*>(fRenderTarget); GrVkImage* targetImage = target->msaaImage() ? target->msaaImage() : target; CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo]; VkRect2D bounds; bounds.offset = { 0, 0 }; bounds.extent = { 0, 0 }; GrVkDrawableInfo vkInfo; vkInfo.fSecondaryCommandBuffer = cbInfo.currentCmdBuf()->vkCommandBuffer(); vkInfo.fCompatibleRenderPass = cbInfo.fRenderPass->vkRenderPass(); SkAssertResult(cbInfo.fRenderPass->colorAttachmentIndex(&vkInfo.fColorAttachmentIndex)); vkInfo.fFormat = targetImage->imageFormat(); vkInfo.fDrawBounds = &bounds; #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK vkInfo.fImage = targetImage->image(); #else vkInfo.fImage = VK_NULL_HANDLE; #endif //SK_BUILD_FOR_ANDROID_FRAMEWORK GrBackendDrawableInfo info(vkInfo); // After we draw into the command buffer via the drawable, cached state we have may be invalid. cbInfo.currentCmdBuf()->invalidateState(); // Also assume that the drawable produced output. cbInfo.fIsEmpty = false; drawable->draw(info); fGpu->addDrawable(std::move(drawable)); if (bounds.extent.width == 0 || bounds.extent.height == 0) { cbInfo.fBounds.join(target->getBoundsRect()); } else { cbInfo.fBounds.join(SkRect::MakeXYWH(bounds.offset.x, bounds.offset.y, bounds.extent.width, bounds.extent.height)); } }
void ImageBuffer::drawConsuming(std::unique_ptr<ImageBuffer> imageBuffer, GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode blendMode) { imageBuffer->draw(destContext, destRect, srcRect, op, blendMode); }
void draw(FontHolder& fonts, ModelHolder& models) noexcept override { view_->draw(fonts, models); }
void models_app::draw() { quad_->draw(); }
virtual void update() override { auto kbd = mEngine->get<Input>()->getKeyboardList().front(); // should mainKeyboard be a thing? auto mouse = mEngine->get<Input>()->getMouseList().front(); // should mainMouse be a thing? // [WASD keyboard controls] { auto cameraAxes = mCamera.getDirections(); glm::vec3 deltaPosition(0.0f, 0.0f, 0.0f); if ((*kbd)['W']) deltaPosition -= cameraAxes.mForward; if ((*kbd)['S']) deltaPosition += cameraAxes.mForward; if ((*kbd)['A']) deltaPosition -= cameraAxes.mRight; if ((*kbd)['D']) deltaPosition += cameraAxes.mRight; if ((*kbd)['Q']) deltaPosition += cameraAxes.mUp; if ((*kbd)['Z']) deltaPosition -= cameraAxes.mUp; if ((*kbd)[GLFW_KEY_LEFT_SHIFT]) deltaPosition *= 5; float elapsedSeconds = mEngine->getClock().deltaFrame().count() * 0.001f; // deltaframe is in milliseconds float movementSpeed = 1.0f * elapsedSeconds; deltaPosition *= movementSpeed; mCamera.setPosition(mCamera.getPosition() + deltaPosition); } // [Mouselook] ~ yaw/pitch based { static std::pair<double, double> previousMousePosition = std::make_pair(0.0, 0.0); auto currentPos = mouse->getPosition(); if ((previousMousePosition.first == 0.0) && (previousMousePosition.second == 0.0)) previousMousePosition = currentPos; float dx = 0.01f * static_cast<float>(currentPos.first - previousMousePosition.first); float dy = 0.01f * static_cast<float>(currentPos.second - previousMousePosition.second); previousMousePosition = currentPos; mCameraYaw += dx; mCameraPitch += dy; auto yawQ = glm::rotate(mCameraYaw, glm::vec3(0.0f, 1.0f, 0.0f)); auto pitchQ = glm::rotate(mCameraPitch, glm::vec3(1.0f, 0.0f, 0.0f)); glm::quat q = glm::quat_cast(pitchQ * yawQ); mCamera.setOrientation(q); } mCamera.update(); mRenderState.clear(); // render that skybox mSkyBoxProgram.bind(); mSkyBoxProgram.setUniform("uView", mCamera.getView()); mSkyBoxProgram.setUniform("uProjection", mCamera.getProjection()); mSkyBoxProgram.setUniform("uModel", glm::translate(mCamera.getPosition())); mSkyBoxTexture.bind(0); mSkyBoxProgram.setUniform("uCubeMap", 0); mSkyBox->draw(); // render the cubes mProgram.bind(); mProgram.setUniform("uView", mCamera.getView()); mProgram.setUniform("uProjection", mCamera.getProjection()); mProgram.setUniform("uLightDirection", glm::vec4(0.2, -1, 0.5, 1)); mProgram.setUniform("uLightAmbient", glm::vec4(0.1, 0.1, 0.1, 1.0)); mProgram.setUniform("uLightDiffuse", glm::vec4(0.85, 0.85, 0.85, 1.0)); mTexture.bind(0); mProgram.setUniform("uTexture", 0); // draw the cube at 100 different locations for (int i = 0; i < 10; ++i) for (int j = 0; j < 10; ++j) { mProgram.setUniform("uModel", glm::translate(glm::vec3(2 * (i - 5), 0, 2 * (j - 5)))); mSphere->draw(); //mCube->draw(); } }
/** * Draws the path. The default implementation adds a DebugRobotPath to the * SystemState that interpolates points along the path. * * @param state The SystemState to draw the path on * @param color The color the path should be drawn * @param layer The layer to draw the path on */ virtual void draw(SystemState* const state, const QColor& color = Qt::black, const QString& layer = "Motion") const override { path->draw(state, color, layer); }
// // メインプログラム // int main(int argc, const char *argv[]) { // GLFW を初期化する if (glfwInit() == GL_FALSE) { // 初期化に失敗した std::cerr << "Can't initialize GLFW" << std::endl; return 1; } // プログラム終了時の処理を登録する atexit(cleanup); // OpenGL Version 3.2 Core Profile を選択する glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // ウィンドウを作成する Window window("ggsample14"); // 背景色を指定する glClearColor(0.2f, 0.4f, 0.6f, 0.0f); // 隠面消去を有効にする glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); // 図形用のプログラムオブジェクト GgSimpleShader simple("simple.vert", "simple.frag"); // 点群のシェーダ GgPointShader point("point.vert", "point.frag", "point.geom"); // OBJ ファイルの読み込み const std::unique_ptr<const GgElements> object(ggElementsObj("bunny.obj")); // 点 const std::unique_ptr<const GgPoints> sphere(ggPointsSphere(100, 1.0f, 0.0f, 0.0f, 0.0f)); // ビュー変換行列を mv に求める const GgMatrix mv(ggLookat(0.0f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f)); // ウィンドウが開いている間くり返し描画する while (window.shouldClose() == GL_FALSE) { // 画面消去 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // 図形の描画 simple.use(); simple.setLightMaterial(light); simple.setLightPosition(light.position); simple.setMaterial(material); simple.loadMatrix(window.getMp(), mv); object->draw(); // 点群の描画 point.use(); point.loadMatrix(window.getMp(), mv * window.getTb()); sphere->draw(); // カラーバッファを入れ替えてイベントを取り出す window.swapBuffers(); } return 0; }
void drawScene() { static system_clock::time_point const start = system_clock::now(); scene->draw(duration<float>(system_clock::now() - start).count()); TwDraw(); }