Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
105218ee
Commit
105218ee
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
better handle pixelRatio
parent
4db38ed6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/mol-gl/renderer.ts
+1
-6
1 addition, 6 deletions
src/mol-gl/renderer.ts
src/mol-gl/webgl/context.ts
+6
-0
6 additions, 0 deletions
src/mol-gl/webgl/context.ts
src/mol-view/viewer.ts
+3
-1
3 additions, 1 deletion
src/mol-view/viewer.ts
with
10 additions
and
7 deletions
src/mol-gl/renderer.ts
+
1
−
6
View file @
105218ee
...
...
@@ -39,10 +39,6 @@ interface Renderer {
dispose
:
()
=>
void
}
function
getPixelRatio
()
{
return
(
typeof
window
!==
'
undefined
'
)
?
window
.
devicePixelRatio
:
1
}
export
const
DefaultRendererProps
=
{
clearColor
:
0x000000
as
Color
,
viewport
:
Viewport
.
create
(
0
,
0
,
0
,
0
)
...
...
@@ -56,7 +52,6 @@ namespace Renderer {
const
model
=
Mat4
.
identity
()
const
viewport
=
Viewport
.
clone
(
_viewport
)
const
pixelRatio
=
getPixelRatio
()
// const lightPosition = Vec3.create(0, 0, -100)
const
lightColor
=
Vec3
.
create
(
1.0
,
1.0
,
1.0
)
...
...
@@ -73,7 +68,7 @@ namespace Renderer {
uView
:
ValueCell
.
create
(
Mat4
.
clone
(
camera
.
view
)),
uProjection
:
ValueCell
.
create
(
Mat4
.
clone
(
camera
.
projection
)),
uPixelRatio
:
ValueCell
.
create
(
pixelRatio
),
uPixelRatio
:
ValueCell
.
create
(
ctx
.
pixelRatio
),
uViewportHeight
:
ValueCell
.
create
(
viewport
.
height
),
uLightColor
:
ValueCell
.
create
(
Vec3
.
clone
(
lightColor
)),
...
...
This diff is collapsed.
Click to expand it.
src/mol-gl/webgl/context.ts
+
6
−
0
View file @
105218ee
...
...
@@ -7,6 +7,10 @@
import
{
createProgramCache
,
ProgramCache
}
from
'
./program
'
import
{
createShaderCache
,
ShaderCache
}
from
'
./shader
'
function
getPixelRatio
()
{
return
(
typeof
window
!==
'
undefined
'
)
?
window
.
devicePixelRatio
:
1
}
function
unbindResources
(
gl
:
WebGLRenderingContext
)
{
// bind null to all texture units
const
maxTextureImageUnits
=
gl
.
getParameter
(
gl
.
MAX_TEXTURE_IMAGE_UNITS
)
...
...
@@ -61,6 +65,7 @@ type Extensions = {
export
interface
Context
{
gl
:
WebGLRenderingContext
extensions
:
Extensions
pixelRatio
:
number
shaderCache
:
ShaderCache
programCache
:
ProgramCache
...
...
@@ -100,6 +105,7 @@ export function createContext(gl: WebGLRenderingContext): Context {
return
{
gl
,
extensions
:
{
angleInstancedArrays
,
standardDerivatives
,
oesElementIndexUint
,
oesVertexArrayObject
},
pixelRatio
:
getPixelRatio
(),
shaderCache
,
programCache
,
...
...
This diff is collapsed.
Click to expand it.
src/mol-view/viewer.ts
+
3
−
1
View file @
105218ee
...
...
@@ -179,9 +179,11 @@ namespace Viewer {
}
function
identify
(
x
:
number
,
y
:
number
):
PickingId
{
const
buffer
=
new
Uint8Array
(
4
)
x
*=
ctx
.
pixelRatio
y
*=
ctx
.
pixelRatio
y
=
canvas
.
height
-
y
// flip y
const
buffer
=
new
Uint8Array
(
4
)
const
xp
=
Math
.
round
(
x
*
pickScale
)
const
yp
=
Math
.
round
(
y
*
pickScale
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment