Nope. Fixed almost everything and now the game layer stretches correctly as it should. But still everything beyond workspace (1920x1080) is pitch black, i.e. 4k looks like this.
here’s our render script
local function fixed_projection(self)
local projected_width = render.get_width()-- / zoom / resZoomX
local projected_height = render.get_height()-- / zoom / resZoom
local xoffset = - (projected_width)/2 --(projected_width - render.get_width()) - 240 --480
local yoffset = - (projected_height)/2 --(projected_height - render.get_height()) - 180 --320
return vmath.matrix4_orthographic(xoffset, xoffset + projected_width, yoffset, yoffset + projected_height, -1000, 5000)
end
function update(self, dt)
render.clear({[render.BUFFER_COLOR_BIT] = vmath.vector4(0,0,0,0), [render.BUFFER_DEPTH_BIT] = 1, [render.BUFFER_STENCIL_BIT] = 0})
render.set_depth_mask(true)
render.set_stencil_mask(0xff)
render.set_viewport(0, 0, window_width, window_height)
render.set_view(self.view)
render.set_depth_mask(false)
render.disable_state(render.STATE_DEPTH_TEST)
render.disable_state(render.STATE_STENCIL_TEST)
render.enable_state(render.STATE_BLEND)
render.set_blend_func(render.BLEND_SRC_ALPHA, render.BLEND_ONE_MINUS_SRC_ALPHA)
render.disable_state(render.STATE_CULL_FACE)
--render to buffer
render.set_projection(fixed_projection())
render.enable_render_target(self.sbuffer)
--draw gfx
render.draw(self.background_pred)
render.draw(self.tiles_pred)
render.draw(self.twode_pred)
render.draw(self.mist_pred)
render.disable_render_target(self.sbuffer)
--send buffer to screen
print(render.get_window_width(), render.get_window_height(), window_width, window_height, resZoom, zoom)
render.set_view(vmath.matrix4())
render.set_viewport(0, 0, window_width / resZoomX, window_height / resZoom)
render.set_projection(vmath.matrix4())
render.enable_texture(0, self.sbuffer, render.BUFFER_COLOR_BIT)
render.draw(self.quad_pred)
render.disable_texture(0, self.sbuffer, render.BUFFER_COLOR_BIT)
--render Lights
render.set_viewport(0, 0, window_width, window_height)
render.set_view(self.view)
render.draw(self.lights_pred)
-- render GUI
render.set_view(vmath.matrix4())
render.set_viewport(0, 0, window_width, window_height)
render.set_projection(vmath.matrix4_orthographic(0, window_width, 0, window_height, -1, 1))
render.enable_state(render.STATE_STENCIL_TEST)
render.draw(self.gui_pred)
render.draw(self.text_pred)
render.disable_state(render.STATE_STENCIL_TEST)
render.draw(self.cursors_pred)
end