Skip to content

Commit

Permalink
Force drawing
Browse files Browse the repository at this point in the history
idk why i have to draw 2 times to update the viewport...
  • Loading branch information
iY0Yi committed May 10, 2024
1 parent 36dbd6b commit f080521
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/js/buffer/buffer_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export default ShaderBoy.bufferManager = {
this.compileShaders()
}

ShaderBoy.forceDraw = (ShaderBoy.isPlaying !== true)
ShaderBoy.forceDraw = !ShaderBoy.isPlaying
},

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
8 changes: 4 additions & 4 deletions src/js/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,31 +142,31 @@ export default ShaderBoy.commands = {
{
ShaderBoy.renderScale = 1
ShaderBoy.bufferManager.setFBOsProps()
if (ShaderBoy.isPlaying !== true) ShaderBoy.forceDraw = true
ShaderBoy.forceDraw = !ShaderBoy.isPlaying
},

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
setResolution2()
{
ShaderBoy.renderScale = 2
ShaderBoy.bufferManager.setFBOsProps()
if (ShaderBoy.isPlaying !== true) ShaderBoy.forceDraw = true
ShaderBoy.forceDraw = !ShaderBoy.isPlaying
},

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
setResolution3()
{
ShaderBoy.renderScale = 3
ShaderBoy.bufferManager.setFBOsProps()
if (ShaderBoy.isPlaying !== true) ShaderBoy.forceDraw = true
ShaderBoy.forceDraw = !ShaderBoy.isPlaying
},

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
setResolution4()
{
ShaderBoy.renderScale = 4
ShaderBoy.bufferManager.setFBOsProps()
if (ShaderBoy.isPlaying !== true) ShaderBoy.forceDraw = true
ShaderBoy.forceDraw = !ShaderBoy.isPlaying
},

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
8 changes: 4 additions & 4 deletions src/js/gui/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default ShaderBoy.gui = {
gui.mousePosX = gui.mouseOriX
gui.mousePosY = gui.mouseOriY
ShaderBoy.uniforms.iMouse = [gui.mousePosX, gui.mousePosY, gui.mouseOriX, gui.mouseOriY]
if (ShaderBoy.isPlaying !== true) ShaderBoy.forceDraw = true
ShaderBoy.forceDraw = !ShaderBoy.isPlaying
}
}

Expand All @@ -119,7 +119,7 @@ export default ShaderBoy.gui = {
gui.mouseOriX=Math.abs(gui.mouseOriX)*-1
gui.mouseOriY=Math.abs(gui.mouseOriY)*-1
ShaderBoy.uniforms.iMouse = [gui.mousePosX, gui.mousePosY, gui.mouseOriX, gui.mouseOriY]
if (ShaderBoy.isPlaying !== true) ShaderBoy.forceDraw = true
ShaderBoy.forceDraw = !ShaderBoy.isPlaying
}
}

Expand All @@ -134,7 +134,7 @@ export default ShaderBoy.gui = {
gui.mouseOriX=Math.abs(gui.mouseOriX)
gui.mouseOriY=Math.abs(gui.mouseOriY)*-1
ShaderBoy.uniforms.iMouse = [gui.mousePosX, gui.mousePosY, gui.mouseOriX, gui.mouseOriY]
if (ShaderBoy.isPlaying !== true) ShaderBoy.forceDraw = true
ShaderBoy.forceDraw = !ShaderBoy.isPlaying
}
}
}
Expand Down Expand Up @@ -170,7 +170,7 @@ export default ShaderBoy.gui = {
ev.deltaZ,
this.iWheelCumulative[2],
]
if (ShaderBoy.isPlaying !== true) ShaderBoy.forceDraw = true
ShaderBoy.forceDraw = !ShaderBoy.isPlaying
}
})

Expand Down
4 changes: 2 additions & 2 deletions src/js/gui/gui_keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default ShaderBoy.gui_keyboard = {
{
if (ShaderBoy.isEditorHidden || ShaderBoy.isSplited){
this.setKeyDown( ev.keyCode )
if (ShaderBoy.isPlaying !== true) ShaderBoy.forceDraw = true
ShaderBoy.forceDraw = !ShaderBoy.isPlaying
}
}
}
Expand All @@ -42,7 +42,7 @@ export default ShaderBoy.gui_keyboard = {
console.log('onkeyup')
if (ShaderBoy.isEditorHidden || ShaderBoy.isSplited){
this.setKeyUp( ev.keyCode )
if (ShaderBoy.isPlaying !== true) ShaderBoy.forceDraw = true
ShaderBoy.forceDraw = !ShaderBoy.isPlaying
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/gui/gui_knobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default ShaderBoy.gui_knobs = {

if (ShaderBoy.gui.knobs.knobs[i].active === true)
{
ShaderBoy.forceDraw = (ShaderBoy.isPlaying !== true)
ShaderBoy.forceDraw = !ShaderBoy.isPlaying
const delta = (e.deltaY < 0) ? 1 : -1
const deg = e.deltaY
ShaderBoy.gui.knobs.knobs[i].value += delta * velocity * (1 / ShaderBoy.gui.knobs.precision)// deg * 1 / ShaderBoy.gui.knobs.precision
Expand Down
2 changes: 1 addition & 1 deletion src/js/gui/gui_midi.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default ShaderBoy.gui_midi = {
{
ShaderBoy.gui.midis[data.name] = data.value
}
ShaderBoy.forceDraw = (ShaderBoy.isPlaying !== true)
ShaderBoy.forceDraw = !ShaderBoy.isPlaying

ShaderBoy.gui_header.setStatus('prgrs', `MIDI: ${data.name} = ${data.value}...`, 3000)
},
Expand Down
8 changes: 7 additions & 1 deletion src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,15 @@ ShaderBoy.update = () =>
else if (ShaderBoy.forceDraw === true)
{
imageRenderer.render()
ShaderBoy.forceDraw = false
if(ShaderBoy.forceDrawnCount++>=2)
{
// idk why i have to draw 2 times to update viewport...
ShaderBoy.forceDraw = false
ShaderBoy.forceDrawnCount = 0
}
}


gui.redraw()
}

Expand Down
1 change: 1 addition & 0 deletions src/js/shaderboy.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const ShaderBoy = {
isDirty: true,

forceDraw: false,
forceDrawnCount: 0,
editingBuffer: '',
vsSource: null,
screenShader: null,
Expand Down

0 comments on commit f080521

Please sign in to comment.