用户调整窗口大小后,JOGL查找当前屏幕大小

时间:2016-12-06 19:49:11

标签: java opengl graphics jogl

如何在JOGL实例中找到当前窗口大小。用户可以手动完成此操作,这是我到目前为止所用的,但是这只是保持返回1920 x 1080.但是我想要它,所以它返回当前窗口的宽度和高度。

Sub addToMaster()

    'get the customer from the invoice sheet
    Dim strCustomer As String
    strCustomer = Sheet1.Range("A1").Value

    'find the customer in the master sheet's column A and grab the row
    Dim rowFoundCustomer As Range
    Set rowFoundCustomer = Sheet2.Range("A:A").Find(strCustomer).EntireRow()

    'write back out to the row in columns D, E, and F (4,5 and 6)
    '   the values for our fruits on the invoice
    rowFoundCustomer.Cells(1, 4) = Sheet1.Range("B2") 'apples
    rowFoundCustomer.Cells(1, 5) = Sheet1.Range("B3") 'bananas
    rowFoundCustomer.Cells(1, 6) = Sheet1.Range("B4") 'oranges
End Sub

此外,显示方法对窗口大小的响应非常晚,是他们更好的方法吗?

更新:我通过获取放置的JFrame的大小然后适当地重置画布大小来完成此操作

更新代码:

@Override
public void display(GLAutoDrawable glautodrawable) {

    GL gl = glautodrawable.getGL();
    int newWidth = glautodrawable.getWidth();
    int newHeight = glautodrawable.getHeight();
    System.out.println(newWidth + "   " + newHeight);
    try {
        render(gl, newWidth, newHeight);
    } catch (IOException ex) {
        Logger.getLogger(dataModelGLEventListener.class
                .getName()).log(Level.SEVERE, null, ex);
    }
}

然而,这会导致菜单栏项目在画布后面呈现并重新绘制并验证似乎对此没有影响,我该如何解决这个问题?

0 个答案:

没有答案
相关问题