Skip to content

Commit e4deb7c

Browse files
authored
Merge pull request #117 from patuwwy/fix-res-change
fix for resolution decrease
2 parents 2978359 + 79b47bc commit e4deb7c

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
## ShaderToy extension changelog:
2+
3+
- 0.13.201 (28-11-2020)
4+
5+
- Temporary fix for resoultion decrease. (doesn't change resoltion when entering fullscreen)
6+
7+
- 0.13.200
8+
9+
- Fix for render timers
10+
211
- 0.13.190 (10-10-2019)
312

413
- Firefox compatibility fix - **alternative profile page and render mode now works in Firefox**.

app/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 2,
33
"name": "Shadertoy unofficial plugin.",
4-
"version": "0.13.200",
4+
"version": "0.13.201",
55
"description": "Shadertoy.com unofficial plugin.",
66
"homepage_url": "https://github.com/patuwwy/ShaderToy-Chrome-Plugin",
77
"background": {

app/shadertoy-plugin.js

+20-8
Original file line numberDiff line numberDiff line change
@@ -295,23 +295,34 @@
295295

296296
/**
297297
* Changes Shader resolution.
298-
* Resolution calculation is based on divider and depends of fullscreen
299-
* mode.
298+
* Resolution calculation is based on divider.
300299
*
301300
* @param {number} divider
302301
*/
303302
decreaseRes(divider) {
304303
var b = this.c.getBoundingClientRect(),
305304
n = {
306-
w: b.width / divider,
307-
h: b.height / divider
305+
w: Math.floor(b.width / divider),
306+
h: Math.floor(b.height / divider)
308307
};
309308

310-
gShaderToy.resize(n.w, n.h);
309+
var mE = gShaderToy.mEffect;
310+
var xres = n.w;
311+
var yres = n.h;
312+
313+
gShaderToy.mEffect.mRO.unobserve(gShaderToy.mCanvas);
314+
315+
mE.mCanvas.setAttribute('width', xres);
316+
mE.mCanvas.setAttribute('height', yres);
317+
mE.mCanvas.width = xres;
318+
mE.mCanvas.height = yres;
319+
mE.mXres = xres;
320+
mE.mYres = yres;
321+
322+
mE.ResizeBuffers(xres, yres);
323+
324+
gShaderToy.iSetResolution(xres, yres);
311325
this.currentDivider = divider;
312-
window.dispatchEvent(
313-
new window.CustomEvent('toyplug:canvas:resolution:changed')
314-
);
315326
}
316327

317328
/**
@@ -351,6 +362,7 @@
351362
var which = e.which,
352363
code = e.code;
353364
if (e.target.id === self.MAIN_SHADERTOY_DEMO_ID) {
365+
console.log(e);
354366
// Alt (or Cmd) + ...
355367
if (e.altKey || e.metaKey) {
356368
// 1...9 Keys

0 commit comments

Comments
 (0)