Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

how I am new to OpenGL and especally with JOGL. I currently try to learn JOGL. I dont like to create a special thread that runs the display method of my window, so I called it manually.

public static void main(String[] args) 
{
    GLProfile.initSingleton();
    GLProfile glp = GLProfile.get(GLProfile.GL2);
    GLCapabilities caps = new GLCapabilities(glp);
    GLWindow window = GLWindow.create(caps);

    window.setSize(800, 480);
    window.setTitle("Test");
    window.setVisible(true);        

    boolean isRunning = true;
    while(isRunning )
    {
        window.display();
    }
}

That works pretty fine, but now I dont know, how I can draw something on the window, without adding a "addGLEventListener". I tried a lot of stuff like this...

while(isRunning )
{
    GL2 gl = window.getGL().getGL2();
    gl.glClear(GL.GL_COLOR_BUFFER_BIT);
    gl.glLoadIdentity();

    gl.glBegin(GL.GL_TRIANGLES);
    gl.glColor3f(1, 0, 0);
    gl.glVertex2d(-0.1, -0.1);
    gl.glColor3f(0, 1, 0);
    gl.glVertex2d(0, 0.1);
    gl.glColor3f(0, 0, 1);
    gl.glVertex2d(0.1, -0.1);
    gl.glEnd();

    window.display();
}

But this not works. I hope someone know how I can use JOGL so. The reason why I want to do this is, that I want to program me a small game framwork/JOGL wrapper. And there is the normal way not very good, at least for beginners.

share|improve this question
    
I believe you just need to do those things on the window thread, which is why you end up needing the GLEventListener. –  Eugene Marcotte Feb 27 at 21:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.