Skip to content
Snippets Groups Projects
Commit d41491c5 authored by Paul Kaplan's avatar Paul Kaplan
Browse files

Use new renderer methods to check for WebGL.

Remove the WebGL checks from the error boundary. Instead, just do not
render the stage if it is not supported.
parent 752347da
Branches
Tags
No related merge requests found
......@@ -6,6 +6,7 @@ import MediaQuery from 'react-responsive';
import {FormattedMessage} from 'react-intl';
import tabStyles from 'react-tabs/style/react-tabs.css';
import VM from 'scratch-vm';
import Renderer from 'scratch-render';
import Blocks from '../../containers/blocks.jsx';
import CostumeTab from '../../containers/costume-tab.jsx';
......@@ -63,6 +64,8 @@ const GUIComponent = props => {
tabSelected: classNames(tabStyles.reactTabsTabSelected, styles.isSelected)
};
const isRendererSupported = Renderer.isSupported();
return (
<Box
className={styles.pageWrapper}
......@@ -74,7 +77,9 @@ const GUIComponent = props => {
{feedbackFormVisible ? (
<FeedbackForm />
) : null}
{(window.WebGLRenderingContext) ? null : (<WebGlModal />)}
{isRendererSupported ? null : (
<WebGlModal />
)}
<MenuBar />
<Box className={styles.bodyWrapper}>
<Box className={styles.flexWrapper}>
......@@ -127,14 +132,18 @@ const GUIComponent = props => {
<StageHeader vm={vm} />
</Box>
<Box className={styles.stageWrapper}>
<MediaQuery minWidth={layout.fullSizeMinWidth}>{isFullSize => (
<Stage
height={isFullSize ? layout.fullStageHeight : layout.smallerStageHeight}
shrink={0}
vm={vm}
width={isFullSize ? layout.fullStageWidth : layout.smallerStageWidth}
/>
)}</MediaQuery>
{/* eslint-disable arrow-body-style */}
<MediaQuery minWidth={layout.fullSizeMinWidth}>{isFullSize => {
return isRendererSupported ? (
<Stage
height={isFullSize ? layout.fullStageHeight : layout.smallerStageHeight}
shrink={0}
vm={vm}
width={isFullSize ? layout.fullStageWidth : layout.smallerStageWidth}
/>
) : null;
}}</MediaQuery>
{/* eslint-enable arrow-body-style */}
</Box>
<Box className={styles.targetWrapper}>
<TargetPane
......
......@@ -28,14 +28,6 @@ class ErrorBoundary extends React.Component {
if (platform.name === 'IE') {
return <BrowserModalComponent onBack={this.handleBack} />;
}
if (window.WebGLRenderingContext) {
const canvas = document.createElement('canvas');
if (!canvas.getContext('webgl') && !canvas.getContext('experimental-webgl')) {
return <WebGlModalComponent onBack={this.handleBack} />;
}
} else {
return <WebGlModalComponent onBack={this.handleBack} />;
}
return (
<div style={{margin: '2rem'}}>
<h1>Oops! Something went wrong.</h1>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment