Skip to content

Commit a8890e4

Browse files
committed
nes: fix canvas initial size
1 parent e4279ee commit a8890e4

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

plugins/Nes.vue

+13-7
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
<i class="pi pi-play" style="font-size: 5rem"></i> <br />
55
<h4>Click here to start the emulation</h4>
66
</div>
7-
<div v-show="loading == 1">
8-
<canvas class="shadow-3 gamecanvas" ref="gamecanvas"></canvas>
7+
<div ref="gamediv" style="width: 100%" v-show="loading == 1">
8+
<canvas
9+
height="240"
10+
width="256"
11+
class="shadow-3 gamecanvas"
12+
ref="gamecanvas"
13+
></canvas>
914
</div>
1015
</div>
1116
</template>
@@ -70,8 +75,8 @@ export default {
7075
gamerom: null,
7176
fps: 60,
7277
ticks: 0,
73-
height: 432,
74-
width: 480,
78+
height: 240,
79+
width: 256,
7580
loaded: false,
7681
loadedFile: null,
7782
paused: false,
@@ -511,12 +516,13 @@ class WebGLRenderer {
511516
const gl = (this.gl = el.getContext("webgl2", {
512517
preserveDrawingBuffer: true,
513518
}));
519+
console.log(gl);
514520
if (gl === null) {
515521
throw new Error("unable to create webgl context");
516522
}
517523
518-
const w = SCREEN_WIDTH / 256;
519-
const h = SCREEN_HEIGHT / 256;
524+
const w = 256 / 256;
525+
const h = 240 / 256;
520526
const buffer = gl.createBuffer();
521527
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
522528
gl.bufferData(
@@ -651,7 +657,7 @@ class WebGLRenderer {
651657
652658
/* Fill the available space */
653659
width: 100%;
654-
/* Original resolution ratio */
660+
/* Original resolution ratio */
655661
aspect-ratio: 256 / 240;
656662
657663
margin: 0; /* binjgb */

0 commit comments

Comments
 (0)