     get_viewport_coordinates: (x, y) ->
         y = @height - y
         for viewport in @viewports by -1
-            [left, bottom, width, height] = viewport.rect_pix
+            [left, bottom, width, height] = viewport.rect
+            left *= @width
+            width *= @width
+            bottom *= @height
+            height *= @height
             right = left+width
             top = bottom+height
             if left < x < right and bottom < y < top

        @viewports = []
        @framebuffer = null
        @width = @height = @diagonal = 0
        @enabled = true
        @init @context, args...


            if not @context.vr_screen? and @auto_resize_to_canvas
                @resize_to_canvas()

    resize_to_canvas: (@pixel_ratio_x=1, @pixel_ratio_y=1) ->
        {clientWidth, clientHeight} = @canvas
        if clientWidth == @width and clientHeight == @height
            return
