From patchwork Thu Jul 26 16:09:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Barker X-Patchwork-Id: 10284 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 9055F23E23 for ; Thu, 26 Jul 2012 16:09:16 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 3A1B7A18198 for ; Thu, 26 Jul 2012 16:09:16 +0000 (UTC) Received: by yenq6 with SMTP id q6so2145097yen.11 for ; Thu, 26 Jul 2012 09:09:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :content-type:mime-version:x-launchpad-project:x-launchpad-branch :x-launchpad-message-rationale:x-launchpad-branch-revision-number :x-launchpad-notification-type:to:from:subject:message-id:date :reply-to:sender:errors-to:precedence:x-generated-by :x-launchpad-hash:x-gm-message-state; bh=h1G2Kq+u853WcxwL3SMXP4L/5q3c6OYg8/cXIJflHTw=; b=WXl8qkN4BNoWg6LUul6ribB+JWzeXDBzwSpLB1sMaR+r8HwhnqAKDscIi+2GQmB4lg sexE8aGgc2gGgfkALLFT/vEvVuaXmVGRwk2oPodm9hitf1ROXuA/R+tqBK2CZmoxTzKv LShEQHJ4ZDLrOmjoSj0gxQSLN7P9iwwLNHsFP6UTAwnXPHRjGMHtxfx4OpinD0FpJo9Q Dzy+mliynUXF9MCuk5VrtK4HfTitM0J8e8n21vtjRInVQ0L9ePJh2IVN0dCrW7rU/lxE RxDwUgBvY/00QroClzYJPq3khJ1vW5qMDgtX/Nd00IQkJpe8mneomGC5u7GocDaDPEME weVQ== Received: by 10.42.41.11 with SMTP id n11mr28748327ice.13.1343318955293; Thu, 26 Jul 2012 09:09:15 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.43.93.3 with SMTP id bs3csp147684icc; Thu, 26 Jul 2012 09:09:14 -0700 (PDT) Received: by 10.180.100.133 with SMTP id ey5mr14719874wib.4.1343318952683; Thu, 26 Jul 2012 09:09:12 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id e5si11685548wiz.14.2012.07.26.09.09.10 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 Jul 2012 09:09:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1SuQcg-0003MP-Id for ; Thu, 26 Jul 2012 16:09:10 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 7953AE003A for ; Thu, 26 Jul 2012 16:09:10 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: glmark2 X-Launchpad-Branch: ~glmark2-dev/glmark2/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 239 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glmark2-dev/glmark2/trunk] Rev 239: SceneJellyfish: Save and restore custom GL state so other scenes are unaffected Message-Id: <20120726160910.18281.39047.launchpad@ackee.canonical.com> Date: Thu, 26 Jul 2012 16:09:10 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="15679"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 63f1bf8ab91d3d560baa5d428c9682c81748c836 X-Gm-Message-State: ALoCoQk6u6Zs5ExK2c2LJxrAE1FS5FtOPNLC7na+1dB0jHV9oXjLmvbNq+zeq2LE6v/ot89aDnJd ------------------------------------------------------------ revno: 239 committer: Jesse Barker branch nick: trunk timestamp: Thu 2012-07-26 09:07:43 -0700 message: SceneJellyfish: Save and restore custom GL state so other scenes are unaffected when "reuse-context" is enabled. modified: src/scene-jellyfish.cpp src/scene-jellyfish.h --- lp:glmark2 https://code.launchpad.net/~glmark2-dev/glmark2/trunk You are subscribed to branch lp:glmark2. To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/glmark2/trunk/+edit-subscription === modified file 'src/scene-jellyfish.cpp' --- src/scene-jellyfish.cpp 2012-07-11 07:54:17 +0000 +++ src/scene-jellyfish.cpp 2012-07-26 16:07:43 +0000 @@ -348,7 +348,12 @@ fresnelPower_(1.0), rotation_(0.0), currentTime_(0.0), - lastUpdateTime_(0.0) + lastUpdateTime_(0.0), + cullFace_(0), + depthTest_(0), + blend_(0), + blendFuncSrc_(0), + blendFuncDst_(0) { static const string modelFilename(GLMARK_DATA_PATH"/models/jellyfish.jobj"); if (!load_obj(modelFilename)) @@ -467,6 +472,18 @@ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glBindTexture(GL_TEXTURE_2D, 0); } + + // Save the GL state we are changing so we can restore it later. + cullFace_ = glIsEnabled(GL_CULL_FACE); + depthTest_ = glIsEnabled(GL_DEPTH_TEST); + blend_ = glIsEnabled(GL_BLEND); + glGetIntegerv(GL_BLEND_SRC_RGB, &blendFuncSrc_); + glGetIntegerv(GL_BLEND_DST_RGB, &blendFuncDst_); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glDisable(GL_CULL_FACE); + glDisable(GL_DEPTH_TEST); } void @@ -495,6 +512,21 @@ void JellyfishPrivate::cleanup() { + // Restore the GL state we changed for the scene. + glBlendFunc(blendFuncSrc_, blendFuncDst_); + if (GL_FALSE == blend_) + { + glDisable(GL_BLEND); + } + if (GL_TRUE == cullFace_) + { + glEnable(GL_CULL_FACE); + } + if (GL_TRUE == depthTest_) + { + glEnable(GL_DEPTH_TEST); + } + program_.stop(); program_.release(); @@ -554,12 +586,6 @@ glBindTexture(GL_TEXTURE_2D, textureObjects_[whichCaustic_]); program_["uSampler1"] = 1; - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glDisable(GL_CULL_FACE); - glDisable(GL_DEPTH_TEST); - glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]); === modified file 'src/scene-jellyfish.h' --- src/scene-jellyfish.h 2012-07-09 15:00:06 +0000 +++ src/scene-jellyfish.h 2012-07-26 16:07:43 +0000 @@ -104,6 +104,12 @@ float rotation_; float currentTime_; double lastUpdateTime_; + // GL state we plan to override, so we can restore it cleanly. + unsigned int cullFace_; + unsigned int depthTest_; + unsigned int blend_; + int blendFuncSrc_; + int blendFuncDst_; public: JellyfishPrivate();