Question

I am trying use lwjgl in NetBeans RCP application. I added my own AWTGLCanvas to my window top component. Problem is that resizing not working when I am trying scale down size of my window (see picture here http://i.stack.imgur.com/MKw2n.png)

My GLCanvas implemented here:

public class GLCanvas extends AWTGLCanvas
{
    public GLCanvas() throws LWJGLException
    {
    }

    @Override
    protected void paintGL()
    {
        try
        {
            glViewport(0, 0, getWidth(), getHeight());
            glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            glClear(GL_COLOR_BUFFER_BIT);

            glMatrixMode(GL_PROJECTION);
            glLoadIdentity();
            gluOrtho2D(0.0f, (float) getWidth(), 0.0f, (float) getHeight());
            glMatrixMode(GL_MODELVIEW);

            paintLine();

            swapBuffers();
        } 
        catch (Exception e)
        {
        }
    }

    private void paintLine()
    {
        glPushMatrix();
            glColor3f(0f, 1f, 0f);
            glTranslatef(getWidth() / 2f, getHeight() / 2f, 0f);
            glLineWidth(1f);

            glBegin(GL_LINE_STRIP);
                glVertex2f(-getWidth() * 0.4f, 0f);
                glVertex2f(getWidth() * 0.4f, 0f);
            glEnd();
        glPopMatrix();
    }
}

I added my GLCanvas into my window TopComponent in constructor:

public MyGLTopComponent()
{
    setLayout(new GridLayout(1,1));

    try
    {
        GLCanvas glCanvas = new GLCanvas();
        add(glCanvas);
    }
    catch (LWJGLException ex)
    {
        Exceptions.printStackTrace(ex);
    }
}

Any idea why resizing (scaling down) not working ?

Was it helpful?

Solution

Problem solved .. LWJGL using canvas to render ... canvas must have set minimum size to 0 ... myCanvas.setMinimumSize(new Dimension(0, 0))

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top