Skip to content

Commit

Permalink
create app for test
Browse files Browse the repository at this point in the history
  • Loading branch information
sedghi committed Dec 21, 2022
1 parent 358894a commit dc2366e
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 4 deletions.
43 changes: 42 additions & 1 deletion packages/core/examples/volumeAPI/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import {
volumeLoader,
getRenderingEngine,
utilities,
CONSTANTS,
hasNorm16TextureSupport,
hasActiveWebGLContext,
getConfiguration,
} from '@cornerstonejs/core';
import {
initDemo,
Expand Down Expand Up @@ -45,7 +47,31 @@ element.id = 'cornerstone-element';
element.style.width = '500px';
element.style.height = '500px';

const element1 = document.createElement('p');
const element2 = document.createElement('p');
const element3 = document.createElement('p');
const element4 = document.createElement('p');
const element5 = document.createElement('p');
const element6 = document.createElement('p');
const element7 = document.createElement('p');

// update the element div text to have hasNorm16TextureSupport
element2.innerText = `hasNorm16TextureSupport: ${hasNorm16TextureSupport()}`;
element2.style.color = 'blue';

element3.innerText = `isWebGL2Supported: ${hasActiveWebGLContext()}`;
element3.style.color = 'blue';

content.appendChild(element1);
content.appendChild(element2);
content.appendChild(element3);
content.appendChild(element5);
content.appendChild(element4);
content.appendChild(element6);
content.appendChild(element7);

content.appendChild(element);

// ============================= //

// TODO -> Maybe some of these implementations should be pushed down to some API
Expand Down Expand Up @@ -286,6 +312,21 @@ async function run() {
type: 'VOLUME',
});

// @ts-ignore
const gpuConfig = getConfiguration().detectGPU;
const useCPURendering = getConfiguration().rendering.useCPURendering;
element4.innerText = `GPU Tier: ${JSON.stringify(gpuConfig)}`;
element4.style.color = 'blue';

element5.innerText = `Use CPU Rendering: ${useCPURendering}`;
element5.style.color = 'blue';

element6.innerText = `platform: ${navigator.platform}`;
element6.style.color = 'blue';

element7.innerText = `appVersion: ${navigator.appVersion}`;
element7.style.color = 'blue';

// Instantiate a rendering engine
const renderingEngine = new RenderingEngine(renderingEngineId);

Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import {
resetUseCPURendering,
setPreferSizeOverAccuracy,
getConfiguration,
hasNorm16TextureSupport,
hasActiveWebGLContext,
} from './init';

// Classes
Expand All @@ -58,6 +60,8 @@ export type { Types };
export {
// init
init,
hasNorm16TextureSupport,
hasActiveWebGLContext,
isCornerstoneInitialized,
// configs
getConfiguration,
Expand Down
11 changes: 8 additions & 3 deletions packages/core/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { Cornerstone3DConfig } from './types';

let csRenderInitialized = false;

const defaultConfig: Cornerstone3DConfig = {
const defaultConfig = {
detectGPU: {},
rendering: {
preferSizeOverAccuracy: true,
useCPURendering: false,
Expand All @@ -14,7 +15,8 @@ const defaultConfig: Cornerstone3DConfig = {
// ...
};

let config: Cornerstone3DConfig = {
let config = {
detectGPU: {},
rendering: {
preferSizeOverAccuracy: true,
useCPURendering: false,
Expand Down Expand Up @@ -96,6 +98,7 @@ async function init(configuration = {}): Promise<boolean> {
config.rendering.useCPURendering = true;
} else {
const gpuTier = await getGPUTier();
config.detectGPU = gpuTier;
console.log(
'CornerstoneRender: Using detect-gpu to get the GPU benchmark:',
gpuTier
Expand Down Expand Up @@ -164,7 +167,8 @@ function isCornerstoneInitialized(): boolean {
*/
function getConfiguration(): Cornerstone3DConfig {
// return a copy
return JSON.parse(JSON.stringify(config));
// return JSON.parse(JSON.stringify(config));
return config;
}

/**
Expand All @@ -189,4 +193,5 @@ export {
resetUseCPURendering,
setPreferSizeOverAccuracy,
hasNorm16TextureSupport,
_hasActiveWebGLContext as hasActiveWebGLContext,
};

0 comments on commit dc2366e

Please sign in to comment.