Prepare to draw to the dynamic screen if dynamic_resolution_ratio != 1.0

Property definitions

gamnit :: dynamic_resolution $ App :: frame_core_dynamic_resolution_before
	# Prepare to draw to the dynamic screen if `dynamic_resolution_ratio != 1.0`
	protected fun frame_core_dynamic_resolution_before(display: GamnitDisplay)
	do
		# TODO autodetect when to lower/increase resolution

		if dynamic_resolution_ratio == 1.0 then
			# Draw directly to the screen framebuffer
			bind_screen_framebuffer screen_framebuffer
			glViewport(0, 0, display.width, display.height)
			glClear gl_COLOR_BUFFER_BIT | gl_DEPTH_BUFFER_BIT

			assert glGetError == gl_NO_ERROR
			return
		end

		# Draw to our dynamic framebuffer
		glBindFramebuffer(gl_FRAMEBUFFER, dynamic_context.dynamic_framebuffer)

		var ratio = dynamic_resolution_ratio
		ratio = ratio.clamp(min_dynamic_resolution_ratio, max_dynamic_resolution_ratio)
		glViewport(0, 0, (display.width.to_f*ratio).to_i,
						 (display.height.to_f*ratio).to_i)

		glClear gl_COLOR_BUFFER_BIT | gl_DEPTH_BUFFER_BIT

		assert glGetError == gl_NO_ERROR
	end
lib/gamnit/dynamic_resolution.nit:89,2--115,4